local config = {
duration = 5 * 60,
storage = 500,
interval = 200,
}
local function check(cid, pos)
if not isPlayer(cid) or getPlayerStorageValue(cid, config.storage) <= 0 then
return
end
return pos ~= getThingPos(cid) and doCreatureAddHealth(cid, -getCreatureHealth(cid)) or addEvent(check, config.interval, cid, pos)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
--[[
if item.itemid == some_item_id then
-- doSomething()
end
--]]
return addEvent(check, config.interval, cid, getThingPos(cid)), setPlayerStorageValue(cid, config.storage, os.time() + config.duration)
end