Advertisement
Guest User

DBGossip

a guest
Jul 8th, 2012
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.85 KB | None | 0 0
  1. --######################
  2. --# By Keta of Modcraft#
  3. --######################
  4.  
  5. local NPCID = 500500
  6.  
  7. local AnswerOnId = 0
  8.  
  9. local function NPC_GossipHello(pUnit, event, pPlayer)
  10.     pUnit:GossipCreateMenu(100, pPlayer, 0)
  11.     local result = WorldDBQuery( "SELECT * FROM `gossip_menus`" );
  12.     if( result ~= NIL ) then
  13.         local rowcount = result:GetRowCount();
  14.         local colcount = result:GetColumnCount();
  15.        
  16.         repeat
  17.             if (result:GetColumn(1):GetUShort() == AnswerOnId) then
  18.                 pUnit:GossipMenuAddItem(result:GetColumn(3):GetUShort(), result:GetColumn(2):GetString(), result:GetColumn(4):GetUShort(), 0)
  19.             end
  20.         until result:NextRow() ~= true;
  21.         pUnit:GossipMenuAddItem(0, "[Exit]", 0, 0)
  22.     end
  23.     pUnit:GossipSendMenu(pPlayer)
  24. end
  25.  
  26. local function NPC_GossipSelect(pUnit, event, pPlayer, id, intid, code)
  27.  
  28.     local MenuAdded = false
  29.     if (intid == 0) then
  30.         pPlayer:GossipComplete()
  31.     elseif (intid == 500) then
  32.         pPlayer:SendBroadcastMessage(pPlayer:GetName())
  33.         pPlayer:GossipComplete()
  34.     else
  35.         local result = WorldDBQuery( "SELECT * FROM `gossip_menus`" );
  36.        
  37.         pUnit:GossipCreateMenu(100, pPlayer, 0)
  38.        
  39.         if( result ~= NIL ) then
  40.             local rowcount = result:GetRowCount();
  41.             local colcount = result:GetColumnCount();
  42.        
  43.             repeat
  44.                 if (result:GetColumn(1):GetUShort() == intid) then
  45.                     pUnit:GossipMenuAddItem(result:GetColumn(3):GetUShort(), result:GetColumn(2):GetString(), result:GetColumn(4):GetUShort(), 0)
  46.                     MenuAdded = true
  47.                 end
  48.             until result:NextRow() ~= true;
  49.            
  50.         end
  51.         pUnit:GossipMenuAddItem(0, "[Exit]", 0, 0)
  52.        
  53.         if MenuAdded == false then
  54.             pPlayer:GossipComplete()
  55.             pPlayer:SendBroadcastMessage("Error: Missing Menu Table. Report to developers")
  56.         else
  57.             pUnit:GossipSendMenu(pPlayer)
  58.         end
  59.     end
  60. end
  61.  
  62. RegisterUnitGossipEvent(NPCID, 1, NPC_GossipHello)
  63. RegisterUnitGossipEvent(NPCID, 2, NPC_GossipSelect)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement