Jump to content

Simple script


Recommended Posts

Hey guys, came back to eluna after a little break and I'm trying to start with some simple stuff. First of all I wanted to make a script for npc so when the player gets in rage he yells to him to come over, make it just once. My problem is that the yell loops infinitely for a reason I can't find . Could someone show me my mistake ? :P


Here's the code:

local entry     = 50000;

local function Greetings(event, delay, repeats, creature)
    creature:SendUnitYell("Hey you, over here!", 0)

local function Welcome(event, creature, player)
if creature: GetPlayersInRange(10) then
    creature:RegisterEvent(Greetings, 1000, 1)

RegisterCreatureEvent(entry, 27, Welcome)

Link to comment
Share on other sites

The script MUST save data in some way about who it has sent the message to already so it can know who not to message anymore.

This can be done either by saving data in the script it self (for example have a list of player guids stored) or you can for example add some dummy aura on the player to signal that he has been already messaged once and then code it so that dont send messages to players with such an aura. There can be other workarounds too.
To store the data in the script, you can use a table, but that would be shared with every creature that uses the same script.
You could also use a table indexed by creature guids, but instead you could see if the object variables extension suits you:

After saying the message once, the creature would not say it again. You might want to make it say the text again if the player gets out of sight and comes back for example, so thats something to think about.

Also it seems that at the moment your script would yell to all players nearby every time a new player gets near.
You may want to try use http://www.elunaengine.com/Unit/SendChatMessageToPlayer.html instead to send the message to a specific player.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use