Advertisement
alamiku

Gamble

Sep 28th, 2011
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. --Gamble NPC.
  2. --For Arcemu , copyright by AlaMiku.
  3.  
  4.  
  5. local NPC_ID = Npc_id
  6. local TOKEN_ID = token_id
  7.  
  8. function Gambler_Gossip(unit, event, plr)
  9. unit:GossipCreateMenu(1, plr, 0)
  10. unit:GossipMenuAddItem(6, "You ready to gamble, "..plr:GetName().."?", 1, 1, "Insert ammount of tokens you want to gamble!")
  11. unit:GossipMenuAddItem(0, "Nevermind", 2, 0)
  12. unit:GossipSendMenu(plr)
  13. end
  14.  
  15. function Gambler_Event(unit, event, plr, id, intid, code)
  16. local chance = math.random(1,5)
  17. if(intid == 1) then
  18. if(plr:GetItemCount(TOKEN_ID) < tonumber(code)) then
  19. plr:SendBroadcastMessage("|cFFFFFF9F"..unit:GetName().." says: You do not have "..code.." tokens!")
  20. else
  21. if(chance == 1) then
  22. plr:SendBroadcastMessage("|cFFFFFF9F"..unit:GetName().." says: Congratulations! You won "..math.ceil(code*1.0).." Tokens!")
  23. plr:AddItem(TOKEN_ID, math.ceil(code*1.0))
  24. else
  25. plr:SendBroadcastMessage("|cFFFFFF9F"..unit:GetName().." says: Too bad "..plr:GetName()..", better luck next time!")
  26. plr:RemoveItem(TOKEN_ID, code)
  27. end
  28. end
  29. end
  30. plr:GossipComplete()
  31. end
  32.  
  33. RegisterUnitGossipEvent(NPC_ID, 1, "Gambler_Gossip")
  34. RegisterUnitGossipEvent(NPC_ID, 2, "Gambler_Event")
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement