local c = {
['energy ring'] = { itemid = 2167, amount = 1, time_ = 60 * 1000 * 5, storage = 21670, con = CONDITION_MANASHIELD}
}
local condition = createConditionObject(c.['energy ring'].con)
setConditionParam(condition, CONDITION_PARAM_TICKS, c.['energy ring'].time_)
function onThink(cid, interval)
if(not isCreature(cid)) then
return
end
local storage = getPlayerStorageValue(cid, c.['energy ring'].storage)
if getPlayerItemCount(cid, c.['energy ring'].itemid) >= c.['energy ring'].amount then
if storage < 1 then
setPlayerStorageValue(cid, c.['energy ring'].storage, c.['energy ring'].time_ + os.time())
doAddCondition(cid, condition)
elseif storage < os.time() then
setPlayerStorageValue(cid, c.['energy ring'].storage, -1)
if hasCondition(cid, c.['energy ring'].con) then
doRemoveCondition(cid, c.['energy ring'].con)
end
doRemoveItem(c.['energy ring'].itemid, 1)
end
else
if hasCondition(cid, c.['energy ring'].con) then
doRemoveCondition(cid, c.['energy ring'].con)
end
end
return true
end