Jump to content
  • 0

[Resolvido] Ajuda com Mensagem


jenison06

Question

Boa noite a Todos estou com o seguinte erro como na imagem

eu queria que essa mensagem Voce gastou 1 ultraball para capturar esse pokemon ficasse abaixo do voce capturou um pokemon.

o erro e que essa mensagem aparece antes do efeito da ball termina assim tira a emoção.

erro cath.PNG

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Substitui o código por esse e testa:

Spoiler

local texts = {
    [PORTUGUESE] = {"Você CAPTUROU um Pokémon novo!", "Você está carregando seis pokemons na bolsa, seu novo pokemon foi enviado ao Centro Pokémon de sua cidade!", "Por pouco... a Pokebola quebrou, mas continue tentando!", "A captura de pokémons não é permitida neste local.", "Este objeto não pode ser capturado.", "Você não é o dono deste corpo.", "Por favor, apenas utilize as Saffari Balls dentro da Saffari Zone.", "Este pokémon não pode ser capturado.", "Desculpe, não é possível."},
    [ENGLISH] = {"You CAUGHT a new Pokemon!", "You are holding six pokemons, your new pokemon will be sent to the Pokemon Center of your hometown!", "Not this time :/ Try again!", "Catching pokemons is not allowed inside this place.", "This thing is uncatchable.", "You are not the owner of this corpse.", "Please, only use Saffari Balls inside the Saffari Zone.", "This pokemon is uncatchable.", "Sorry, not possible."},
}

local time = 4
local pokeballs = {
    [9271] = {multiplier=1, failEffect=23, successEffect=24, shootEffect=17}, -- STARTER'S PB
    [2149] = {multiplier=1, failEffect=23, successEffect=24, shootEffect=17}, -- PB
    [2147] = {multiplier=2, failEffect=197, successEffect=198, shootEffect=19}, -- GB
    [2150] = {multiplier=3, failEffect=201, successEffect=202, shootEffect=20}, -- SB
    [2146] = {multiplier=4, failEffect=199, successEffect=200, shootEffect=27}, -- UB
    [4758] = {multiplier=4, failEffect=199, successEffect=200, shootEffect=27}, -- starter ball UB
    [2151] = {multiplier=4, failEffect=203, successEffect=204, shootEffect=36}, -- Saffari Ball
}
catchRate = 1

local function onCapturePokemon(cid, name, params, ballid)
    local txt = texts[getPlayerLanguage(cid)]
    if isCreature(cid) then
        doPlayerAddSoul(cid, 1)
        doPlayerSendTextMessage(cid, 20, txt[1].. " ("..name..").")
        doEndCount(cid, ballid, name)
        if #getPlayerPokeballs(cid) >= 6 then
            local pokeball = doCreatePokeball(name, params.pokeball-1)
            doItemSetAttribute(pokeball, "pokemon_sex", params.sex)
            doPlayerSendMailByName(getCreatureName(cid), pokeball)
            local creature = getPlayerPokemon(cid) == false and cid or getPlayerPokemon(cid)
            doSendMagicEffect(getCreaturePosition(creature), 173)
            local file = io.open('data/logs/catchlog.txt','a')
            file:write(os.date().."  "..getCreatureName(cid).." caught a "..name.." with "..getItemNameById(params.pokeball).." at pos {X="..getCreaturePosition(cid).x.." Y="..getCreaturePosition(cid).y.." Z="..getCreaturePosition(cid).z..".\n")
            file:close()
            doPlayerSave(cid)
            doPlayerSendTextMessage(cid, 20, txt[2])
            
        else
            local pokeball = doCreatePokeball(name, params.pokeball)
            doItemSetAttribute(pokeball, "pokemon_sex", params.sex)
            doPlayerAddItemEx(cid, pokeball)
        end
    end
end

local function onFailCapturePokemon(cid)
    local txt = texts[getPlayerLanguage(cid)]
    if isCreature(cid) then
        local creature = cid
        local creature = getPlayerPokemon(cid) == false and cid or getPlayerPokemon(cid)
        doSendMagicEffect(getCreaturePosition(creature), 166)
        doPlayerSendTextMessage(cid, 27, txt[3])
    end
