Thorn
Spriting since 2013
Hello guys, i had this awesome cassino script, i dont know really how i got it, i think here in otland years ago, it's for tfs 0.4, i think it works great for that version, altho now im using tfs 1.2 and i was wondering if any of you guys would do me the favor to convert it into tfs 1.x
plz!!
plz!!
Code:
function onUse(cid, item, frompos, item2, topos)
local pos = getCreaturePosition(cid)
local cost_per_click = 500000 -- Amount in gold coins. 30,000 = 3 cc. Set to 0 if you want no money to be taken.
local item_per_click = 0 -- Amount of items needed to use lever. Set to 0 in you want no item to be used.
local item_currency = 0 -- Item needed to use lever. Set as Demonic Essences currently.
local item_name = "demonic essence"
local chance_to_win = 30 -- Percent 30/100
local casino_machine = 21720
local ids = { -- THIS IS WHERE YOU PUT ALL ITEMS YOU WANT FOR PRIZES
[1] = {item_name = "Overflow energy ring", itemID = 30442, amount = 1},
[2] = {item_name = "Overmind knight ring", itemID = 30438, amount = 1},
[3] = {item_name = "Overmind mage ring", itemID = 30439, amount = 1}
}
-- Don't edit below unless your sure you know what to do. :P
local exstorage = 45001
local player_gold = getPlayerItemCount(cid,2148)
local player_plat = getPlayerItemCount(cid,2152)*100
local player_crys = getPlayerItemCount(cid,2160)*10000
local player_blood = getPlayerItemCount(cid,21667)*1000000
local player_ultimate = getPlayerItemCount(cid,23912)*100000000
local player_money = player_gold + player_plat + player_crys + player_blood + player_ultimate
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
doSendMagicEffect(pos, 30)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Winner! You receive ".. rand.amount .." ".. rand.item_name ..".")
else
doSendMagicEffect(pos, 30)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Winner! You receive ".. rand.amount .." ".. rand.item_name .."s.")
end
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, 1)
return true
end