Advertisement
Rochet2

Simple gossip

Jan 17th, 2012
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. local Entry = 123 -- NPC entry
  2. local npc_text = 700000
  3. local T =
  4. {
  5. --  {icon, "Name", npc_text+X},
  6.     {0, "I would like to know how the server works", npc_text+1},
  7.     {0, "I would like to know how I level up", npc_text+2},
  8.     {0, "I would like to know where the mall is located", npc_text+3},
  9.     {0, "How can I find other players?", npc_text+4},
  10. }
  11. local D = #T
  12.  
  13. function T.Hello(pUnit, event, pPlayer)
  14.     pUnit:GossipCreateMenu(npc_text, pPlayer, 0)
  15.     for k, v in ipairs(T) do
  16.         pUnit:GossipMenuAddItem(v[1], v[2], D+k, 0, '', 0)
  17.     end
  18.     pUnit:GossipSendMenu(pPlayer)
  19. end
  20.  
  21. function T.Select(pUnit, event, pPlayer, id, intid, code)
  22.     if(intid > D) then
  23.         pUnit:GossipCreateMenu(T[intid-D][3], pPlayer, 0)
  24.         pUnit:GossipMenuAddItem(0, "Back..", 0, 0, '', 0)
  25.         pUnit:GossipSendMenu(pPlayer)
  26.         return
  27.     end
  28.     T.Hello(pUnit, event, pPlayer)
  29. end
  30.  
  31. RegisterUnitGossipEvent(Entry, 1, T.Hello)
  32. RegisterUnitGossipEvent(Entry, 1, T.Select)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement