• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[CLIENT POKEMON] CD bar crashes the client

poinferno

Member
Joined
Jan 7, 2015
Messages
45
Reaction score
7
Hi, i'm running a pokemon server and would like to implement a cd bar because lots of players really want it.
I'm not really having any luck since the client crashes when i use my pokeball and after that, it crashes every time I login.
The report is as follows:
Naamloos.png
Scripting is my business but i'm still not quite familiar with the client :/
Could somebody please explain to me whats wrong and if possible give me a solution?
thank you for your time! ^^

----------------EDIT-------------------
i found that the problem is somewhere around here:

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

    if exhaustion.get(cid, 6666) and exhaustion.get(cid, 6666) > 0 then return true end

    local owner = getItemAttribute(item.uid, "firstpoke")

    if owner and owner ~= getCreatureName(cid) then
        doPlayerSendCancel(cid, "This pokemon belongs to "..owner..", it is his first pokemon. Please, give it back to him.")
    return true
    end

if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) >= 1 or getPlayerStorageValue(cid, 63215) >= 1 then
return true
end

local btype = getPokeballType(item.itemid)

local effect = pokeballs[btype].effect
    if not effect then
        effect = 21
    end

if item.itemid == pokeballs[btype].use then

    if getPlayerStorageValue(cid, 990) == 1 then -- GYM
        doPlayerSendCancel(cid, "You can't return your pokemon during gym battles.")
    return true
    end

    if #getCreatureSummons(cid) <= 0 then
        if isInArray(pokeballs[btype].all, item.itemid) then
            doTransformItem(item.uid, pokeballs[btype].off)
            doItemSetAttribute(item.uid, "hp", 0)
            doPlayerSendCancel(cid, "This pokemon is fainted.")
        return true
        end
    end

    local z = getCreatureSummons(cid)[1]

    if getCreatureCondition(z, CONDITION_INVISIBLE) and not isGhostPokemon(z) then
    return true
    end

    doReturnPokemon(cid, z, item, effect)

