Troque o código por esse:
local function HealHealthPercent(cid, percent, effect)
if not cid then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.")
return true
end
percent = percent / 100
doCreatureAddHealth(cid, percent > 0 and math.floor(percent * getCreatureHealth(cid)) or 1)
doSendMagicEffect(getThingPos(cid), effect)
doCreatureSay(cid, "Heal")
end
--- TABELA COM O ID DAS POTIONS, TANTO DE PORCENTAGEM QUE CURA BASEADO NA VIDA E EFEITO AO USAR A POÇÃO ---
local potions = {
[12347] = {percent = 25, effect = 13}, -- full restore
[12348] = {percent = 50, effect = 13}, -- hyper potion
[12346] = {percent = 75, effect = 13}, -- ultra potion
[12345] = {percent = 100, effect = 13}, -- super potion
}
local storage = 47898 -- STORAGE PARA USAR NOVAMENTE A POTION APÓS O TEMPO DO VALOR DA VARIÁVEL MINUTOS
local minutos = 3 -- MINUTOS PARA USAR A POTION NOVAMENTE
---------------------------- CÓDIGO --------------------------------
function onUse(cid, item, toPos, itemEx, FromPos)
if getPlayerStorageValue(cid, storage) <= os.time() then
local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON)
if not pokemon then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.")
return true
end
if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.")
return doPlayerSendCancel(cid, "You can use potion only in your pokémon.")
end
if getCreatureHealth(pokemon) == getCreatureMaxHealth(pokemon) then
return doPlayerSendCancel(cid, "The health of your pokémon already is full.")
end
if getPlayerStorageValue(cid, 52481) >= 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.")
return doPlayerSendCancel(cid, "You can't do that while a duel.")
end
if getPlayerStorageValue(cid, 990) >= 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.")
return doPlayerSendCancel(cid, "You can't use potion during gym battles.")
end
HealHealthPercent(pokemon, potions[item.itemid].percent, potions[item.itemid].effect)
doRemoveItem(item.uid, 1)
setPlayerStorageValue(cid, storage, os.time() + (60 * minutos))
return true
else
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to wait " .. minutos .. " minutes to use the potion again.")
end
end
Criei uma variável minutos para poder definir outro valor caso queira mudar futuramente, mas deixei 3 por padrão.