Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local bets = {
- {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.
- {name = "high", multiplier = 0.8, ids = {5795, 5796, 5797}} -- Dice id for 4,5,6
- }
- -- If you want other bets you can add them as another table in the same format.
- -- local bet = {name = "betname", ids = {winning, ids}}
- 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?
- local rewardPos = Self.Position() -- Position to put reward
- local platinum = Item.GetID("platinum coin") -- Platinum coin id
- local crystal = Item.GetID("crystal coin") -- CC id
- --[[ You can't touch this.. ooh ahh ohh ]]--
- local roll = false
- local amount = 0
- local reward = 0
- local bet = false
- local used_id = 0
- function rollDice(winning_ids)
- local pos = Self.Position()
- used_id = Self.UseItemFromGround(pos.x, pos.y-1, pos.z)
- wait(200,500)
- return table.contains(winning_ids, Map.GetTopUseItem(pos.x, pos.y-1, pos.z).id), used_id
- end
- function giveReward(rate)
- local reward = math.floor(amount * rate)
- local give = {platinum = 0, crystal = 0}
- if reward > 100 then
- give.crystal = math.floor(reward / 100)
- local rest = reward - (give.crystal * 100)
- give.platinum = rest
- else
- give.platinum = reward
- end
- if give.crystal > 0 then
- Self.DropItem(rewardPos.x, rewardPos.y, rewardPos.z, crystal, give.crystal)
- end
- if give.platinum > 0 then
- Self.DropItem(rewardPos.x, rewardPos.y, rewardPos.z, platinum, give.platinum)
- end
- end
- function onSpeak(c, msg)
- c:SendYellowMessage(Self.Name(), msg)
- if msg:lower() == "help" then
- c:SendOrangeMessage("Casino", "Type 'amount bet' to play.\nEx. '50 high'.")
- end
- local betname = msg:match("%a+")
- for k, v in pairs(bets) do
- if betname == v.name then
- bet = v
- end
- end
- if bet then
- if msg:match("%d+") then
- amount = msg:match("%d+")
- amount = tonumber(amount)
- roll, used_id = rollDice(bet.ids)
- sleep(500)
- else
- c:SendOrangeMessage("Casino", "Please specify amount! Ex. '50 high'")
- end
- if roll then
- c:SendOrangeMessage("Casino", "Player win! Commencing reward...")
- giveReward(bet.multiplier)
- roll = false
- bet = false
- reward = 0
- amount = 0
- used_id = 0
- else
- c:SendOrangeMessage("Casino", "Player lost!")
- end
- end
- end
- function onClose(c, msg) end
- local c = Channel.Open("Casino", onSpeak, onClose)
- 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