JU
tfs 0.3.6

Ajuda com NPC e CreatureEvents TASK

Por julhinhuu, 05 de set. de 2015 em Scripts

0.3.6
otserv
25
2.6k
zipter98Z
08 de setembro de 2015 às 21:11

Sim, o que me leva a indagar do porquê não tem aparecido erro algum na distro. É sempre informado no console quando uma variável inexistente é declarada. Mesmo assim, a storage responsável por armazenar os dados da task é ainda alterada.

julhinhuuJ
09 de setembro de 2015 às 00:42

Mds, tenho muito o que aprender mesmo em scripts hehe não entendi nada ?, então quando chegar em casa vou testar os scripts alterados do creatureevents e tiro a print se caso der algum erro na distro.

 

Por gentileza, informe se alguma mensagem é imprimida na distro. Assim, saberemos onde exatamente se encontra o erro.

local function isSummon(cid)
    if not isCreature(cid) then return false end
    if getCreatureMaster(cid) ~= cid then
        return true
    end
    return false
end
 
function onDeath(cid, corpse, deathList)
 
    print("Script sendo executado.")
    local stoTime = 96586
    local stoKill = 96587
    local stoName = 96587
    local task = {
        ["dragon"] = {kill = "Dragon", qnt = 1500, exp = 1000000},
        ["dragon lord"] = {kill = "Dragon Lord", qnt = 1000, exp = 800000},
        ["hydra"] = {kill = "Hydra", qnt = 800, exp = 700000},
        ["frost dragon"] = {kill = "Frost Dragon", qnt = 600, exp = 500000},
        ["dragon guardian"] = {kill = "Dragon Guardian", qnt = 500, exp = 400000},
        ["thunder dragon"] = {kill = "Thunder Dragon", qnt = 400, exp = 300000},
        ["multi"] = {kill = "Multi", qnt = 600, exp = 200000},
        ["demodras"] = {kill = "Demodras", qnt = 300, exp = 200000},
    }
 
    for a = 1, #deathList do
        print("Loop iterando jogadores sendo executado.")
        local pk = deathList[a]
        local myTask = task[string.lower(getPlayerStorageValue(pk, stoName))]
        local left = math.ceil((getPlayerStorageValue(pk, stoTime) - os.time())/(24 * 60 * 60))
 
        if myTask and getCreatureName(cid) == getPlayerStorageValue(pk, stoName) and not isSummon(cid) then
            print("Primeira condição sendo executada.")
            if left > 0 and getPlayerStorageValue(pk, stoKill) > 0 then
                print("Segunda condição sendo executada.")
                setPlayerStorageValue(pk, stoKill, getPlayerStorageValue(pk, stoKill) - 1)
                local sto = getPlayerStorageValue(pk, stoKill)
                local jaMatou = math.abs(getPlayerStorageValue(pk, stoKill)-myTask.qntdade)
 
                if sto == 0 then
                    doPlayerSendTextMessage(pk, 22, "["..myTask.kill.." Task Finalizada] ("..myTask.qntdade.."/"..myTask.qnt..")")
                else
                    doPlayerSendTextMessage(pk, 22, "["..myTask.kill.." Task] ("..jaMatou.."/"..myTask.qntdade..")")
                end
            end
        end
    end
    return true
end

@Zipter98

Apareceu isso:

 

post-321783-0-03507000-1441770095_thumb.png

 

zipter98Z
09 de setembro de 2015 às 14:27

OK, já sabemos onde o erro está. Agora, veremos qual é o erro.

 

local function isSummon(cid)
    if not isCreature(cid) then return false end
    if getCreatureMaster(cid) ~= cid then
        return true
    end
    return false
end
 
function onDeath(cid, corpse, deathList)
 
    local stoTime = 96586
    local stoKill = 96587
    local stoName = 96587
    local task = {
        ["dragon"] = {kill = "Dragon", qnt = 1500, exp = 1000000},
        ["dragon lord"] = {kill = "Dragon Lord", qnt = 1000, exp = 800000},
        ["hydra"] = {kill = "Hydra", qnt = 800, exp = 700000},
        ["frost dragon"] = {kill = "Frost Dragon", qnt = 600, exp = 500000},
        ["dragon guardian"] = {kill = "Dragon Guardian", qnt = 500, exp = 400000},
        ["thunder dragon"] = {kill = "Thunder Dragon", qnt = 400, exp = 300000},
        ["multi"] = {kill = "Multi", qnt = 600, exp = 200000},
        ["demodras"] = {kill = "Demodras", qnt = 300, exp = 200000},
    }
 
    for a = 1, #deathList do
        local pk = deathList[a]
        local myTask = task[string.lower(getPlayerStorageValue(pk, stoName))]
        local left = math.ceil((getPlayerStorageValue(pk, stoTime) - os.time())/(24 * 60 * 60))
        
        print(myTask or "Task não existente: "..getPlayerStorageValue(pk, stoName))
        print("Task do jogador "..getPlayerStorageValue(pk, stoName))
        print("Nome do monstro: "..getCreatureName(cid))
        if myTask and getCreatureName(cid) == getPlayerStorageValue(pk, stoName) and not isSummon(cid) then
            print("Primeira condição sendo executada.")
            if left > 0 and getPlayerStorageValue(pk, stoKill) > 0 then
                print("Segunda condição sendo executada.")
                setPlayerStorageValue(pk, stoKill, getPlayerStorageValue(pk, stoKill) - 1)
                local sto = getPlayerStorageValue(pk, stoKill)
                local jaMatou = math.abs(getPlayerStorageValue(pk, stoKill)-myTask.qntdade)
 
                if sto == 0 then
                    doPlayerSendTextMessage(pk, 22, "["..myTask.kill.." Task Finalizada] ("..myTask.qntdade.."/"..myTask.qnt..")")
                else
                    doPlayerSendTextMessage(pk, 22, "["..myTask.kill.." Task] ("..jaMatou.."/"..myTask.qntdade..")")
                end
            end
        end
    end
    return true
