Why sometimes works and sometimes does not?
I want to to work every 2 seconds.
Code:
function onThink(cid, interval)
if last_interval == nil then
last_interval = os.clock()
end
if (os.clock() - last_interval) > 2 then -- execute every 2 sec
if getPlayerStorageValue(cid, eSkill.charm) >= 1 then
doCreatureAddHealth(cid, getPlayerStorageValue(cid, eSkill.charm))
doCreatureAddMana(cid, getPlayerStorageValue(cid, eSkill.charm))
end
last_interval= os.clock()
return true
end
return false
end
I want to to work every 2 seconds.