end

function onUse(cid, item, frompos, item2, topos)
    local txt = texts[getPlayerLanguage(cid)]
    if isPlayerInsideMewtwoQuest(cid) or isPlayerInsideArticunoQuest(cid) or isPlayerInsideHarmoniaQuest(cid) or isPlayerInsideMewQuest(cid) or isPlayerInsideZapdosQuest(cid) or isInsideGhostPlagueQuest(cid) or isInsideRocketQuest(cid) or isInsideMoltresQuest(cid) or isInsideGoldArena(cid)  or isInsideBox6(cid) then
        doPlayerSendCancel(cid, txt[4])
        return true
    end
    if item2.uid == 0 then
        return false
    end
    
    local corpses = {}
    local it = getTileInfo(topos)
    if not it or it.things == 0 then return false end
    for i=1, it.things do
        local item = getTileThingByPos({x=topos.x, y=topos.y, z=topos.z, stackpos=i})
        if item.uid ~= 0 and isCorpse(item.uid) and getItemAttribute(item.uid, "corpseowner") == cid then
            item2 = item
            break
        end
    end
    
    if item2.uid == 0 or not isCorpse(item2.uid) then
        doPlayerSendCancel(cid, txt[5])
        return true
    end
    
    if getItemAttribute(item2.uid, "corpseowner") ~= cid then
        doPlayerSendCancel(cid, txt[6])
        return true
    end
    
    if getPlayerStorageValue(cid, Saffari.storage) > 0 and item.itemid ~= Saffari.pokeballId then
        doPlayerSendCancel(cid, txt[7])
        return true
    end
    
    for i, x in pairs(pokes) do
        if item2.itemid == x.c then
            local chances = (x.chance) * pokeballs[item.itemid].multiplier * catchRate
            if chances == 0 then
                doPlayerSendCancel(cid, txt[8])
                return TRUE
            end
            
            if math.random(1, 940) <= chances then
                doAddBrokeCount(cid, item.itemid, i)
                doSendDistanceShoot(frompos, topos, pokeballs[item.itemid].shootEffect)
                doSendMagicEffect(topos, pokeballs[item.itemid].successEffect)
                addEvent(onCapturePokemon, time*1000, cid, i, {pokeball = getPokeballIn(item.itemid), sex = getItemAttribute(item2.uid, "corpsesex") }, item.itemid)
                --doEndCount(cid, item.itemid, i)
            else
                doSendDistanceShoot(frompos, topos, pokeballs[item.itemid].shootEffect)
                doSendMagicEffect(topos, pokeballs[item.itemid].failEffect)
                addEvent(onFailCapturePokemon, time*1000, cid)
                
                if getPlayerGroupId(cid) >= 4 and getPlayerGroupId(cid) <= 6 then
                end
            end
            
            doRemoveItem(item.uid, 1)
            doRemoveItem(item2.uid, 1)
            return TRUE
        end
    end
    
    doPlayerSendCancel(cid, txt[9])
    return TRUE
end

local ballsw = {
[PORTUGUESE] = {"Voce gastou ", "para capturar esse pokemon."},
[ENGLISH] = {"You used ", "to catch it."}
}
local ea = {
[PORTUGUESE] = "e ",
[ENGLISH] = "and ",
}
-- 2001 é abra | 2304 é Wanted Farfetch'd.
-- A cada pokemon novo, adicionar o próximo numero.


function doAddBrokeCount(cid, ballid, pokemon)
local pbb = {9271, 2149}
local gbb = {2147}
local sbb = {2150}
local ubb = {2146, 4758}
local sfbb = {2151}
local sto = pokes[pokemon].sto
local toset = "nb = 0, gb = 0, sb = 0, sfb = 0, ub = 0;"
local toget = "nb = (.-), gb = (.-), sb = (.-), sfb = (.-), ub = (.-);"
if getPlayerStorageValue(cid, sto) == -1 then
setPlayerStorageValue(cid, sto, toset)
end

