• 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!

Lua attempt to index a boolean value

Cracudoo

New Member
Joined
Jan 22, 2017
Messages
32
Reaction score
0
Error while speaking commands

Code:
[22/02/2017 12:39:21] [Error - TalkAction Interface] 
[22/02/2017 12:39:21] data/talkactions/scripts/dittomemory.lua:onSay
[22/02/2017 12:39:21] Description: 
[22/02/2017 12:39:21] data/talkactions/scripts/dittomemory.lua:90: attempt to index a boolean value
[22/02/2017 12:39:21] stack traceback:
[22/02/2017 12:39:21]     data/talkactions/scripts/dittomemory.lua:90: in function <data/talkactions/scripts/dittomemory.lua:33>

[22/02/2017 12:39:22] [Error - TalkAction Interface] 
[22/02/2017 12:39:22] data/talkactions/scripts/dittomemory.lua:onSay
[22/02/2017 12:39:22] Description: 
[22/02/2017 12:39:22] data/talkactions/scripts/dittomemory.lua:76: attempt to index a boolean value
[22/02/2017 12:39:22] stack traceback:
[22/02/2017 12:39:22]     data/talkactions/scripts/dittomemory.lua:76: in function <data/talkactions/scripts/dittomemory.lua:33>

[22/02/2017 12:39:23] [Error - TalkAction Interface] 
[22/02/2017 12:39:23] data/talkactions/scripts/dittomemory.lua:onSay
[22/02/2017 12:39:23] Description: 
[22/02/2017 12:39:23] data/talkactions/scripts/dittomemory.lua:57: attempt to index a boolean value
[22/02/2017 12:39:23] stack traceback:
[22/02/2017 12:39:23]     data/talkactions/scripts/dittomemory.lua:57: in function <data/talkactions/scripts/dittomemory.lua:33>

Script

Code:
local maxSlots = 3            --Quantia máxima de slots.
function getDittoSlots(item)
    if not item or item < 1 then
        return false
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        return false
    end
    local slots = {}
    for i = 1, maxSlots do
        local attr = getItemAttribute(item, "memory"..i)
        if attr then
            slots[i] = attr
        end
    end
    return slots
end
function hasDittoSavedPokemon(item, name)
    if not item or item < 1 then
        return false
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        return false
    end
    local check
    for i = 1, maxSlots do
        local attr = getItemAttribute(item, "memory"..i)
        if attr and attr == name then
            check = true
            break
        end
    end
    return check