end
julhinhuuJ
09 de setembro de 2015 às 14:34

 

OK, já sabemos onde o erro está. Agora, veremos qual é o erro.

local function isSummon(cid)
    if not isCreature(cid) then return false end
    if getCreatureMaster(cid) ~= cid then
        return true
    end
    return false
end
 
function onDeath(cid, corpse, deathList)
 
    local stoTime = 96586
    local stoKill = 96587
    local stoName = 96587
    local task = {
        ["dragon"] = {kill = "Dragon", qnt = 1500, exp = 1000000},
        ["dragon lord"] = {kill = "Dragon Lord", qnt = 1000, exp = 800000},
        ["hydra"] = {kill = "Hydra", qnt = 800, exp = 700000},
        ["frost dragon"] = {kill = "Frost Dragon", qnt = 600, exp = 500000},
        ["dragon guardian"] = {kill = "Dragon Guardian", qnt = 500, exp = 400000},
        ["thunder dragon"] = {kill = "Thunder Dragon", qnt = 400, exp = 300000},
        ["multi"] = {kill = "Multi", qnt = 600, exp = 200000},
        ["demodras"] = {kill = "Demodras", qnt = 300, exp = 200000},
    }
 
    for a = 1, #deathList do
        local pk = deathList[a]
        local myTask = task[string.lower(getPlayerStorageValue(pk, stoName))]
        local left = math.ceil((getPlayerStorageValue(pk, stoTime) - os.time())/(24 * 60 * 60))
        
        print(myTask or "Task não existente: "..getPlayerStorageValue(pk, stoName))
        print("Task do jogador "..getPlayerStorageValue(pk, stoName))
        print("Nome do monstro: "..getCreatureName(cid))
        if myTask and getCreatureName(cid) == getPlayerStorageValue(pk, stoName) and not isSummon(cid) then
            print("Primeira condição sendo executada.")
            if left > 0 and getPlayerStorageValue(pk, stoKill) > 0 then
                print("Segunda condição sendo executada.")
                setPlayerStorageValue(pk, stoKill, getPlayerStorageValue(pk, stoKill) - 1)
                local sto = getPlayerStorageValue(pk, stoKill)
                local jaMatou = math.abs(getPlayerStorageValue(pk, stoKill)-myTask.qntdade)
 
                if sto == 0 then
                    doPlayerSendTextMessage(pk, 22, "["..myTask.kill.." Task Finalizada] ("..myTask.qntdade.."/"..myTask.qnt..")")
                else
                    doPlayerSendTextMessage(pk, 22, "["..myTask.kill.." Task] ("..jaMatou.."/"..myTask.qntdade..")")
                end
            end
        end
    end
    return true
end

Então aparece isso:

 

[09/09/2015 14:29:57] Task não existente: -1

[09/09/2015 14:29:57] Task do jogador -1

[09/09/2015 14:29:57] Nome do monstro: dragon guardian

 

 

zipter98Z
09 de setembro de 2015 às 14:43
No código do NPC, troque:
local stoTime = 96588
local stoKill = 96589
local stoName = 96590
por:
local stoTime = 96586
local stoKill = 96585
local stoName = 96587

E, para evitar futuros erros, troque seu creatureevent por este:

local function isSummon(cid)
    if not isCreature(cid) then return false end
    if getCreatureMaster(cid) ~= cid then
        return true
    end
    return false
end
 
