function addPokemonToPlayer(cid, pokemon, ball, unique)
if not cid or not isCreature(cid) then return false end
local pokemon = doCorrectString(pokemon)
if not pokes[pokemon] then return false end
local gender = getRandomGenderByName(pokemon)
local btype = (ball and pokeballs[ball]) and ball or "normal"
local happy = 250
if getPlayerFreeCap(cid) >= 6 or not hasSpaceInContainer(getPlayerSlotItem(cid, 3).uid) then
item = doCreateItemEx(11826)
else
item = addItemInFreeBag(getPlayerSlotItem(cid, 3).uid, 11826, 1)
end
if not item then return false end
doItemSetAttribute(item, "poke", pokemon)
doItemSetAttribute(item, "hp", 1)
doItemSetAttribute(item, "happy", happy)
doItemSetAttribute(item, "gender", gender)
doSetItemAttribute(item, "hands", 0)
doItemSetAttribute(item, "description", "Contains a "..pokemon..".")
doItemSetAttribute(item, "fakedesc", "Contains a "..pokemon..".")
if unique then
doItemSetAttribute(item, "unique", getCreatureName(cid))
end
if getPlayerFreeCap(cid) >= 6 or not hasSpaceInContainer(getPlayerSlotItem(cid, 3).uid) then
doPlayerSendMailByName(getCreatureName(cid), item, 1)
end
doTransformItem(item, pokeballs[btype].on)
return true
end
local pokes = {
--[action dos baus] = poke q vai ganhar,
[1111] = "Bulbasaur",
[2222] = "Squirtle",
[3333] = "Charmander",
}
local sto = 587899 --storage dos baus...
function onUse(cid, item, frompos, item2, topos)
local pokemon = pokes[item.actionid]
if not pokemon then return true end
if getPlayerStorageValue(cid, sto) >= 1 then
return doPlayerSendTextMessage(cid, 27, "You already get the pokemon!")
end
setPlayerStorageValue(cid, sto, 1)
addPokemonToPlayer(cid, pokemon, "normal", true)
doPlayerSendTextMessage(cid, 27, "Coungradulations you have received ".. getArticle(pokemon) .." "..pokemon..".")
return true
end