Forgee_XenoBot

Casino tool

Jan 20th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.52 KB | None | 0 0
  1. local bets = {
  2.     {name = "low", multiplier = 0.8, ids = {5792, 5793, 5794}}, -- Dice id for 1,2,3, name  is what you say in channel to choose table.
  3.     {name = "high", multiplier = 0.8, ids = {5795, 5796, 5797}} -- Dice id for 4,5,6
  4. }
  5. -- If you want other bets you can add them as another table in the same format.
  6. -- local bet = {name = "betname", ids = {winning, ids}}
  7. local multiplier = 0.8 -- x * 0.8 = 80% of x (lose 20% even if you win), unless the player can take his bet back himself?
  8. local rewardPos = Self.Position() -- Position to put reward
  9. local platinum = Item.GetID("platinum coin") -- Platinum coin id
  10. local crystal = Item.GetID("crystal coin") -- CC id
  11.  
  12. --[[ You can't touch this.. ooh ahh ohh ]]--
  13. local roll = false
  14. local amount = 0
  15. local reward = 0
  16. local bet = false
  17. local used_id = 0
  18.  
  19. function rollDice(winning_ids)
  20.     local pos = Self.Position()
  21.     used_id = Self.UseItemFromGround(pos.x, pos.y-1, pos.z)
  22.     wait(200,500)
  23.     return table.contains(winning_ids, Map.GetTopUseItem(pos.x, pos.y-1, pos.z).id), used_id
  24. end
  25.  
  26. function giveReward(rate)
  27.     local reward = math.floor(amount * rate)
  28.     local give = {platinum = 0, crystal = 0}
  29.     if reward > 100 then
  30.         give.crystal = math.floor(reward / 100)
  31.         local rest = reward - (give.crystal * 100)
  32.         give.platinum = rest
  33.     else
  34.         give.platinum = reward
  35.     end
  36.     if give.crystal > 0 then
  37.         Self.DropItem(rewardPos.x, rewardPos.y, rewardPos.z, crystal, give.crystal)
  38.     end
  39.     if give.platinum > 0 then
  40.         Self.DropItem(rewardPos.x, rewardPos.y, rewardPos.z, platinum, give.platinum)
  41.     end
  42. end
  43.    
  44. function onSpeak(c, msg)
  45.     c:SendYellowMessage(Self.Name(), msg)
  46.     if msg:lower() == "help" then
  47.         c:SendOrangeMessage("Casino", "Type 'amount bet' to play.\nEx. '50 high'.")
  48.     end
  49.     local betname = msg:match("%a+")
  50.     for k, v in pairs(bets) do
  51.         if betname == v.name then
  52.             bet = v
  53.         end
  54.     end
  55.     if bet then
  56.         if msg:match("%d+") then
  57.             amount = msg:match("%d+")
  58.             amount = tonumber(amount)
  59.             roll, used_id = rollDice(bet.ids)
  60.             sleep(500)
  61.         else
  62.             c:SendOrangeMessage("Casino", "Please specify amount! Ex. '50 high'")
  63.         end
  64.         if roll then
  65.             c:SendOrangeMessage("Casino", "Player win! Commencing reward...")
  66.             giveReward(bet.multiplier)
  67.             roll = false
  68.             bet = false
  69.             reward = 0
  70.             amount = 0
  71.             used_id = 0
  72.         else
  73.             c:SendOrangeMessage("Casino", "Player lost!")
  74.         end
  75.     end
  76. end
  77.  
  78. function onClose(c, msg) end
  79.  
  80. local c = Channel.Open("Casino", onSpeak, onClose)
  81. c:SendOrangeMessage("Casino", "Powered by Forgee. Type ex. 50 high to bet 50 platinum on high.")
Advertisement
Add Comment
Please, Sign In to add comment