local config = {
chance_for_nothing = 50,
required_item = 1444,
winnable_items = {
{2148, 10, "gold coins"},
{2152, 5, "platinum coins"},
{2160, 1, "crystal coin"}
}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerItemCount(cid, 1444) < 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You require 1 xxxxxxxxxx to use the slot machine.")
return true
end
doPlayerRemoveItem(cid, 1444, 1)
local rand = math.random(100)
if rand > config.chance_for_nothing then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Ding ding. Result: Nothing! :C")
return true
end
local reward = config.winnable_items
rand = math.random(#reward)
doPlayerAddItem(cid, reward[rand][1], reward[rand][2], true)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Ding ding. Result: " .. reward[rand][2] .. " " .. reward[rand][3] .. "! :D")
return true
end