Get your lua script to target the npc you want, with examples menu

User Tag List

Results 1 to 5 of 5
  1. #1
    choweyiii's Avatar Contributor
    Reputation
    91
    Join Date
    Aug 2010
    Posts
    127
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get your lua script to target the npc you want, with examples

    You will need to add some things at the end of your .lua so the script knows which npc you're talking about, this will teach you some basics, with a cheesy example, and how to remove events on bosses (so the players are not in combat once the creature is dead).

    You can name the .lua file whatever you want, as long as the things inside are correct, I'm very tired, so some of these may be mistakes, correct me if i'm wrong, please!

    Feel free to change the messages.
    PM me if you need some more help, I'm a noob to scripting, but I think I've got the basics down.

    For gossip NPCs add:


    Code:
    RegisterUnitGossipEvent(NPC ID GOES HERE, 1, "On_Gossip")
    RegisterUnitGossipEvent(NPC ID GOES HERE, 2, "Gossip_Submenus")
    end

    For bosses:

    Code:
    function CreatureNameGoesHereWithCaps_OnCombat(pUnit, Event)
    local RandomTalk=math.random(1, 3);
    if RandomTalk == 1 then
    pUnit:SendChatMessage(14, 0, "rarr you pulled me") 
    elseif RandomTalk == 2 then
    pUnit:SendChatMessage(14, 0, "im cummin to getch ye")
    elseif RandomTalk == 3 then
    pUnit:SendChatMessage(14, 0, "it's a one in three chance to see this message, personally, i think this one is the best, arn't you lucky")
    end
    end
    
    function CreatureNameGoesHereWithCaps_OnDied(pUnit, Event)
    pUnit:SendChatMessage(14, 0, "oh noes im deads")
    pUnit:RemoveEvents()
    end 
    
    function CreatureNameGoesHereWithCaps_OnLeaveCombat(pUnit, Event)
    pUnit:SendChatMessage(14, 0, "this is what i yell when i leave combat, like when players wipe or run away!")
    pUnit:RemoveEvents()
    end
    
    function CreatureNameGoesHereWithCaps_OnKilledTarget(pUnit, Event)
    local RandomText=math.random(1, 3)
    if RandomText == 1 then
    pUnit:SendChatMessage(14, 0, "pwned")
    elseif RandomText == 2 then
    pUnit:SendChatMessage(14, 0, "this is what i yell when i kill somthing")
    elseif RandomText == 3 then
    pUnit:SendChatMessage(14, 0, "l2p")
    end
    end
    
    RegisterUnitEvent(NPC ID GOES HERE, 1, "CreatureNameGoesHereWithCaps_OnCombat") 
    RegisterUnitEvent(NPC ID GOES HERE, 2, "CreatureNameGoesHereWithCaps_OnLeaveCombat") 
    RegisterUnitEvent(NPC ID GOES HERE, 3, "CreatureNameGoesHereWithCaps_OnKilledTarget")
    RegisterUnitEvent(NPC ID GOES HERE, 4, "CreatureNameGoesHereWithCaps_OnDied")
    end
    Good Luck!
    Last edited by choweyiii; 08-12-2010 at 08:44 PM.

    Get your lua script to target the npc you want, with examples
  2. #2
    Claiver's Avatar Member
    Reputation
    138
    Join Date
    Mar 2009
    Posts
    217
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think the title of the thread fits the content at all - I have no clue how it is related to it - but you've done your best to contribute, which gets my rep.

  3. #3
    EpicPwner's Avatar Member
    Reputation
    1
    Join Date
    May 2009
    Posts
    14
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice, hopefully helps somebody in some way

  4. #4
    MaCAppLeBiTeMe's Avatar Private
    Reputation
    1
    Join Date
    Jul 2010
    Posts
    6
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think he's trying to teach how to link script with creature if I'm not mistaken?

  5. #5
    pantryboy's Avatar Member
    Reputation
    44
    Join Date
    Sep 2008
    Posts
    99
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're linking the script with the creature, as MaCAppLeBiTeMe said... If you didn't do this the script would do nothing.
    If you wanted to make a script select a specific creature, you would spawn it in-game, get it's SQL Id and do this:
    Code:
    local creature = Unit:GetUnitBySqlId(...)
    Then you can invoke actions on the creature variable.

Similar Threads

  1. [Selling] [US] *The Gem shop* Get your flawless squared gems while the market is down!
    By nuclear12347 in forum Diablo 3 Buy Sell Trade
    Replies: 0
    Last Post: 05-25-2012, 11:33 PM
  2. How to get your server off of hamachi (THE EASY WAY)
    By snowbird in forum WoW EMU Guides & Tutorials
    Replies: 58
    Last Post: 12-02-2010, 03:54 PM
  3. Replies: 22
    Last Post: 05-29-2008, 03:52 PM
  4. [HOWTO] Get a pet with all the abilities you want[HUNTER]
    By JoeBiden in forum World of Warcraft Guides
    Replies: 13
    Last Post: 12-31-2007, 08:20 AM
  5. [PTR] Get on the server you want.
    By Icicle in forum World of Warcraft Guides
    Replies: 10
    Last Post: 01-30-2007, 02:36 PM
All times are GMT -5. The time now is 01:10 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search