Desatenção minha,
use este:
function doHealOverTime(cid, div, turn, effect)
if not isCreature(cid) then return true end
if turn <= 0 then return true end
if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return true end
local d = div / 10000
local amount = math.floor(getCreatureMaxHealth(cid) * d)
doCreatureAddHealth(cid, amount)
if math.floor(turn/10) == turn/10 then
doSendMagicEffect(getThingPos(cid), effect)
end
addEvent(doHealOverTime, 100, cid, div, turn - 1, effect)
end
local potions = {
[12346] = {effect = 12, div = 20},
[12347] = {effect = 13, div = 40},
[12348] = {effect = 13, div = 60},
[12345] = {effect = 14, div = 80},
[12343] = {effect = 12, div = 100}}
function onUse(cid, item, frompos, item2, topos)
if isPlayer(item2.uid) then
return doPlayerSendCancel(cid, "You can only use potions on pokemons!")
end
if not isCreature(item2.uid) then
return doPlayerSendCancel(cid, "You can only use potions on pokemons!")
end
if not isPlayer(getCreatureMaster(item2.uid)) then
return doPlayerSendCancel(cid, "You cant use potions on wild pokemons.")
end
if getCreatureHealth(item2.uid) == getCreatureMaxHealth(item2.uid) then
return doPlayerSendCancel(cid, "This pokemon is already at full health.")
end
doCreatureSay(cid, ""..getPlayerStorageValue(item2.uid, 1007)..", take this potion!", TALKTYPE_SAY)
doSendMagicEffect(getThingPos(item2.uid), 172)
doRemoveItem(item.uid, 1)
local a = potions[item.itemid]
doHealOverTime(item2.uid, a.div, 100, a.effect)
return true
end