function onUse(cid, item, frompos, item2, topos)
if not getTileInfo(getThingPos(cid)).protection then
return doPlayerSendCancel(cid, "You can only use this item in protection zone.")
end
setPlayerStorageValue(cid, 8422, 0)
setPlayerStorageValue(cid, 23254, 50)
--doPlayerRemoveItem(cid, 7855, 1)
if isCreature(item2.uid) then
return doPlayerSendCancel(cid, "You can only use revive in pokeballs!")
end
if isPlayer(item2.uid) then
return doPlayerSendCancel(cid, "You cant use potions on wild pokemons.")
end
local x = pokeballs[getPokeballType(item2.itemid)]
if not x or isInArray(x.use, item2.itemid) then return doPlayerSendCancel(cid, "Sorry, is not possible.") end
if x.on or x.off then
doSendMagicEffect(getThingPos(cid), 14)
doRemoveItem(item.uid, 1)
maxh = tonumber(getItemAttribute(item2.uid, "poke"):match("/(.+)]"))
doItemSetAttribute(item2.uid, "poke", getItemAttribute(item2.uid, "poke"):sub(1, findLetter(getItemAttribute(item2.uid, "poke"), "[")) .. maxh .. getItemAttribute(item2.uid, "poke"):sub(findLetter(getItemAttribute(item2.uid, "poke"), "/")))
btype = getPokeballType(item2.itemid)
ons = pokeballs[btype].on
doTransformItem(item2.uid, ons)
doCureAllStatus(item2.uid)
else
doPlayerSendCancel(cid, "Sorry, is not possible.")
return true
end
end