end
function onSay(cid, words, param)
    local item = getPlayerSlotItem(cid, 8).uid
    if item < 1 then
        doPlayerSendCancel(cid, "Coloque uma pokeball no slot pokeball.")
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        doPlayerSendCancel(cid, "Coloque uma pokeball com um Ditto no slot pokeball.")
    elseif param == "" then
        doPlayerSendCancel(cid, "Especifique um param.")
    else
        param = param:lower()
        if param == "check" then
            local str = ""
            for i = 1, maxSlots do
                local attr = getItemAttribute(item, "memory"..i) or "No memory"
                if str == "" then
                    str = i.." - "..attr
                else
                    str = str.."\n"..i.." - "..attr
                end
            end
            doPlayerPopupFYI(cid, "Ditto Memory:\n"..str.."")
        elseif param:find("forget") then
            local slot = tonumber(param:match("forget (.+)"))
            if slot and slot <= maxSlots and slot > 0 then
                if getDittoSlots(item)[slot] then
                    doItemSetAttribute(item, "memory"..slot, false)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory] Slot "..slot.." deletado.")
                else
                    doPlayerSendCancel(cid, "Este slot está vazio.")
                end
            else
                doPlayerSendCancel(cid, "Slot inválido.")
            end
        else
            local summons = getCreatureSummons(cid)
            if #summons == 0 then
                doPlayerSendCancel(cid, "Você não tem nenhum pokemon fora do pokeball.")
            else
                if param:find("save") then
                    local transformedPoke = getItemAttribute(item, "poke")
                    if transformedPoke and type(transformedPoke) == "string" and transformedPoke ~= "Ditto" then
                        local slot = tonumber(param:match("save (.+)"))
                        if slot and slot <= maxSlots and slot > 0 then
                            if not getDittoSlots(item)[slot] and not hasDittoSavedPokemon(item, transformedPoke) then
                                doItemSetAttribute(item, "memory"..slot, transformedPoke)
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory]  Você salvou um "..slot..": "..transformedPoke..".")
                            else
                                doPlayerSendCancel(cid, "Este slot não está vazio ou o seu Ditto já tem esse pokemon salvo em sua memória.")
                            end
                        else
                            doPlayerSendCancel(cid, "Slot inválido.")
                        end
                    else
                        doPlayerSendCancel(cid, "Seu Ditto não está transformado em outro pokemon.")
                    end
                else
                    local slot = tonumber(param)
                    local transformPoke = getDittoSlots(item)[slot]
                    if not slot then
                        doPlayerSendCancel(cid, "param inválido.")
                    elseif slot <= 0 or slot > maxSlots then
                        doPlayerSendCancel(cid, "Use um slot válido.")
                    elseif not transformPoke then
                        doPlayerSendCancel(cid, "Este slot está vazio.")
                    elseif getPlayerStorageValue(summons[1], 1010) == transformPoke then
                        doPlayerSendCancel(cid, "Seu Ditto já está transformado neste pokemon.")
                    else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory] Usando o slot "..slot..", seu Ditto é transformado em um "..transformPoke..".")
                        setPlayerStorageValue(summons[1], 1010, transformPoke)
                        doSetCreatureOutfit(summons[1], {lookType = getPokemonXMLOutfit(transformPoke)}, -1)
                        doSendMagicEffect(getThingPos(summons[1]), 184)
                        doCreatureSay(summons[1], "TRANSFORM!", TALKTYPE_MONSTER)
                        doItemSetAttribute(item, "poke", transformPoke)
                        if useKpdoDlls then
                            doUpdateMoves(cid)
                        end
                        if dittoCopiesStatusToo then
                           setPlayerStorageValue(summons[1], 1001, dittoBonus * pokes[transformPoke].offense * getPlayerLevel(cid))
                           setPlayerStorageValue(summons[1], 1002, dittoBonus * pokes[transformPoke].defense)
                           setPlayerStorageValue(summons[1], 1003, pokes[transformPoke].agility)
                           setPlayerStorageValue(summons[1], 1004, dittoBonus * pokes[transformPoke].vitality * getPlayerLevel(cid))
                           setPlayerStorageValue(summons[1], 1005, dittoBonus * pokes[transformPoke].specialattack * getPlayerLevel(cid))
                           local pct = getCreatureHealth(summons[1]) / getCreatureMaxHealth(summons[1])
                           local vit = getVitality(summons[1]) * getPlayerLevel(cid) / 100
                           setCreatureMaxHealth(summons[1], vit * HPperVITsummon)
                           doCreatureAddHealth(summons[1], pct * vit * HPperVITsummon)
                    end
                end
            end
        end
    end
    end
    return true
end
 
try this

Lua:
local maxSlots = 3            --Quantia máxima de slots.
function getDittoSlots(item)
    if not item or item < 1 then
        return false
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        return false
    end
    local slots = {}
    for i = 1, maxSlots do
        local attr = getItemAttribute(item, "memory"..i)
        if attr then
            slots[i] = attr
        end
    end
    return slots
end
function hasDittoSavedPokemon(item, name)
    if not item or item < 1 then
        return false
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        return false
    end
    local check
    for i = 1, maxSlots do
        local attr = getItemAttribute(item, "memory"..i)
        if attr and attr == name then
            check = true
            break
        end
    end
    return check
