local itemID = 2273
local maglv = 3
-- potions exausted
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
function onGetFormulaValues(cid)
local min = ( (((getPlayerMagLevel(cid)) * 100) * 0.5 ) + (40)) * -1
local max = ( (((getPlayerMagLevel(cid)) * 100) * 1.0 ) + (40)) * -1
local value = math.random(min, max)
return value
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local target = cid
-- 1 how to check if rune was used in a real player? i mean, not only cid, others players/monsters
if target == 0 then
doPlayerSendCancel(cid, "You need to have a target to use this rune.")
return true
end
-- 2 why exausted is not working?
if(os.time() - getPlayerStorageValue(cid, spellcfg_actions_exausted_storage)) < spellcfg_actions_exausted_secs then
doPlayerSendCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return true
end
if getPlayerMagLevel(cid) < maglv then
doPlayerSendCancel(cid, "You do not have enought magic level.")
return true
end
doSendMagicEffect(getThingPos(target), CONST_ME_MAGIC_BLUE)
local dmg = onGetFormulaValues(cid)
doCreatureAddHealth(cid, dmg)
setPlayerStorageValue(cid, spellcfg_actions_exausted_storage, os.time())
doRemoveItem(item.uid, 1) -- 3 why the item is not removing?
return TRUE
end