function onDeath(cid, corpse, deathList)
 
    local stoTime = 96586
    local stoKill = 96585
    local stoName = 96587
    local task = {
        ["dragon"] = {kill = "Dragon", qnt = 1500, exp = 1000000},
        ["dragon lord"] = {kill = "Dragon Lord", qnt = 1000, exp = 800000},
        ["hydra"] = {kill = "Hydra", qnt = 800, exp = 700000},
        ["frost dragon"] = {kill = "Frost Dragon", qnt = 600, exp = 500000},
        ["dragon guardian"] = {kill = "Dragon Guardian", qnt = 500, exp = 400000},
        ["thunder dragon"] = {kill = "Thunder Dragon", qnt = 400, exp = 300000},
        ["multi"] = {kill = "Multi", qnt = 600, exp = 200000},
        ["demodras"] = {kill = "Demodras", qnt = 300, exp = 200000},
    }
 
    for a = 1, #deathList do
        local pk = deathList[a]
        local myTask = task[string.lower(getPlayerStorageValue(pk, stoName))]
        local left = math.ceil((getPlayerStorageValue(pk, stoTime) - os.time())/(24 * 60 * 60))
        
        if myTask and getCreatureName(cid) == getPlayerStorageValue(pk, stoName) and not isSummon(cid) then
            if left > 0 and getPlayerStorageValue(pk, stoKill) > 0 then
                setPlayerStorageValue(pk, stoKill, getPlayerStorageValue(pk, stoKill) - 1)
                local sto = getPlayerStorageValue(pk, stoKill)
                local jaMatou = math.abs(getPlayerStorageValue(pk, stoKill)-myTask.qnt)
 
                if sto == 0 then
                    doPlayerSendTextMessage(pk, 22, "["..myTask.kill.." Task Finalizada] ("..myTask.qnt.."/"..myTask.qnt..")")
                else
                    doPlayerSendTextMessage(pk, 22, "["..myTask.kill.." Task] ("..jaMatou.."/"..myTask.qnt..")")
                end
            end
        end
    end
    return true
end

 

Editado Setembro 10 por zipter98

julhinhuuJ
09 de setembro de 2015 às 20:06

 

No código do NPC, troque:
local stoTime = 96588
local stoKill = 96589
local stoName = 96590
por:
local stoTime = 96586
local stoKill = 96587
local stoName = 96587

E, para evitar futuros erros, troque seu creatureevent por este:

local function isSummon(cid)
    if not isCreature(cid) then return false end
    if getCreatureMaster(cid) ~= cid then
        return true
    end
    return false
end
 
function onDeath(cid, corpse, deathList)
 
    local stoTime = 96586
    local stoKill = 96587
    local stoName = 96587
    local task = {
        ["dragon"] = {kill = "Dragon", qnt = 1500, exp = 1000000},
        ["dragon lord"] = {kill = "Dragon Lord", qnt = 1000, exp = 800000},
        ["hydra"] = {kill = "Hydra", qnt = 800, exp = 700000},
        ["frost dragon"] = {kill = "Frost Dragon", qnt = 600, exp = 500000},
        ["dragon guardian"] = {kill = "Dragon Guardian", qnt = 500, exp = 400000},
        ["thunder dragon"] = {kill = "Thunder Dragon", qnt = 400, exp = 300000},
        ["multi"] = {kill = "Multi", qnt = 600, exp = 200000},
        ["demodras"] = {kill = "Demodras", qnt = 300, exp = 200000},
    }
 
    for a = 1, #deathList do
        local pk = deathList[a]
        local myTask = task[string.lower(getPlayerStorageValue(pk, stoName))]
        local left = math.ceil((getPlayerStorageValue(pk, stoTime) - os.time())/(24 * 60 * 60))
        
        if myTask and getCreatureName(cid) == getPlayerStorageValue(pk, stoName) and not isSummon(cid) then
            if left > 0 and getPlayerStorageValue(pk, stoKill) > 0 then
                setPlayerStorageValue(pk, stoKill, getPlayerStorageValue(pk, stoKill) - 1)
                local sto = getPlayerStorageValue(pk, stoKill)
                local jaMatou = math.abs(getPlayerStorageValue(pk, stoKill)-myTask.qnt)
 
                if sto == 0 then
                    doPlayerSendTextMessage(pk, 22, "["..myTask.kill.." Task Finalizada] ("..myTask.qnt.."/"..myTask.qnt..")")
                else
                    doPlayerSendTextMessage(pk, 22, "["..myTask.kill.." Task] ("..jaMatou.."/"..myTask.qnt..")")
                end
            end
        end
    end
    return true
end

 

ERRO zipter98, quando pego a task ta tudo bem mais ainda não conta os monstros, quando volto para falar com npc da o erro.

 

post-321783-0-26691500-1441855420_thumb.png

Editado Setembro 10 por julhinhokullitz

zipter98Z
10 de setembro de 2015 às 11:44

É, imaginei que isso fosse acontecer. Editei meu comentário anterior com as correções (tanto na modificação do NPC quanto no creatureevent).

Editado Setembro 10 por zipter98

julhinhuuJ
14 de setembro de 2015 às 19:47

É, imaginei que isso fosse acontecer. Editei meu comentário anterior com as correções (tanto na modificação do NPC quanto no creatureevent).

 

11:56 Kahn: Você ainda não matou os 500 Dragon Guardian, atualmente você matou 0, resta 500. Seu prazo é de até 17/09/15 11:56:14.

 

Matei 4, não conta da mesma forma, mas dessa vez nenhum erro na distro.

Up

UP

UP

Editado Setembro 10 por julhinhokullitz

julhinhuuJ
18 de setembro de 2015 às 16:08

Up please. :(

1 mês depois...
LumusL
26 de outubro de 2015 às 23:21

Tópico Movido
Este tópico foi movido de "OTServSuporte OTServSuporte Scripting"
para "OTServSuporte OTServSuporte ScriptingPedidos e dúvidas resolvidos - Scripting".