end
function onSay(cid, words, param)
    local item = getPlayerSlotItem(cid, 8).uid
    if item < 1 then
        doPlayerSendCancel(cid, "Coloque uma pokeball no slot pokeball.")
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        doPlayerSendCancel(cid, "Coloque uma pokeball com um Ditto no slot pokeball.")
    elseif param == "" then
        doPlayerSendCancel(cid, "Especifique um param.")
    else
        param = param:lower()
        if param == "check" then
            local str = ""
            for i = 1, maxSlots do
                local attr = getItemAttribute(item, "memory"..i) or "No memory"
                if str == "" then
                    str = i.." - "..attr
                else
                    str = str.."\n"..i.." - "..attr
                end
            end
            doPlayerPopupFYI(cid, "Ditto Memory:\n"..str.."")
        elseif param:find("forget") then
            local slot = tonumber(param:match("forget (.+)"))
            if slot and slot <= maxSlots and slot > 0 then
                if getDittoSlots(item)[slot] then
                    doItemSetAttribute(item, "memory"..slot, false)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory] Slot "..slot.." deletado.")
                else
                    doPlayerSendCancel(cid, "Este slot está vazio.")
                end
            else
                doPlayerSendCancel(cid, "Slot inválido.")
            end
        else
            local summons = getCreatureSummons(cid)
            if #summons == 0 then
                doPlayerSendCancel(cid, "Você não tem nenhum pokemon fora do pokeball.")
            else
                if param:find("save") then
                    local transformedPoke = getItemAttribute(item, "poke")
                    if transformedPoke and type(transformedPoke) == "string" and transformedPoke ~= "Ditto" then
                        local slot = tonumber(param:match("save (.+)"))
                        if slot and slot <= maxSlots and slot > 0 then
                            if not getDittoSlots(item)[slot] and not hasDittoSavedPokemon(item, transformedPoke) then
                                doItemSetAttribute(item, "memory"..slot, transformedPoke)
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory]  Você salvou um "..slot..": "..transformedPoke..".")
                            else
                                doPlayerSendCancel(cid, "Este slot não está vazio ou o seu Ditto já tem esse pokemon salvo em sua memória.")
                            end
                        else
                            doPlayerSendCancel(cid, "Slot inválido.")
                        end
                    else
                        doPlayerSendCancel(cid, "Seu Ditto não está transformado em outro pokemon.")
                    end
                else
                    local slot = tonumber(param)
                    local transformPoke = getDittoSlots(item)
                    if transformPoke and slot then
                        transformPoke = transformPoke[slot]
                    else
                        doPlayerSendCancel(cid, "param inválido.")
                        return true
                    end

                    if not slot then
                        doPlayerSendCancel(cid, "param inválido.")
                    elseif slot <= 0 or slot > maxSlots then
                        doPlayerSendCancel(cid, "Use um slot válido.")
                    elseif not transformPoke then
                        doPlayerSendCancel(cid, "Este slot está vazio.")
                    elseif getPlayerStorageValue(summons[1], 1010) == transformPoke then
                        doPlayerSendCancel(cid, "Seu Ditto já está transformado neste pokemon.")
                    else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory] Usando o slot "..slot..", seu Ditto é transformado em um "..transformPoke..".")
                        setPlayerStorageValue(summons[1], 1010, transformPoke)
                        doSetCreatureOutfit(summons[1], {lookType = getPokemonXMLOutfit(transformPoke)}, -1)
                        doSendMagicEffect(getThingPos(summons[1]), 184)
                        doCreatureSay(summons[1], "TRANSFORM!", TALKTYPE_MONSTER)
                        doItemSetAttribute(item, "poke", transformPoke)
                        if useKpdoDlls then
                            doUpdateMoves(cid)
                        end
                        if dittoCopiesStatusToo then
                           setPlayerStorageValue(summons[1], 1001, dittoBonus * pokes[transformPoke].offense * getPlayerLevel(cid))
                           setPlayerStorageValue(summons[1], 1002, dittoBonus * pokes[transformPoke].defense)
                           setPlayerStorageValue(summons[1], 1003, pokes[transformPoke].agility)
                           setPlayerStorageValue(summons[1], 1004, dittoBonus * pokes[transformPoke].vitality * getPlayerLevel(cid))
                           setPlayerStorageValue(summons[1], 1005, dittoBonus * pokes[transformPoke].specialattack * getPlayerLevel(cid))
                           local pct = getCreatureHealth(summons[1]) / getCreatureMaxHealth(summons[1])
                           local vit = getVitality(summons[1]) * getPlayerLevel(cid) / 100
                           setCreatureMaxHealth(summons[1], vit * HPperVITsummon)
                           doCreatureAddHealth(summons[1], pct * vit * HPperVITsummon)
                    end
                end
            end
        end
    end
    end
    return true
end
 
try this

Lua:
local maxSlots = 3            --Quantia máxima de slots.
function getDittoSlots(item)
    if not item or item < 1 then
        return false
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        return false
    end
    local slots = {}
    for i = 1, maxSlots do
        local attr = getItemAttribute(item, "memory"..i)
        if attr then
            slots[i] = attr
        end
    end
    return slots
end
function hasDittoSavedPokemon(item, name)
    if not item or item < 1 then
        return false
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        return false
    end
    local check
    for i = 1, maxSlots do
        local attr = getItemAttribute(item, "memory"..i)
        if attr and attr == name then
            check = true
            break
        end
    end
    return check
end
function onSay(cid, words, param)
    local item = getPlayerSlotItem(cid, 8).uid
    if item < 1 then
        doPlayerSendCancel(cid, "Coloque uma pokeball no slot pokeball.")
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        doPlayerSendCancel(cid, "Coloque uma pokeball com um Ditto no slot pokeball.")
    elseif param == "" then
        doPlayerSendCancel(cid, "Especifique um param.")
    else
        param = param:lower()
        if param == "check" then
            local str = ""
            for i = 1, maxSlots do
                local attr = getItemAttribute(item, "memory"..i) or "No memory"
                if str == "" then
                    str = i.." - "..attr
                else
                    str = str.."\n"..i.." - "..attr
                end
            end
            doPlayerPopupFYI(cid, "Ditto Memory:\n"..str.."")
        elseif param:find("forget") then
            local slot = tonumber(param:match("forget (.+)"))
            if slot and slot <= maxSlots and slot > 0 then
                if getDittoSlots(item)[slot] then
                    doItemSetAttribute(item, "memory"..slot, false)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory] Slot "..slot.." deletado.")
                else
                    doPlayerSendCancel(cid, "Este slot está vazio.")
                end
            else
                doPlayerSendCancel(cid, "Slot inválido.")
            end
        else
            local summons = getCreatureSummons(cid)
            if #summons == 0 then
                doPlayerSendCancel(cid, "Você não tem nenhum pokemon fora do pokeball.")
            else
                if param:find("save") then
                    local transformedPoke = getItemAttribute(item, "poke")
                    if transformedPoke and type(transformedPoke) == "string" and transformedPoke ~= "Ditto" then
                        local slot = tonumber(param:match("save (.+)"))
                        if slot and slot <= maxSlots and slot > 0 then
                            if not getDittoSlots(item)[slot] and not hasDittoSavedPokemon(item, transformedPoke) then
                                doItemSetAttribute(item, "memory"..slot, transformedPoke)
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory]  Você salvou um "..slot..": "..transformedPoke..".")
                            else
                                doPlayerSendCancel(cid, "Este slot não está vazio ou o seu Ditto já tem esse pokemon salvo em sua memória.")
                            end
                        else
                            doPlayerSendCancel(cid, "Slot inválido.")
                        end
                    else
                        doPlayerSendCancel(cid, "Seu Ditto não está transformado em outro pokemon.")
                    end
                else
                    local slot = tonumber(param)
                    local transformPoke = getDittoSlots(item)
                    if transformPoke and slot then
                        transformPoke = transformPoke[slot]
                    else
                        doPlayerSendCancel(cid, "param inválido.")
                        return true
                    end

                    if not slot then
                        doPlayerSendCancel(cid, "param inválido.")
                    elseif slot <= 0 or slot > maxSlots then
                        doPlayerSendCancel(cid, "Use um slot válido.")
                    elseif not transformPoke then
                        doPlayerSendCancel(cid, "Este slot está vazio.")
                    elseif getPlayerStorageValue(summons[1], 1010) == transformPoke then
                        doPlayerSendCancel(cid, "Seu Ditto já está transformado neste pokemon.")
                    else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory] Usando o slot "..slot..", seu Ditto é transformado em um "..transformPoke..".")
                        setPlayerStorageValue(summons[1], 1010, transformPoke)
                        doSetCreatureOutfit(summons[1], {lookType = getPokemonXMLOutfit(transformPoke)}, -1)
                        doSendMagicEffect(getThingPos(summons[1]), 184)
                        doCreatureSay(summons[1], "TRANSFORM!", TALKTYPE_MONSTER)
                        doItemSetAttribute(item, "poke", transformPoke)
                        if useKpdoDlls then
                            doUpdateMoves(cid)
                        end
                        if dittoCopiesStatusToo then
                           setPlayerStorageValue(summons[1], 1001, dittoBonus * pokes[transformPoke].offense * getPlayerLevel(cid))
                           setPlayerStorageValue(summons[1], 1002, dittoBonus * pokes[transformPoke].defense)
                           setPlayerStorageValue(summons[1], 1003, pokes[transformPoke].agility)
                           setPlayerStorageValue(summons[1], 1004, dittoBonus * pokes[transformPoke].vitality * getPlayerLevel(cid))
                           setPlayerStorageValue(summons[1], 1005, dittoBonus * pokes[transformPoke].specialattack * getPlayerLevel(cid))
                           local pct = getCreatureHealth(summons[1]) / getCreatureMaxHealth(summons[1])
                           local vit = getVitality(summons[1]) * getPlayerLevel(cid) / 100
                           setCreatureMaxHealth(summons[1], vit * HPperVITsummon)
                           doCreatureAddHealth(summons[1], pct * vit * HPperVITsummon)
                    end
                end
            end
        end
    end
    end
    return true
end

No command works and the same errors happen, like ^^

Code:
[22/02/2017 13:09:41] [Error - TalkAction Interface] 
[22/02/2017 13:09:41] data/talkactions/scripts/dittomemory.lua:onSay
[22/02/2017 13:09:41] Description: 
[22/02/2017 13:09:41] data/talkactions/scripts/dittomemory.lua:77: attempt to index a boolean value
[22/02/2017 13:09:41] stack traceback:
[22/02/2017 13:09:41]     data/talkactions/scripts/dittomemory.lua:77: in function <data/talkactions/scripts/dittomemory.lua:34>

[22/02/2017 13:09:42] [Error - TalkAction Interface] 
[22/02/2017 13:09:42] data/talkactions/scripts/dittomemory.lua:onSay
[22/02/2017 13:09:42] Description: 
[22/02/2017 13:09:42] data/talkactions/scripts/dittomemory.lua:58: attempt to index a boolean value
[22/02/2017 13:09:42] stack traceback:
[22/02/2017 13:09:42]     data/talkactions/scripts/dittomemory.lua:58: in function <data/talkactions/scripts/dittomemory.lua:34>
 
try
Lua:
local maxSlots = 3            --Quantia máxima de slots.
function getDittoSlots(item)
    if not item or item < 1 then
        return false
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        return false
    end
    local slots = {}
    for i = 1, maxSlots do
        local attr = getItemAttribute(item, "memory"..i)
        if attr then
            slots[i] = attr
        end
    end
    return slots
end
function hasDittoSavedPokemon(item, name)
    if not item or item < 1 then
        return false
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        return false
    end
    local check
    for i = 1, maxSlots do
        local attr = getItemAttribute(item, "memory"..i)
        if attr and attr == name then
            check = true
            break
        end
    end
    return check
end
function onSay(cid, words, param)
    local item = getPlayerSlotItem(cid, 8).uid
    if item < 1 then
        doPlayerSendCancel(cid, "Coloque uma pokeball no slot pokeball.")
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        doPlayerSendCancel(cid, "Coloque uma pokeball com um Ditto no slot pokeball.")
    elseif param == "" then
        doPlayerSendCancel(cid, "Especifique um param.")
    else
        param = param:lower()
        if param == "check" then
            local str = ""
            for i = 1, maxSlots do
                local attr = getItemAttribute(item, "memory"..i) or "No memory"
                if str == "" then
                    str = i.." - "..attr
                else
                    str = str.."\n"..i.." - "..attr
                end
            end
            doPlayerPopupFYI(cid, "Ditto Memory:\n"..str.."")
        elseif param:find("forget") then
            local slot = tonumber(param:match("forget (.+)"))
            if slot and slot <= maxSlots and slot > 0 then
                local dittoSlots = getDittoSlots(item)
                if dittoSlots and dittoSlots[slot] then
                    doItemSetAttribute(item, "memory"..slot, false)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory] Slot "..slot.." deletado.")
                else
                    doPlayerSendCancel(cid, "Este slot está vazio.")
                end
            else
                doPlayerSendCancel(cid, "Slot inválido.")
            end
        else
            local summons = getCreatureSummons(cid)
            if #summons == 0 then
                doPlayerSendCancel(cid, "Você não tem nenhum pokemon fora do pokeball.")
            else
                if param:find("save") then
                    local transformedPoke = getItemAttribute(item, "poke")
                    if transformedPoke and type(transformedPoke) == "string" and transformedPoke ~= "Ditto" then
                        local slot = tonumber(param:match("save (.+)"))
                        if slot and slot <= maxSlots and slot > 0 then
                            local dittoSlots = getDittoSlots(item)
                            if not (dittoSlots and dittoSlots[slot]) and not hasDittoSavedPokemon(item, transformedPoke) then
                                doItemSetAttribute(item, "memory"..slot, transformedPoke)
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory]  Você salvou um "..slot..": "..transformedPoke..".")
                            else
                                doPlayerSendCancel(cid, "Este slot não está vazio ou o seu Ditto já tem esse pokemon salvo em sua memória.")
                            end
                        else
                            doPlayerSendCancel(cid, "Slot inválido.")
                        end
                    else
                        doPlayerSendCancel(cid, "Seu Ditto não está transformado em outro pokemon.")
                    end
                else
                    local slot = tonumber(param)
                    local transformPoke = getDittoSlots(item)
                    if transformPoke and slot then
                        transformPoke = transformPoke[slot]
                    else
                        doPlayerSendCancel(cid, "param inválido.")
                        return true
                    end

                    if not slot then
                        doPlayerSendCancel(cid, "param inválido.")
                    elseif slot <= 0 or slot > maxSlots then
                        doPlayerSendCancel(cid, "Use um slot válido.")
                    elseif not transformPoke then
                        doPlayerSendCancel(cid, "Este slot está vazio.")
                    elseif getPlayerStorageValue(summons[1], 1010) == transformPoke then
                        doPlayerSendCancel(cid, "Seu Ditto já está transformado neste pokemon.")
                    else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory] Usando o slot "..slot..", seu Ditto é transformado em um "..transformPoke..".")
                        setPlayerStorageValue(summons[1], 1010, transformPoke)
                        doSetCreatureOutfit(summons[1], {lookType = getPokemonXMLOutfit(transformPoke)}, -1)
                        doSendMagicEffect(getThingPos(summons[1]), 184)
                        doCreatureSay(summons[1], "TRANSFORM!", TALKTYPE_MONSTER)
                        doItemSetAttribute(item, "poke", transformPoke)
                        if useKpdoDlls then
                            doUpdateMoves(cid)
                        end
                        if dittoCopiesStatusToo then
                           setPlayerStorageValue(summons[1], 1001, dittoBonus * pokes[transformPoke].offense * getPlayerLevel(cid))
                           setPlayerStorageValue(summons[1], 1002, dittoBonus * pokes[transformPoke].defense)
                           setPlayerStorageValue(summons[1], 1003, pokes[transformPoke].agility)
                           setPlayerStorageValue(summons[1], 1004, dittoBonus * pokes[transformPoke].vitality * getPlayerLevel(cid))
                           setPlayerStorageValue(summons[1], 1005, dittoBonus * pokes[transformPoke].specialattack * getPlayerLevel(cid))
                           local pct = getCreatureHealth(summons[1]) / getCreatureMaxHealth(summons[1])
                           local vit = getVitality(summons[1]) * getPlayerLevel(cid) / 100
                           setCreatureMaxHealth(summons[1], vit * HPperVITsummon)
                           doCreatureAddHealth(summons[1], pct * vit * HPperVITsummon)
                    end
                end
            end
        end
    end
    end
    return true
end
 
try
Lua:
local maxSlots = 3            --Quantia máxima de slots.
function getDittoSlots(item)
    if not item or item < 1 then
        return false
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        return false
    end
    local slots = {}
    for i = 1, maxSlots do
        local attr = getItemAttribute(item, "memory"..i)
        if attr then
            slots[i] = attr
        end
    end
    return slots
end
function hasDittoSavedPokemon(item, name)
    if not item or item < 1 then
        return false
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        return false
    end
    local check
    for i = 1, maxSlots do
        local attr = getItemAttribute(item, "memory"..i)
        if attr and attr == name then
            check = true
            break
        end
    end
    return check
