Advertisement
Guest User

Untitled

a guest
May 16th, 2013
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.85 KB | None | 0 0
  1. local NPC_ID = 44007
  2. local multi = 2
  3.  
  4. function Gambler_Gossip(event, plr, unit)
  5.         plr:GossipMenuAddItem(6, "You ready to gamble, "..plr:GetName().."?", 0, 1, true, "Insert amount of gold you want to gamble with!")
  6.         plr:GossipMenuAddItem(0, "Nevermind", 0, 2)
  7.         plr:GossipSendMenu(1, unit)
  8. end
  9.  
  10. function Gambler_Event(event, plr, unit, sender, intid, code)
  11.         local chance = math.random(1,2) -- This'll give you a 50% chance to win. 1/2 = 50%  1/3 = 33%  1/4 = 25%  1/5 = 20%
  12.         if(intid == 1) then
  13.                 if (tonumber(code)) then -- Check if player actually specified an amount in numbers
  14.                         if(plr:GetCoinage() < tonumber(code*10000)) then
  15.                                 plr:SendBroadcastMessage("|cFFFFFF9F"..unit:GetName().." says: You do not have "..tonumber(code).." gold!")
  16.                         else
  17.                                 if(chance == 1) then
  18.                                         plr:SendBroadcastMessage("|cFFFFFF9F"..unit:GetName().." says: Congratulations! You won "..math.ceil(code*multi).." gold!")
  19.                                         gold = (math.ceil(tonumber(code*10000)*multi))
  20.                                         plr:GiveCoinage(gold)
  21.                                 else
  22.                                         plr:SendBroadcastMessage("|cFFFFFF9F"..unit:GetName().." says: Too bad "..plr:GetName()..", better luck next time!")
  23.                                         plr:RemoveCoinage(tonumber(code*10000))
  24.                                 end
  25.                         end
  26.                 else
  27.                         plr:SendBroadcastMessage("|cFFFFFF9F"..unit:GetName().." says: You need to use numbers, not letters.")
  28.                 end
  29.         end
  30.         plr:GossipComplete()
  31. end
  32.  
  33. RegisterCreatureGossipEvent(NPC_ID, 1, Gambler_Gossip)
  34. RegisterCreatureGossipEvent(NPC_ID, 2, Gambler_Event)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement