Hi, i tried to make casino machine with my own sprites but something goes wrong. I do 3 math.random
first is "CASINO_WIN" - id of winning color sprites
and second is "CASINO_LOSS" - you know
and third is a main random (win/loss)
but even if i loss script make a winning sprites in that pos. or if i win then make losing sprites. How to fix?
first is "CASINO_WIN" - id of winning color sprites
and second is "CASINO_LOSS" - you know
and third is a main random (win/loss)
but even if i loss script make a winning sprites in that pos. or if i win then make losing sprites. How to fix?
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local CASINO1 = 11366
local storage = 50002
local wait = 1.0
local CASINO_WIN = {11367, 11368, 11369, 11370} --- winning sprites
local CASINO_LOSS = {11371, 11372, 11373, 11374, 11375, 11404} --- losing sprites
local WINS = math.random(1, #CASINO_WIN)
local LOSES = math.random(1, #CASINO_LOSS)
local machine = {x=1919, y=696, z=8}
local roll = math.random(1, 10)
if item.itemid == CASINO1 and exhaustion.get(cid, storage) == FALSE and getPlayerItemCount(cid, 2152) >= 10 and (roll <=2) then
doPlayerRemoveItem(cid, 2152, 10)
doSendMagicEffect(machine, 188)
doCreateItem(CASINO_WIN[WINS],1,machine)
doPlayerAddItem(cid, 2152, 50)
doSendAnimatedText(fromPosition, "+$", TEXTCOLOR_GREEN)
exhaustion.set(cid, storage, wait)
elseif item.itemid == CASINO1 and exhaustion.get(cid, storage) == FALSE and getPlayerItemCount(cid, 2152) >= 10 and (roll >=3) then
doPlayerRemoveItem(cid, 2152, 10)
doSendMagicEffect(machine, 188)
doCreateItem(CASINO_LOSS[LOSES],1,machine)
doSendAnimatedText(fromPosition, "-$", TEXTCOLOR_RED)
exhaustion.set(cid, storage, wait)
elseif item.itemid == CASINO1 and exhaustion.get(cid, storage) == FALSE and getPlayerItemCount(cid, 2152) < 10 then
doPlayerSendCancel(cid, "You don\'t have enough money to play.")
exhaustion.set(cid, storage, wait)
elseif item.itemid == CASINO1 and exhaustion.get(cid, storage) == TRUE then
doPlayerSendCancel(cid, "The machine is running.")
end
return TRUE
end