local b = string.gmatch(getPlayerStorageValue(cid, sto), toget)
local nc = ""
for nb, gb, sb, sfb, ub in (b) do
if isInArray(pbb, ballid) then
nc = "nb = "..(tonumber(nb)+1)..", gb = "..gb..", sb = "..sb..", sfb = "..sfb..", ub = "..ub..";"
break
elseif isInArray(gbb, ballid) then
nc = "nb = "..nb..", gb = "..(tonumber(gb) + 1)..", sb = "..sb..", sfb = "..sfb..", ub = "..ub..";"
break
elseif isInArray(sbb, ballid) then
nc = "nb = "..nb..", gb = "..gb..", sb = "..(tonumber(sb) + 1)..", sfb = "..sfb..", ub = "..ub..";"
break
elseif isInArray(ubb, ballid) then
nc = "nb = "..nb..", gb = "..gb..", sb = "..sb..", sfb = "..sfb..", ub = "..(tonumber(ub) + 1)..";"
break
elseif isInArray(sfbb, ballid) then
nc = "nb = "..nb..", gb = "..gb..", sb = "..sb..", sfb = "..(tonumber(sfb) + 1)..", ub = "..ub..";"
break
end
end
setPlayerStorageValue(cid, sto, nc)
return true
end

function doEndCount(cid, ballid, name)
local sto = pokes[name].sto
    local toget = "nb = (.-), gb = (.-), sb = (.-), sfb = (.-), ub = (.-);"
    local str = ""
    local b = getPlayerStorageValue(cid, sto)
    
    if b == -1 or b == -2 or not b then 
        doAddBrokeCount(cid, ballid,name) 
    end
    
local wast = {
nbs = 0,
gbs = 0,
sbs = 0,
ubs = 0,
sfbs = 0,
}

local str = ""

for nb, gb, sb, sfb, ub in (b:gmatch(toget)) do
    wast.nbs = (tonumber(nb) > 0 and (tonumber(nb) == 1 and tonumber(nb).." poke ball " or tonumber(nb).." poke balls ")) or ""
    wast.gbs = (tonumber(gb) > 0 and (tonumber(nb) == 1 and tonumber(gb).." great ball " or tonumber(gb).." great balls ")) or ""
    wast.sbs = (tonumber(sb) > 0 and (tonumber(sb) == 1 and tonumber(sb).." super ball " or tonumber(sb).." super balls ")) or ""
    wast.ubs = (tonumber(ub) > 0 and (tonumber(ub) == 1 and tonumber(ub).." ultra ball " or tonumber(ub).." ultra balls ")) or ""
    wast.sfbs = (tonumber(sfb) > 0 and (tonumber(sfb) == 1 and tonumber(sfb).." saffari ball " or tonumber(sfb).." saffari balls ")) or ""
    
    local aand = (wast.nbs ~= "" or wast.gbs ~= "" or wast.sfbs ~= "" or wast.sbs ~= "" or wast.sbs ~= "") and wast.ubs ~= ""
    local sfbv = (wast.nbs ~= "" or wast.gbs ~= "") and wast.sfbs ~= ""
    local sbv = (wast.nbs ~= "" or wast.gbs ~= "" or wast.sfbs ~= "") and wast.sbs ~= ""
    local gbv = (wast.nbs ~= "") and wast.gbs ~= ""
    
    str = ((wast.nbs)..(gbv and wast.gbs ~= "" and ", " or "")..(wast.gbs)..(sfbv and wast.sfbs~="" and ", " or "").. (wast.sfbs) ..(sbv and wast.sbs ~= "" and ", " or "")..(wast.sbs)..(aand and ea[getPlayerLanguage(cid)] or "")..(wast.ubs))
end

doPlayerSendTextMessage(cid, 20, (ballsw[getPlayerLanguage(cid)][1])..(str)..(ballsw[getPlayerLanguage(cid)][2]))
setPlayerStorageValue(cid, sto, -1)
return true
end

 

Se der algum problema ou erro me avisa.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...