Ir para conteúdo

Featured Replies

Postado
  • Autor
9 horas atrás, Nolangg disse:


tenta assim agora:

 



function onCastSpell(cid, var)
    local storage = 55512 
    local storage2 = 55513 -- Exhaust
    local waittimes = {30, 30, 40, 50, 60} 
    local waittime3 = 310 

    if not isCreature(cid) or exhaustion.check(cid, storage2) then
        doPlayerSendCancel(cid, "Aguarde " .. (exhaustion.get(cid, storage2) or 0) .. " segundos para usar a spell novamente.")
        return false
    end

    if getPlayerStorageValue(cid, storage) > 0 then
        doPlayerSendCancel(cid, "Você já está sob o efeito da spell.")
        return false
    end

    setPlayerStorageValue(cid, storage, 1)
    exhaustion.set(cid, storage2, waittime3)
    OpenGate(cid, Select_Stages(getCreatureOutfit(cid).lookType), 1)

    local function advanceStage()
        if not isCreature(cid) then
            return false
        end

        local stage = getPlayerStorageValue(cid, storage)
        if stage and stage < #waittimes then
            stage = stage + 1
            setPlayerStorageValue(cid, storage, stage)
            addEvent(advanceStage, waittimes[stage] * 1000)
        else
            setPlayerStorageValue(cid, storage, -1) -- Reseta a storage ao final dos estágios
        end
    end

    addEvent(advanceStage, waittimes[1] * 1000)

    addEvent(function()
        if isCreature(cid) then
            setPlayerStorageValue(cid, storage, -1)
        end
    end, (waittimes[#waittimes] + waittimes[1]) * 1000)

    return true
end


caso apareça algum erro retorne aqui.

[01/09/2024 01:19:01] [Error - Spell Interface] 
[01/09/2024 01:19:01] In a timer event called from: 
[01/09/2024 01:19:01] data/spells/scripts/maito gai/hachimon_tonkou.lua:onCastSpell
[01/09/2024 01:19:01] Description: 
[01/09/2024 01:19:01] data/spells/scripts/maito gai/hachimon_tonkou.lua:211: attempt to perform arithmetic on field '?' (a nil value)
[01/09/2024 01:19:01] stack traceback:
[01/09/2024 01:19:01]     data/spells/scripts/maito gai/hachimon_tonkou.lua:211: in function <data/spells/scripts/maito gai/hachimon_tonkou.lua:202>

 

surge o erro quando esta quase no final da spell

Editado por Gabrielxxxxx (veja o histórico de edições)

  • Respostas 11
  • Visualizações 1.9k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Boa noite @Gabrielxxxxx, essa função advanceStage é chamada algumas vezes num intervalo de tempo e ela tenta setar a storage no player, se ele estiver deslogado vai dar esse erro, pois o servidor não

  • O que o rapaz acima falou pode ser usado também. mas, teste assim também:   function onCastSpell(cid, var) local storage = 55512 local storage2 = 55513 -- Exhaust local waittimes

  • ta faltando stopEvent(eventName) ao deslogar  

Postado

ta faltando stopEvent(eventName) ao deslogar

 

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

Postado
  • Autor
19 horas atrás, L3K0T disse:

ta faltando stopEvent(eventName) ao deslogar

 

não consegui de nenhum jeito, consegue dar uma força no script lekot?

Postado
function onCastSpell(cid, var)
    if not isCreature(cid) then
        return false
    end

    local storage, storage2 = 55512, 55513
    local stage = getPlayerStorageValue(cid, storage) or 0
    local waittimes = {30, 30, 40, 50, 60}
    local waittime3 = 310

    if exhaustion.check(cid, storage2) then
        doPlayerSendCancel(cid, "Aguarde " .. exhaustion.get(cid, storage2) .. " segundos para usar a spell novamente.")
        return false
    end

    if stage > 0 then
        doPlayerSendCancel(cid, "Você já está sob o efeito da spell.")
        return false
    end

    setPlayerStorageValue(cid, storage, 1)

    local function advanceStage()
        if not isCreature(cid) then
            return
        end

        local currentStage = getPlayerStorageValue(cid, storage)
        if currentStage < #waittimes then
            setPlayerStorageValue(cid, storage, currentStage + 1)
            addEvent(advanceStage, waittimes[currentStage + 1] * 1000)
        else
            setPlayerStorageValue(cid, storage, -1)
        end
    end

    addEvent(advanceStage, waittimes[1] * 1000)


    exhaustion.set(cid, storage2, waittime3)
    OpenGate(cid, Select_Stages(getCreatureOutfit(cid).lookType), 1)


    addEvent(function()
        if isCreature(cid) then
            setPlayerStorageValue(cid, storage, -1)
        end
    end, waittimes[1] * 1000)

    return true
end

 

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

Postado
  • Autor
18 horas atrás, L3K0T disse:




function onCastSpell(cid, var)
    if not isCreature(cid) then
        return false
    end

    local storage, storage2 = 55512, 55513
    local stage = getPlayerStorageValue(cid, storage) or 0
    local waittimes = {30, 30, 40, 50, 60}
    local waittime3 = 310

    if exhaustion.check(cid, storage2) then
        doPlayerSendCancel(cid, "Aguarde " .. exhaustion.get(cid, storage2) .. " segundos para usar a spell novamente.")
        return false
    end

    if stage > 0 then
        doPlayerSendCancel(cid, "Você já está sob o efeito da spell.")
        return false
    end

    setPlayerStorageValue(cid, storage, 1)

    local function advanceStage()
        if not isCreature(cid) then
            return
        end

        local currentStage = getPlayerStorageValue(cid, storage)
        if currentStage < #waittimes then
            setPlayerStorageValue(cid, storage, currentStage + 1)
            addEvent(advanceStage, waittimes[currentStage + 1] * 1000)
        else
            setPlayerStorageValue(cid, storage, -1)
        end
    end

    addEvent(advanceStage, waittimes[1] * 1000)


    exhaustion.set(cid, storage2, waittime3)
    OpenGate(cid, Select_Stages(getCreatureOutfit(cid).lookType), 1)


    addEvent(function()
        if isCreature(cid) then
            setPlayerStorageValue(cid, storage, -1)
        end
    end, waittimes[1] * 1000)

    return true
end

 

vai chegando no final da spell da esse erro não consigo identificar ele no script

 

a spell funciona perfeitamente e quando esta deslogado não da mais erros na distro, porem da esse erro na distro no finalzinho da spell enquanto o player esta online com a spell em andamento...

 

[09/09/2024 09:11:44] [Error - Spell Interface] 
[09/09/2024 09:11:44] In a timer event called from: 
[09/09/2024 09:11:44] data/spells/scripts/maito gai/hachimon_tonkou.lua:onCastSpell
[09/09/2024 09:11:44] Description: 
[09/09/2024 09:11:44] data/spells/scripts/maito gai/hachimon_tonkou.lua:212: attempt to perform arithmetic on field '?' (a nil value)
[09/09/2024 09:11:44] stack traceback:
[09/09/2024 09:11:44]     data/spells/scripts/maito gai/hachimon_tonkou.lua:212: in function <data/spells/scripts/maito gai/hachimon_tonkou.lua:204>

 

acabei de ver tambem que as storage que a spell daria não estão corretas, o primeiro stage seta a storage 1 porem o resto seta a storage 0, o certo seria a sequencia 1,2,3,4, e 5

Editado por Gabrielxxxxx
informaçoes (veja o histórico de edições)

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.8k

Informação Importante

Confirmação de Termo