local heldTable = {
-- X --
[13348] = {attribute = "heldx", ident = 1}, -- Accuracy 1
[13349] = {attribute = "heldx", ident = 2}, -- Accuracy 2
[13350] = {attribute = "heldx", ident = 3}, -- Accuracy 3
[13351] = {attribute = "heldx", ident = 4}, -- Agility 1
[13352] = {attribute = "heldx", ident = 5}, -- Agility 2
[13353] = {attribute = "heldx", ident = 6}, -- Agility 3
[13354] = {attribute = "heldx", ident = 7}, -- Attack 1
[13355] = {attribute = "heldx", ident = 8}, -- Attack 2
[13356] = {attribute = "heldx", ident = 9}, -- Attack 3
[13357] = {attribute = "heldx", ident = 10}, -- Boost 1
[13358] = {attribute = "heldx", ident = 11}, -- Boost 2
[13359] = {attribute = "heldx", ident = 12}, -- Boost 3
[13360] = {attribute = "heldx", ident = 13}, -- Critical 1
[13361] = {attribute = "heldx", ident = 14}, -- Critical 2
[13362] = {attribute = "heldx", ident = 15}, -- Critical 3
[13363] = {attribute = "heldx", ident = 16}, -- Defense 1
[13364] = {attribute = "heldx", ident = 18}, -- Defense 3
[13365] = {attribute = "heldx", ident = 19}, -- Elemental 1
[13366] = {attribute = "heldx", ident = 20}, -- Elemental 2
[13367] = {attribute = "heldx", ident = 21}, -- Elemental 3
[13368] = {attribute = "heldx", ident = 22}, -- Experience 1
[13369] = {attribute = "heldx", ident = 23}, -- Experience 2 
[13370] = {attribute = "heldx", ident = 24}, -- Experience 3
[13371] = {attribute = "heldx", ident = 25}, -- Harden 1
[13372] = {attribute = "heldx", ident = 26}, -- Harden 2
[13373] = {attribute = "heldx", ident = 27}, -- Harden 3
[13374] = {attribute = "heldx", ident = 28}, -- Haste 1
[13375] = {attribute = "heldx", ident = 29}, -- Haste 2
[13376] = {attribute = "heldx", ident = 30}, -- Haste 3
[13377] = {attribute = "heldx", ident = 31}, -- Hellfire 1
[13378] = {attribute = "heldx", ident = 32}, -- Hellfire 2
[13379] = {attribute = "heldx", ident = 33}, -- Hellfire 3
[13380] = {attribute = "heldx", ident = 34}, -- Lucky 1
[13381] = {attribute = "heldx", ident = 35}, -- Lucky 2
[13382] = {attribute = "heldx", ident = 36}, -- Lucky 3
[13383] = {attribute = "heldx", ident = 37}, -- Poison 1
[13384] = {attribute = "heldx", ident = 38}, -- Poison 2
[13385] = {attribute = "heldx", ident = 39}, -- Poison 3
[13386] = {attribute = "heldx", ident = 40}, -- Rage 1
[13387] = {attribute = "heldx", ident = 41}, -- Rage 2
[13388] = {attribute = "heldx", ident = 42}, -- Rage 3
[13389] = {attribute = "heldx", ident = 43}, -- Return 1
[13390] = {attribute = "heldx", ident = 44}, -- Return 2
[13391] = {attribute = "heldx", ident = 45}, -- Return 3
[13392] = {attribute = "heldx", ident = 46}, -- Strafe 1
[13393] = {attribute = "heldx", ident = 47}, -- Strafe 2
[13394] = {attribute = "heldx", ident = 48}, -- Strafe 3
[13395] = {attribute = "heldx", ident = 49}, -- Vitality 1
[13396] = {attribute = "heldx", ident = 50}, -- Vitality 2
[13397] = {attribute = "heldx", ident = 51}, -- Vitality 3

-- Y -- 
[13398] = {attribute = "heldy", ident = 1}, -- Control 1
[13399] = {attribute = "heldy", ident = 2}, -- Control 2
[13400] = {attribute = "heldy", ident = 3}, -- Control 3
[13401] = {attribute = "heldy", ident = 4}, -- Cure 1
[13402] = {attribute = "heldy", ident = 5}, -- Cure 2
[13403] = {attribute = "heldy", ident = 6}, -- Cure 3
[13404] = {attribute = "heldy", ident = 7}, -- Regeneration 1
[13405] = {attribute = "heldy", ident = 8}, -- Regeneration 2
[13406] = {attribute = "heldy", ident = 9}, -- Regeneration 3
[13407] = {attribute = "heldy", ident = 10}, -- Teleport 1
[13408] = {attribute = "heldy", ident = 11}, -- Teleport 2
[13409] = {attribute = "heldy", ident = 12}, -- Teleport 3
[13410] = {attribute = "heldy", ident = 13}, -- Wing 1
[13411] = {attribute = "heldy", ident = 14}, -- Wing 2
[13412] = {attribute = "heldy", ident = 15}, -- Wing 3
}

function onUse(cid, item, frompos, item2, topos)

local config = {
s = 2256891, -- n mexa
exhau = 10 -- tempo em seegundos para salvar denovo
}

if (getPlayerStorageValue(cid, config.s) <= os.time()) then
setPlayerStorageValue(cid,config.s,os.time()+config.exhau)
doPlayerPopupFYI(cid, "Atencao, se o seu pokemon ja tiver aum held x ou y ele ira perder para adicionar o novo, voce tem 15 segundos para fazer novamente caso tenha certeza.")
else
doPlayerSendCancel(cid, "Você tem que esperar " .. config.exhau .. " segundos para salvar novamente.")
return true
end

if not isPokeball(item2.itemid) or #getCreatureSummons(cid) > 0 then return false end
if not heldTable[item.itemid] then return false end

held = heldTable[item.itemid]
pokename = getItemAttribute(item2.uid, "poke")
heldname = getItemInfo(item.itemid).name

doSetItemAttribute(item2.uid, held.attribute, held.ident)
doRemoveItem(item.uid, 1)
doSendMagicEffect(getThingPos(cid), 14)
sendMsgToPlayer(cid, 27, "Your "..pokename.." has gained a "..heldname..".")
setPlayerStorageValue(cid,config.s,os.time()+config.exhau)
return true
end