elseif item.itemid == pokeballs[btype].on then

    if item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_FEET).uid then
        doPlayerSendCancel(cid, "You must put your pokeball in the correct place!")
    return TRUE
    end

    local thishp = getItemAttribute(item.uid, "hp")

    if thishp <= 0 then
        if isInArray(pokeballs[btype].all, item.itemid) then
            doTransformItem(item.uid, pokeballs[btype].off)
            doItemSetAttribute(item.uid, "hp", 0)
            doPlayerSendCancel(cid, "This pokemon is fainted.")
        return true
        end
    end
   
    local pokemon = getItemAttribute(item.uid, "poke")
   
    local mypoke = getPokemonStatus(pokemon)
    if not mypoke then return true end
    local speed = getCreatureSpeed(cid) / 3
    doItemSetAttribute(item.uid, "speed", speed)
       

    if not pokes[pokemon] then
    return true
    end

    local x = pokes[pokemon]
   

    if getPlayerLevel(cid) + pokemonMaxLevelAbovePlayer < getItemAttribute(item.uid, "level") then
        doPlayerSendCancel(cid, "Your pokemon's level is much higher than yours, you can't use him.")
        return true
        end

    doSummonMonster(cid, pokemon)
   
    local pk = getCreatureSummons(cid)[1]
    if not isCreature(pk) then return true end
    ------------------------passiva hitmonchan------------------------------
    if isSummon(pk) then
       --local e = getCreatureMaster(cid)
       local nameHIT = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "poke")
       local hands = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "hands")
       if nameHIT == "Shiny Hitmonchan" or nameHIT == "Hitmonchan" then
          if getItemAttribute(getPlayerSlotItem(cid, 8).uid, "hands") then
             doSetCreatureOutfit(pk, {lookType = hitmonchans[nameHIT][hands].out}, -1)
          else
              doPlayerSendTextMessage(cid, 27, "Contact a GameMaster! Error in passive system! Attribute \"hands\" missing") 
          end
       end
    end
    -------------------------------------------------------------------------     

    if getCreatureName(pk) == "Ditto" then

        local left = getItemAttribute(item.uid, "transLeft")
        local name = getItemAttribute(item.uid, "transName")

        if left and left > 0 then
            setPlayerStorageValue(pk, 1010, name)
            doSetCreatureOutfit(pk, {lookType = getItemAttribute(item.uid, "transOutfit")}, -1)
            addEvent(deTransform, left * 1000, pk, getItemAttribute(item.uid, "transTurn"))
            doItemSetAttribute(item.uid, "transBegin", os.clock())
        else
            setPlayerStorageValue(pk, 1010, "Ditto")
        end
    end

    if isGhostPokemon(pk) then doTeleportThing(pk, getPosByDir(getThingPos(cid), math.random(0, 7)), false) end

    doCreatureSetLookDir(pk, 2)

    adjustStatus(pk, item.uid, true, false, true)
    doAddPokemonInOwnList(cid, pokemon)

    doTransformItem(item.uid, item.itemid+1)

    local pokename = getItemAttribute(item.uid, "nick") or getCreatureName(pk)

    local mgo = gobackmsgs[math.random(1, #gobackmsgs)].go:gsub("doka", pokename)
    doCreatureSay(cid, mgo, TALKTYPE_SAY)

    doSendMagicEffect(getCreaturePosition(pk), effect)

local pk = getCreatureSummons(cid)[1]
        local pb = getPlayerSlotItem(cid, 8).uid
        local look = getItemAttribute(pb,"addon")
        if not look then
                doSetItemAttribute(pb,"addon",0)
        return false
        end
        if look > 0 then
                doSetCreatureOutfit(pk, {lookType = look}, -1)
        return true
        end

else

    doPlayerSendCancel(cid, "This pokemon is fainted.")

end

    if useKpdoDlls then
        doUpdateMoves(cid)
    end
return true
end
 
Last edited:
Code:
function getPlayerPokeballs(cid)
local ret = {}
local container = 0
if isCreature(cid) then
container = getPlayerSlotItem(cid, 3).uid
local myball = getPlayerSlotItem(cid, 8)
if myball.uid > 0 then
table.insert(ret, myball)
end
else
container = cid
end
if isContainer(container) and getContainerSize(container) > 0 then
for slot = 0, (getContainerSize(container) - 1) do
local item = getContainerItem(container, slot)
if isContainer(item.uid) then
local itemsbag = getPlayerPokeballs(item.uid)
if itemsbag and #itemsbag > 0 then
for i = 0, #itemsbag do
table.insert(ret, itemsbag[i])
end
end
elseif isPokeball(item.itemid) then
table.insert(ret, item)
end
end
end
return ret
end
function doUpdatePokemonsBar(cid)
local ret = "p#,"
local balls = getPlayerPokeballs(cid)
local times = 0
for a = 1, #balls do
local item = balls[a]
local hp = math.ceil(getItemAttribute(item.uid, "hp") * 100)
local name = getItemAttribute(item.uid, "poke")
local port = getPlayerSlotItem(cid, CONST_SLOT_LEGS)
if fotos[name] >= 100 and fotos[name] <= 11387 then
times = times + 1
local foto = fotos[name] - 911
doItemSetAttribute(item.uid, "ballorder", times)
ret = ret..""..foto..","..name..""..times..","..hp..","
else
times = times + 1
local foto = fotos[name] - 928
doItemSetAttribute(item.uid, "ballorder", times)
ret = ret..""..foto..","..name..""..times..","..hp..","
end
end
doPlayerSendCancel(cid, ret)
end
function getNewMoveTable(table, n)
if not(table) then return true end
if n == 1 and table.move1 then
return table.move1
elseif n == 2 and table.move2 then
return table.move2
elseif n == 3 and table.move3 then
return table.move3
elseif n == 4 and table.move4 then
return table.move4
elseif n == 5 and table.move5 then
return table.move5
elseif n == 6 and table.move6 then
return table.move6
elseif n == 7 and table.move7 then
return table.move7
elseif n == 8 and table.move8 then
return table.move8
elseif n == 9 and table.move9 then
return table.move9
elseif n == 10 and table.move10 then
return table.move10
elseif n == 11 and table.move11 then
return table.move11
elseif n == 12 and table.move12 then
return table.move12
else
return false
end
end
function doUpdateMoves(cid)
local summon = getCreatureSummons(cid)[1]
local ret = "12&,"
if not summon then
for a = 1, 12 do
ret = ret.."n/n,"
end
doPlayerSendCancel(cid, ret)
addEvent(doUpdateCooldowns, 100, cid)
return true
end
local ret = "12&,"
local moves = movestable[getCreatureName(summon)]
for a = 1, 12 do
local b = getNewMoveTable(moves, a)
if b then
ret = ret..""..b.name..","
else
ret = ret.."n/n,"
end
end
doPlayerSendCancel(cid, ret)
addEvent(doUpdateCooldowns, 100, cid)
end
function doUpdateCooldowns(cid)
local a = getPlayerSlotItem(cid, 8)
local ret = "12|,"
if a.uid <= 0 or #getCreatureSummons(cid) <= 0 then
   for cds = 1, 12 do
       ret = ret.."-1,"
   end
   doPlayerSendCancel(cid, ret)
return true
end
for cds = 1, 12 do
    local summon = getCreatureSummons(cid)[1]
    if summon and getPlayerStorageValue(summon, 212123) >= 1 then
       cdzin = "cm_move"..cds
    else                       --alterado v2.5
       cdzin = "move"..cds
    end
    if getCD(a.uid, cdzin) > 0 then
       ret = ret..""..(getCD(a.uid, cdzin) - 1)..","
    else
       ret = ret.."0,"
    end
end
doPlayerSendCancel(cid, ret)
end
function getBallsAttributes(item)
local t = {"boffense", "bdefense", "bagility", "bsattack", "offense", "defense", "speed", "level", "specialattack", "poke", "gender", "vitality", "nick",
"boost", "happy", "hunger", "hp", "description", "exp", "nextlevelexp", "transBegin", "transLeft", "transTurn", "transOutfit", "transName", "trans",
"light", "blink", "move1", "move2", "move3", "move4", "move5", "move6", "move7", "move8", "move9", "move10", "move11", "move12", "ballorder", "firstpoke",
"hands", "aura", "burn", "burndmg", "poison", "poisondmg", "confuse", "sleep", "miss", "missSpell", "missEff", "fear", "fearSkill", "silence",
"silenceEff", "stun", "stunEff", "stunSpell", "paralyze", "paralyzeEff", "slow", "slowEff", "leech", "leechdmg", "Buff1", "Buff2", "Buff3", "Buff1skill",
"Buff2skill", "Buff3skill", "control"}                           --alterado v2.5
local ret = {}
for a = 1, #t do
if getItemAttribute(item, t[a]) == "hands" then
return
end
ret[t[a]] = getItemAttribute(item, t[a]) or false
end
return ret
end
function doChangeBalls(cid, item1, item2)
if not isCreature(cid) then return true end
if item1.uid == item2.uid then
if #getCreatureSummons(cid) <= 0 then
doGoPokemon(cid, getPlayerSlotItem(cid, 8))
else
doReturnPokemon(cid, getCreatureSummons(cid)[1], getPlayerSlotItem(cid, 8), pokeballs[getPokeballType(getPlayerSlotItem(cid, 8).itemid)].effect)
end
return true
end
if item1.uid > 0 and item2.uid > 0 then
local io = getBallsAttributes(item1.uid)
local it = getBallsAttributes(item2.uid)
for a, b in pairs (io) do
if b then
doItemSetAttribute(item2.uid, a, b)
else
doItemEraseAttribute(item2.uid, a)
end
end
for a, b in pairs (it) do
if b then
doItemSetAttribute(item1.uid, a, b)
else
doItemEraseAttribute(item1.uid, a)
end
end
local id = item2.itemid
doTransformItem(item2.uid, item1.itemid)
doTransformItem(item1.uid, id)
doGoPokemon(cid, getPlayerSlotItem(cid, 8))
else
local id = item2.itemid
local b = getBallsAttributes(item2.uid)
local a = doPlayerAddItem(cid, 2643, false)
for c, d in pairs (b) do
if d then
doItemSetAttribute(a, c, d)
else
doItemEraseAttribute(a, c)
end
end
doRemoveItem(item2.uid, 1)
doTransformItem(a, id)
doGoPokemon(cid, getPlayerSlotItem(cid, 8))
end
end
 
Code:
function onLogout(cid)
   
    if not isCreature(cid) then return true end
    local thisitem = getPlayerSlotItem(cid, 8)
   
    if thisitem.uid <= 0 then return true end
   
    local ballName = getItemAttribute(thisitem.uid, "poke")
   
    --------------------------------------------------------
    btype = getPokeballType(thisitem.itemid)
    ---------------------------------------------------------------
    if #getCreatureSummons(cid) > 1 and getPlayerStorageValue(cid, 212124) <= 0 then    --alterado v1.6
       if getPlayerStorageValue(cid, 637501) == -2 or getPlayerStorageValue(cid, 637501) >= 1 then 
          BackTeam(cid)      
       end
    end
    --////////////////////////////////////////////////////////////////////////////////////////--
    if not isCreature(cid) then return true end
    if getPlayerStorageValue(cid, 52480) >= 1 or getPlayerStorageValue(cid, 52481) >= 0 then
       local sid = getPlayerByName(getPlayerStorageValue(cid, 52482))
       local sendLose = true
       if isCreature(sid) then
          if getPlayerStorageValue(sid, 52482) == getCreatureName(cid) then
             addEvent(doSendAnimatedText, 1000, getThingPosWithDebug(sid), "WIN", COLOR_ELECTRIC)
             setPlayerStorageValue(sid, 52480, -1)
             setPlayerStorageValue(sid, 52481, -1)
             setPlayerStorageValue(sid, 52482, -1)
             setPlayerStorageValue(sid, 52483, -1)           --alterado v1.6.1
             setPlayerStorageValue(sid, 6598754, -1)
             doCreatureSetSkullType(sid, 0)
          else
             sendLose = false
          end
       end
       if sendLose then
          addEvent(doSendAnimatedText, 1000, getThingPosWithDebug(cid), "LOSE", COLOR_BURN)
       end
       setPlayerStorageValue(cid, 52480, -1)
       setPlayerStorageValue(cid, 52481, -1)
       setPlayerStorageValue(cid, 52482, -1)
       setPlayerStorageValue(cid, 52483, -1)
       setPlayerStorageValue(cid, 6598754, -1)
       doCreatureSetSkullType(cid, 0)
    end
    --////////////////////////////////////////////////////////////////////////////////////////--
    if #getCreatureSummons(cid) == 2 and getPlayerStorageValue(cid, 212124) >= 1 then
       local cmed2 = getCreatureSummons(cid)[1]
       local poscmed = getThingPos(cmed2)
       local cmeddir = getCreatureLookDir(cmed2)
       local namecmed = getCreatureName(cmed2)
       local hp, maxHp = getCreatureHealth(getCreatureSummons(cid)[1]), getCreatureMaxHealth(getCreatureSummons(cid)[1])
       local gender = getPokemonGender(cmed2)
       doRemoveCreature(getCreatureSummons(cid)[1])
       local back = doCreateMonster(namecmed, poscmed)
       addEvent(doCreatureSetSkullType, 150, back, gender)
       doCreatureSetLookDir(back, cmeddir)
       addEvent(doCreatureAddHealth, 100, back, hp-maxHp)
                                                                            --alterado v1.5
       -- pokemon controlador   
       local ball2 = getPlayerSlotItem(cid, 8)
       local mynewpos = getThingPos(getCreatureSummons(cid)[1])
       doRemoveCreature(getCreatureSummons(cid)[1])
       local pk2 = doSummonCreature(getItemAttribute(ball2.uid, "poke"), mynewpos)
       doConvinceCreature(cid, pk2)
       addEvent(doAdjustWithDelay, 100, cid, pk2, true, true, false)
       setPlayerStorageValue(cid, 888, 0)
       cleanCMcds(ball2.uid)
       doCreatureSetLookDir(getCreatureSummons(cid)[1], 2)
       registerCreatureEvent(pk2, "SummonDeath")    --alterado v1.6
    end
   
    ----------------------------------------------------------------------
    local summon = getCreatureSummons(cid)[1]     
     
    if #getCreatureSummons(cid) >= 1 and thisitem.uid > 1 then
        if getPlayerStorageValue(cid, 212124) <= 0 then
           doItemSetAttribute(thisitem.uid, "hp", (getCreatureHealth(summon) / getCreatureMaxHealth(summon)))
        end                                                          --alterado v1.5
        setPlayerStorageValue(cid, 212124, 0)
        doTransformItem(thisitem.uid, pokeballs[btype].on)
        doSendMagicEffect(getThingPos(summon), pokeballs[btype].effect)
        doRemoveCreature(summon)
    end

    if getCreatureOutfit(cid).lookType == 814 then
        doPlayerStopWatching(cid)
    end

    if tonumber(getPlayerStorageValue(cid, 17000)) and getPlayerStorageValue(cid, 17000) >= 1 then  --alterado v1.6
        markFlyingPos(cid, getThingPos(cid))
    end
   
    if getPlayerStorageValue(cid, 22545) == 1 then     --alterado v1.4
       setGlobalStorageValue(22550, getGlobalStorageValue(22550)-1)
    end

return TRUE
end

local deathtexts = {"Oh no! POKENAME, come back!", "Come back, POKENAME!", "That's enough, POKENAME!", "You did well, POKENAME!",
            "You need to rest, POKENAME!", "Nice job, POKENAME!", "POKENAME, you are too hurt!"}

function onDeath(cid, deathList)

    local owner = getCreatureMaster(cid)

        if getPlayerStorageValue(cid, 637500) >= 1 then
           doSendMagicEffect(getThingPos(cid), 211)
           doRemoveCreature(cid)
           return true
        end
       
        if getPlayerStorageValue(cid, 212123) >= 1 then
           return true
        end
       
        --////////////////////////////////////////////////////////////////////////////////////////--
        checkDuel(owner)                                                                          --alterado v1.6 duel system
        --////////////////////////////////////////////////////////////////////////////////////////--
       
    local thisball = getPlayerSlotItem(owner, 8)
    local ballName = getItemAttribute(thisball.uid, "poke")
   
    btype = getPokeballType(thisball.itemid)

        if #getCreatureSummons(owner) > 1 then
           BackTeam(owner, getCreatureSummons(owner))     
        end

        doSendMagicEffect(getThingPos(cid), pokeballs[btype].effect)
        doTransformItem(thisball.uid, pokeballs[btype].off)

        doPlayerSendTextMessage(owner, 22, "Your pokemon fainted.")

    local say = deathtexts[math.random(#deathtexts)]
        say = string.gsub(say, "POKENAME", getCreatureName(cid))

    if getPlayerStorageValue(cid, 33) <= 0 then
        doCreatureSay(owner, say, TALKTYPE_SAY)
    end

    doItemSetAttribute(thisball.uid, "hp", 0)
    if ehMonstro(deathList[1]) then
       doItemSetAttribute(thisball.uid, "happy", getPlayerStorageValue(cid, 1008) - happyLostOnDeath)
    end
    doItemSetAttribute(thisball.uid, "hunger", getPlayerStorageValue(cid, 1009))

    doRemoveCreature(cid)

return false
end
 
Code:
local hitmonchans = {
["Hitmonchan"] = {
                         [0] = {out = 559, eff = 112, type = FIGHTINGDAMAGE},  --outfit normal
                         [1] = {out = 1075, eff = 35, type = FIREDAMAGE},    --outfit fogo
                         [2] = {out = 1077, eff = 48, type = ELECTRICDAMAGE},    --outfit raio
                         [3] = {out = 1078, eff = 43, type = ICEDAMAGE},    --outfit gelo
                         [4] = {out = 1076, eff = 140, type = GHOSTDAMAGE}   --outfit ghost
                  },
                 
["Shiny Hitmonchan"] = {             
                         --aconcelho trocar a outfit do shiny hitmonchan pela do elite hitmonchan do PO...
                         [0] = {out = 837, eff = 112, type = FIGHTINGDAMAGE},  --outfit normal
                         [1] = {out = 1080, eff = 35, type = FIREDAMAGE},    --outfit fogo
                         [2] = {out = 1081, eff = 48, type = ELECTRICDAMAGE},    --outfit raio
                         [3] = {out = 1082, eff = 43, type = ICEDAMAGE},    --outfit gelo
                         [4] = {out = 1079, eff = 140, type = GHOSTDAMAGE}   --outfit ghost
                       }
}
function onUse(cid, item, frompos, item2, topos)

    if exhaustion.get(cid, 6666) and exhaustion.get(cid, 6666) > 0 then return true end

    local owner = getItemAttribute(item.uid, "firstpoke")

    if owner and owner ~= getCreatureName(cid) then
        doPlayerSendCancel(cid, "This pokemon belongs to "..owner..", it is his first pokemon. Please, give it back to him.")
    return true
    end

if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) >= 1 or getPlayerStorageValue(cid, 63215) >= 1 then
return true
end

local btype = getPokeballType(item.itemid)

local effect = pokeballs[btype].effect
    if not effect then
        effect = 21
    end

if item.itemid == pokeballs[btype].use then

    if getPlayerStorageValue(cid, 990) == 1 then -- GYM
        doPlayerSendCancel(cid, "You can't return your pokemon during gym battles.")
    return true
    end

    if #getCreatureSummons(cid) <= 0 then
        if isInArray(pokeballs[btype].all, item.itemid) then
            doTransformItem(item.uid, pokeballs[btype].off)
            doItemSetAttribute(item.uid, "hp", 0)
            doPlayerSendCancel(cid, "This pokemon is fainted.")
        return true
        end
    end

    local z = getCreatureSummons(cid)[1]

    if getCreatureCondition(z, CONDITION_INVISIBLE) and not isGhostPokemon(z) then
    return true
    end

    doReturnPokemon(cid, z, item, effect)

elseif item.itemid == pokeballs[btype].on then

    if item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_FEET).uid then
        doPlayerSendCancel(cid, "You must put your pokeball in the correct place!")
    return TRUE
    end

    local thishp = getItemAttribute(item.uid, "hp")

    if thishp <= 0 then
        if isInArray(pokeballs[btype].all, item.itemid) then
            doTransformItem(item.uid, pokeballs[btype].off)
            doItemSetAttribute(item.uid, "hp", 0)
            doPlayerSendCancel(cid, "This pokemon is fainted.")
        return true
        end
    end
   
    local pokemon = getItemAttribute(item.uid, "poke")
   
    local mypoke = getPokemonStatus(pokemon)
    if not mypoke then return true end
    local speed = getCreatureSpeed(cid) / 3
    doItemSetAttribute(item.uid, "speed", speed)
       

    if not pokes[pokemon] then
    return true
    end

    local x = pokes[pokemon]
   

    if getPlayerLevel(cid) + pokemonMaxLevelAbovePlayer < getItemAttribute(item.uid, "level") then
        doPlayerSendCancel(cid, "Your pokemon's level is much higher than yours, you can't use him.")
        return true
        end

    doSummonMonster(cid, pokemon)
   
    local pk = getCreatureSummons(cid)[1]
    if not isCreature(pk) then return true end
    ------------------------passiva hitmonchan------------------------------
    if isSummon(pk) then
       --local e = getCreatureMaster(cid)
       local nameHIT = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "poke")
       local hands = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "hands")
       if nameHIT == "Shiny Hitmonchan" or nameHIT == "Hitmonchan" then
          if getItemAttribute(getPlayerSlotItem(cid, 8).uid, "hands") then
             doSetCreatureOutfit(pk, {lookType = hitmonchans[nameHIT][hands].out}, -1)
          else
              doPlayerSendTextMessage(cid, 27, "Contact a GameMaster! Error in passive system! Attribute \"hands\" missing") 
          end
       end
    end
    -------------------------------------------------------------------------     

    if getCreatureName(pk) == "Ditto" then

        local left = getItemAttribute(item.uid, "transLeft")
        local name = getItemAttribute(item.uid, "transName")

        if left and left > 0 then
            setPlayerStorageValue(pk, 1010, name)
            doSetCreatureOutfit(pk, {lookType = getItemAttribute(item.uid, "transOutfit")}, -1)
            addEvent(deTransform, left * 1000, pk, getItemAttribute(item.uid, "transTurn"))
            doItemSetAttribute(item.uid, "transBegin", os.clock())
        else
            setPlayerStorageValue(pk, 1010, "Ditto")
        end
    end

    if isGhostPokemon(pk) then doTeleportThing(pk, getPosByDir(getThingPos(cid), math.random(0, 7)), false) end

    doCreatureSetLookDir(pk, 2)

    adjustStatus(pk, item.uid, true, false, true)
    doAddPokemonInOwnList(cid, pokemon)

    doTransformItem(item.uid, item.itemid+1)

    local pokename = getItemAttribute(item.uid, "nick") or getCreatureName(pk)

    local mgo = gobackmsgs[math.random(1, #gobackmsgs)].go:gsub("doka", pokename)
    doCreatureSay(cid, mgo, TALKTYPE_SAY)

    doSendMagicEffect(getCreaturePosition(pk), effect)

local pk = getCreatureSummons(cid)[1]
        local pb = getPlayerSlotItem(cid, 8).uid
        local look = getItemAttribute(pb,"addon")
        if not look then
                doSetItemAttribute(pb,"addon",0)
        return false
        end
        if look > 0 then
                doSetCreatureOutfit(pk, {lookType = look}, -1)
        return true
        end

else

    doPlayerSendCancel(cid, "This pokemon is fainted.")

end

    if useKpdoDlls then
        doUpdateMoves(cid)
    end
return true
end
 
Code:
local function ChangeBalls(cid, param, cancelequal)
    local balls = getPlayerPokeballs(cid)
    for a = 1, #balls do
        local item = balls[a]
        local name = getItemAttribute(item.uid, "poke") .. getItemAttribute(item.uid, "ballorder")
        if name == param then
            if cancelequal and item.uid == getPlayerSlotItem(cid, 8).uid then return true end
            doChangeBalls(cid, getPlayerSlotItem(cid, 8), item)
            return 0
        end
    end
end

function onSay(cid, words, param)

    if not useKpdoDlls then return true end

    if words == "!code64" then
    return 0
    end

    if words == "/pokeread" then
        if #getCreatureSummons(cid) >= 1 then
            local pokemon = getCreatureSummons(cid)[1]
            local pokelife = (getCreatureHealth(pokemon) / getCreatureMaxHealth(pokemon))
            doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "hp", pokelife)
        end
        doUpdatePokemonsBar(cid)
    end

    if words == "/goaction" then
        if param == "null" then return 0 end
        if exhaustion.get(cid, 6666) and exhaustion.get(cid, 6666) > 0 then return true end
        if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) >= 1 or getPlayerStorageValue(cid, 63215) >= 1 then return true end
        if #getCreatureSummons(cid) >= 1 then
            addEvent(doReturnPokemon, 100, cid, getCreatureSummons(cid)[1], false, pokeballs[getPokeballType(getPlayerSlotItem(cid, 8).itemid)].effect)
            if param ~= getItemAttribute(getPlayerSlotItem(cid, 8).uid, "poke") .. getItemAttribute(getPlayerSlotItem(cid, 8).uid, "ballorder") then
                addEvent(ChangeBalls, 1200, cid, param, true)
            end
        else
            addEvent(ChangeBalls, 100, cid, param)
        end
        exhaustion.set(cid, 6666, 2)
    return 0
    end

return 0
end
 
Back
Top