Gossip scripts have lots of buggy things where you have to make hack-fixes to get around.
For example, you can't have only 1 menu otherwise it automatically does it straight away. To make it only display 1 menu yet not skip it, you would do something like:
Code:
function menus()
pUnit:createmenu()
pUnit:AddMenu("hi",player,0) -- Or whatever the command is
if pUnit == 0 then -- This can't happen
pUnit:AddMenu("DEBUG", player, 0)
end
end
You also can't register events in a gossip menu. To do this make it check to see if a variable is at a state on spawn every 5 seconds forever, and when a gossip menu is selected change the state of that variable so it can do that registered event.
Answering your question though:
Code:
RegisterUnitGossipEvent(npcid, 1, "OnTalk")
RegisterUnitGossipEvent(npcid, 2, "OnItemSelect")
You can find helpful documentation on all of this through the following two links: