Sir Islam
Never Give Up
i need rune make 30 % chance to on or fail to take this Storage xxxx
and when on player say on when fail player say fail
reb ++
and when on player say on when fail player say fail
reb ++
local config = {storage = 123, chance = 30}
function onUse(cid, item, frompos, item2, topos)
if isPlayer(item2.uid) then
if getPlayerStorageValue(item2.uid, config.storage) == 1 then
doPlayerSendCancel(cid, "This player is already on.")
elseif math.random(1, 100) <= config.chance then
setPlayerStorageValue(item2.uid, config.storage, 1)
doSendAnimatedText(topos, "On!", COLOR_GREEN)
else
doSendAnimatedText(topos, "Fail!", COLOR_RED)
end
else
doPlayerSendCancel(cid, "You must use it on a player.")
end
return true
end
local config = {storages = {[1]=123,[2]=124}, chance = 30, time = os.time()}
function onUse(cid, item, frompos, item2, topos)
if getPlayerStorageValue(cid, config.storages[1]) == 1 then
doPlayerSendCancel(cid, "You're already on.")
elseif math.random(1, 100) <= config.chance then
setPlayerStorageValue(cid, config.storages[1], 1)
setPlayerStorageValue(cid, config.storages[2], time + 60)
doSendAnimatedText(topos, "On!", COLOR_GREEN)
addEvent(function()
if cid and isCreature(cid) then
setPlayerStorageValue(cid, config.storages[1], -1)
end
end, 60 * 1000)
else
doSendAnimatedText(topos, "Fail!", COLOR_RED)
end
doRemoveItem(item.uid, 1) -- <-- if it doesnt work, try doChangeTypeItem(item.uid, item.type - 1)
return true
end
-----------------------------------------------------------------------------
local config = {storages = {[1]=123,[2]=124}, time = os.time()}
function onLogin(cid)
if getPlayerStorageValue(cid, config.storages[2]) - time <= 0 then
setPlayerStorageValue(cid, config.storages[1], -1)
end
return true
end