end
function onSay(cid, words, param)
    local item = getPlayerSlotItem(cid, 8).uid
    if item < 1 then
        doPlayerSendCancel(cid, "Coloque uma pokeball no slot pokeball.")
    elseif not getItemAttribute(item, "ehditto") and getItemAttribute(item, "poke") ~= "Ditto" then
        doPlayerSendCancel(cid, "Coloque uma pokeball com um Ditto no slot pokeball.")
    elseif param == "" then
        doPlayerSendCancel(cid, "Especifique um param.")
    else
        param = param:lower()
        if param == "check" then
            local str = ""
            for i = 1, maxSlots do
                local attr = getItemAttribute(item, "memory"..i) or "No memory"
                if str == "" then
                    str = i.." - "..attr
                else
                    str = str.."\n"..i.." - "..attr
                end
            end
            doPlayerPopupFYI(cid, "Ditto Memory:\n"..str.."")
        elseif param:find("forget") then
            local slot = tonumber(param:match("forget (.+)"))
            if slot and slot <= maxSlots and slot > 0 then
                local dittoSlots = getDittoSlots(item)
                if dittoSlots and dittoSlots[slot] then
                    doItemSetAttribute(item, "memory"..slot, false)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory] Slot "..slot.." deletado.")
                else
                    doPlayerSendCancel(cid, "Este slot está vazio.")
                end
            else
                doPlayerSendCancel(cid, "Slot inválido.")
            end
        else
            local summons = getCreatureSummons(cid)
            if #summons == 0 then
                doPlayerSendCancel(cid, "Você não tem nenhum pokemon fora do pokeball.")
            else
                if param:find("save") then
                    local transformedPoke = getItemAttribute(item, "poke")
                    if transformedPoke and type(transformedPoke) == "string" and transformedPoke ~= "Ditto" then
                        local slot = tonumber(param:match("save (.+)"))
                        if slot and slot <= maxSlots and slot > 0 then
                            local dittoSlots = getDittoSlots(item)
                            if not (dittoSlots and dittoSlots[slot]) and not hasDittoSavedPokemon(item, transformedPoke) then
                                doItemSetAttribute(item, "memory"..slot, transformedPoke)
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory]  Você salvou um "..slot..": "..transformedPoke..".")
                            else
                                doPlayerSendCancel(cid, "Este slot não está vazio ou o seu Ditto já tem esse pokemon salvo em sua memória.")
                            end
                        else
                            doPlayerSendCancel(cid, "Slot inválido.")
                        end
                    else
                        doPlayerSendCancel(cid, "Seu Ditto não está transformado em outro pokemon.")
                    end
                else
                    local slot = tonumber(param)
                    local transformPoke = getDittoSlots(item)
                    if transformPoke and slot then
                        transformPoke = transformPoke[slot]
                    else
                        doPlayerSendCancel(cid, "param inválido.")
                        return true
                    end

                    if not slot then
                        doPlayerSendCancel(cid, "param inválido.")
                    elseif slot <= 0 or slot > maxSlots then
                        doPlayerSendCancel(cid, "Use um slot válido.")
                    elseif not transformPoke then
                        doPlayerSendCancel(cid, "Este slot está vazio.")
                    elseif getPlayerStorageValue(summons[1], 1010) == transformPoke then
                        doPlayerSendCancel(cid, "Seu Ditto já está transformado neste pokemon.")
                    else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[Ditto Memory] Usando o slot "..slot..", seu Ditto é transformado em um "..transformPoke..".")
                        setPlayerStorageValue(summons[1], 1010, transformPoke)
                        doSetCreatureOutfit(summons[1], {lookType = getPokemonXMLOutfit(transformPoke)}, -1)
                        doSendMagicEffect(getThingPos(summons[1]), 184)
                        doCreatureSay(summons[1], "TRANSFORM!", TALKTYPE_MONSTER)
                        doItemSetAttribute(item, "poke", transformPoke)
                        if useKpdoDlls then
                            doUpdateMoves(cid)
                        end
                        if dittoCopiesStatusToo then
                           setPlayerStorageValue(summons[1], 1001, dittoBonus * pokes[transformPoke].offense * getPlayerLevel(cid))
                           setPlayerStorageValue(summons[1], 1002, dittoBonus * pokes[transformPoke].defense)
                           setPlayerStorageValue(summons[1], 1003, pokes[transformPoke].agility)
                           setPlayerStorageValue(summons[1], 1004, dittoBonus * pokes[transformPoke].vitality * getPlayerLevel(cid))
                           setPlayerStorageValue(summons[1], 1005, dittoBonus * pokes[transformPoke].specialattack * getPlayerLevel(cid))
                           local pct = getCreatureHealth(summons[1]) / getCreatureMaxHealth(summons[1])
                           local vit = getVitality(summons[1]) * getPlayerLevel(cid) / 100
                           setCreatureMaxHealth(summons[1], vit * HPperVITsummon)
                           doCreatureAddHealth(summons[1], pct * vit * HPperVITsummon)
                    end
                end
            end
        end
    end
    end
    return true
end

Memory save 1, 2 or 3 it says that the param param is invalid, the same thing happens with the memory forget command when it is transformed it says that the slot is empty And does nothing </ 3

Would not it be possible to use the / memory save command and the / memory forget even with the already transformed pokémon? Because it gets annoying to have to unlock the ditto always just to remove a slot or turn into an already memorized one.

The / memory save is working normal <3
 
Back
Top