function onUse(cid, item, fromPosition, itemEx, toPosition)
function getPokemonMaxLife(name)
local file = io.open('data/monster/monsters.xml','r')
local arquivo = file:read(-1):lower():match('')
file:close()
local data = io.open('data/monster/'..(arquivo or ''),'r')
if not data then
return 100
end
local maximo = data:read(-1):match('max%s*=%s*"(%d+)"')
data:close()
return maximo
end
----- Config -----
local MaximoSummon = 1
local nome1 = getItemName(item.uid)
local nome = nome1:match('(.-) Pokeball')
local summons = getCreatureSummons(cid)
local action_id = getItemAttribute(item.uid, "aid")
------ Config -----
local summons = getCreatureSummons(cid)
if item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_AMMO).uid then
doPlayerSendCancel(cid, "Coloque no slot certo!.")
return TRUE
end
if getTilePzInfo(getCreaturePosition(cid)) then
return doPlayerSendCancel(cid, "You can't use pokeball in Protection Zones.")
end
if getItemAttribute(item.uid,"level") >= getPlayerLevel(cid) then
doPlayerSendCancel(cid, "You dont have level to use.")
return TRUE
end
if(table.maxn(summons) < MaximoSummon) then -- no summons
creature = doSummonCreature(nome, getCreaturePosition(cid))
doConvinceCreature(cid, creature)
local hp = getCreatureHealth(getCreatureSummons(cid)[1])
doItemSetAttribute(item.uid, "aid", hp)
doPlayerSay(cid, "Go,"..nome.."", TALKTYPE_SAY)
registerCreatureEvent(cid, "PlayerPokeDeath")
registerCreatureEvent(creature, "DiePoke")
doSendMagicEffect(getCreaturePosition(creature), 188)
doTransformItem(getPlayerSlotItem(cid,8).uid, 2532, 1)
doItemSetAttribute(item.uid,"name",""..nome.." Pokeball")
if action_id ~= 0 then
doCreatureAddHealth(creature, -(tonumber(getPokemonMaxLife(nome) - action_id)))
else
doCreatureAddHealth(creature, getPokemonMaxLife(nome))
end
else
for _, pid in ipairs(summons) do
if (table.maxn(summons) >= 1) then
doItemSetAttribute(item.uid, "aid", getCreatureHealth(summons[1]))
doSendMagicEffect(getCreaturePosition(creature), 188)
doPlayerSay(cid, "Back,"..nome.."", TALKTYPE_SAY)
doRemoveCreature(pid)
doTransformItem(item.uid, 2532, 1)
doItemSetAttribute(item.uid,"name", nome .." Pokeball")
end
end
end
return true
end
acho que agora n da mais o erro, OBS eu n testei caso n funcione avise no tópico