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