function onUse(cid, item, frompos, item2, topos)
-- https://otland.net/members/xikini.102396/
-- https://otland.net/threads/casino-slotmachines-of-winning-or-loose.232794/#post-2245827
local cost_per_click = 30000 -- Amount in gold coins. 30,000 = 3 cc. Set to 0 if you want no money to be taken.
local item_per_click = 150 -- Amount of items needed to use lever. Set to 0 in you want no item to be used.
local item_currency = 6500 -- Item needed to use lever. Set as Demonic Essences currently.
local item_name = "demonic essence" -- name of item_currency
local chance_to_win = 30 -- Percent 30/100
local casino_machine = 00000000 -- ItemID of casino machine
local exhaust_time = 5 -- 5 seconds (how long before a player can use the machine again) (note:Gm/cm/god is not affected by exhaustion)
local winner_effect = 30 -- Animation sent at players location when you win
local ids = { -- THIS IS WHERE YOU PUT ALL ITEMS YOU WANT FOR PRIZES
[1] = {item_name = "demon armor", itemID = 2494, amount = 1},
[2] = {item_name = "aaaaaaaaaaaa", itemID = 1111111111, amount = 1},
[3] = {item_name = "aaaaaaaaaaaa", itemID = 1111111111, amount = 1},
[4] = {item_name = "aaaaaaaaaaaa", itemID = 1111111111, amount = 1},
[5] = {item_name = "aaaaaaaaaaaa", itemID = 1111111111, amount = 1} -- LAST LINE MUST NEVER HAVE A " , "
}
-- Don't edit below unless your sure you know what to do. :P
local exstorage = 45001
local pos = getCreaturePosition(cid)
local player_gold = getPlayerItemCount(cid,2148)
local player_plat = getPlayerItemCount(cid,2152)*100
local player_crys = getPlayerItemCount(cid,2160)*10000
local player_money = player_gold + player_plat + player_crys
if exhaustion.check(cid, exstorage) then
return doPlayerSendCancel(cid, "Please wait a few seconds before using the casino again.")
end
if item.itemid == casino_machine then
if player_money >= cost_per_click then
if getPlayerItemCount(cid,item_currency) >= item_per_click then
doPlayerRemoveMoney(cid, cost_per_click)
doPlayerRemoveItem(cid, item_currency, item_per_click)
if(math.random(1, 100) <= chance_to_win) then
local rand = ids[math.random(#ids)]
local item = doPlayerAddItem(cid, rand.itemID, rand.amount)
if rand.amount <= 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Winner! You receive ".. rand.amount .." ".. rand.item_name ..".")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Winner! You receive ".. rand.amount .." ".. rand.item_name .."s.")
end
doSendMagicEffect(pos, winner_effect)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Sorry, no luck!")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You require ".. item_per_click .." ".. item_name .." to use the lottery machine.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You require ".. cost_per_click .." gold coins to use the lottery machine.")
end
else
return doPlayerSendCancel(cid, "This is the incorrect item for this script! Check casino_machine ID.")
end
exhaustion.set(cid, exstorage, exhaust_time)
return true
end