View Full Version : What's Wrong with my Beastmaster Script?

03-07-2014, 01:02 AM
I am creating a script for my server to have an NPC that will train hunter pets when they click on a certain option. However, I can't progress any further because my script won't work. The intention is that when the NPC is right clicked a gossip menu will come up with 3 options, Cunning, Ferocity, and Tenacity (the 3 hunter pet skill trees). When any of those options are selected it'll take you to another gossip menu with a list of those pets in that skill tree. And for players that aren't Hunters it will tell them they aren't a Hunter and close gossip. However, for some reason when I right click the NPC it won't even take me to the first gossip menu when on a Hunter and when on any other class it doesn't show the broadcast message. I tried to make the script as simple as possible to try and make it work but it still won't work. If someone can diagnose the issue it'd be much appreciated.


03-07-2014, 02:44 AM
Well for one the 'X_error' functions aren't needed at all. Second, the function arguments for 'OnGossipHello' and 'OnGossipSelect' are in correct.

If you go to the wiki to the Gossip Hook documentation page, it will show you everything you need to know: http://wiki.emudevs.com/doku.php?id=eluna_gossip_events

Not sure why you're calling 'GossipCreateMenu', looks like ArcEmu to me. If you aren't sure about the gossip methods, you can always go to LuaFunctions.cpp (or the wiki) and view them: https://github.com/ElunaLuaEngine/Eluna-TC-Wotlk/blob/master/src/LuaEngine/LuaFunctions.cpp#L556-L559

'GetPlayerClass' is also not a valid method. You can use 'GetClassAsString' to return the class as a string.

Your arguments for 'GossipMenuAddItem' is incorrect as well. It should be:

:GossipMenuAddItem(icon, msg, sender, intid[, code, popup, money])

Your Register function is incorrect. It should be 'RegisterCreatureGossipEvent(entry, EventId, function)' - the "function" does not need to be in quotations.

Here you go:

local NPCID = 41001

local function OnGossipHello(event, player, object)
if (player:GetClassAsString() == "Hunter") then
player:GossipMenuAddItem(4, "Cunning", 0, 1)
player:GossipMenuAddItem(4, "Ferocity", 0, 2)
player:GossipMenuAddItem(4, "Tenacity", 0, 3)
player:SendNotification("You are not a hunter!")

local function OnGossipSelect(event, player, object, sender, intid, code)
if(intid == 1) then
player:GossipMenuAddItem(3, "Bat", 0, 4)
player:GossipMenuAddItem(3, "Bird of Prey", 0, 5)
player:GossipMenuAddItem(3, "Dragonhawk", 0, 6)
player:GossipMenuAddItem(3, "Ravager", 0, 6)
player:GossipMenuAddItem(3, "Serpent", 0, 7)
player:GossipMenuAddItem(3, "Spider", 0, 8)
player:GossipMenuAddItem(3, "Wind Serpent", 0, 9)
elseif(intid == 2) then
player:GossipMenuAddItem(3, "Carrion Bird", 0, 10)
player:GossipMenuAddItem(3, "Cat", 0, 11)
player:GossipMenuAddItem(3, "Hound", 0, 12)
player:GossipMenuAddItem(3, "Hyena", 0, 13)
player:GossipMenuAddItem(3, "Moth", 0, 14)
player:GossipMenuAddItem(3, "Raptor", 0, 15)
player:GossipMenuAddItem(3, "Tallstrider", 0, 16)
player:GossipMenuAddItem(3, "Wolf", 0, 17)
elseif(intid == 3) then
player:GossipMenuAddItem(3, "Basilisk", 0, 18)
player:GossipMenuAddItem(3, "Bear", 0, 19)
player:GossipMenuAddItem(3, "Boar", 0, 20)
player:GossipMenuAddItem(3, "Crab", 0, 21)
player:GossipMenuAddItem(3, "Crocolisk", 0, 22)
player:GossipMenuAddItem(3, "Scorpid", 0, 23)
player:GossipMenuAddItem(3, "Turtle", 0, 24)

RegisterCreatureGossipEvent(NPCID, 1, OnGossipHello)
RegisterCreatureGossipEvent(NPCID, 2, OnGossipSelect)