local cPos = {x = xxx, y = xxx, z = x}
local STORE_VALUE = 3567 -- Value where exhaust is saved.
local EXHAUST_TIME = 1 -- Exhaust time in seconds.
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.uid == xxx and item.itemid == 1945 then
doSummonCreature("Monster", cPos)
end
end
function exhaust(cid, STORE_VALUE, EXHAUST_TIME)
newExhaust = os.time()
oldExhaust = getPlayerStorageValue(cid, STORE_VALUE)
if (oldExhaust == nil or oldExhaust < 0) then
oldExhaust = 0
end
if (EXHAUST_TIME == nil or EXHAUST_TIME < 0) then
EXHAUST_TIME = 1
end
diffTime = os.difftime(newExhaust, oldExhaust)
if (diffTime >= EXHAUST_TIME) then
setPlayerStorageValue(cid, STORE_VALUE, newExhaust)
return 1
else
return 0
end
end
Don't work. I use swich and don't summon monster.
local cPos = {x = xxx, y = xxx, z = x}
local exhaust,storage = 5, 1299 -- in seconds,empty storage
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid,storage) > os.time() then
doPlayerSendTextMessage(cid,27,os.date("You are exhausted, you need to wait more %S seconds.",getPlayerStorageValue(cid,storage) - os.time()) )
return true
end
if item.uid == xxx and item.itemid == 1945 then
doSummonCreature("Monster", cPos)
setPlayerStorageValue(cid,storage,os.time() + exhaust)
end
return true
end