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

TFS 1.X+ task system by limos, bug request another task

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
921
Location
Chile
Hello guys!!

i have been trying to fix this thing but i can't get the reason why is this npc working so strange, this is the problem:

when a player takes the task "God", it counts the 200 gods killed, fine there, but when the task is ready, the npc asks for the hellish rhino task D:

i check the storage values but they are correct :/ so idk what could be the problem :S

probably is something really stupid but i can't find it!!

this is the npc
Lua:
-- Monster Tasks by Limos
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local xmsg = {}
function onCreatureAppear(cid)  npcHandler:onCreatureAppear(cid)  end
function onCreatureDisappear(cid)  npcHandler:onCreatureDisappear(cid)  end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg)  end
function onThink()  npcHandler:onThink()  end
local storage = 62010
local monsters = {
   ["Hellish Rhino"] = {storage = 12244, mstorage = 19023, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}},
   ["God"] = {storage = 22245, mstorage = 29024, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}},
   ["Dragon Infernal"] = {storage = 12246, mstorage = 19025, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}},
   ["Dark Cucka"] = {storage = 12247, mstorage = 19026, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}},
   ["Wailing Widow"] = {storage = 12248, mstorage = 19027, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}}
}
local function getItemsFromTable(itemtable)
     local text = ""
     for v = 1, #itemtable do
         count, info = itemtable[v].count, ItemType(itemtable[v].id)
         local ret = ", "
         if v == 1 then
             ret = ""
         elseif v == #itemtable then
             ret = " and "
         end
         text = text .. ret
         text = text .. (count > 1 and count or info:getArticle()).." "..(count > 1 and info:getPluralName() or info:getName())
     end
     return text
end
local function Cptl(f, r)
     return f:upper()..r:lower()
end
function creatureSayCallback(cid, type, msg)
     local player, cmsg = Player(cid), msg:gsub("(%a)([%w_']*)", Cptl)
     if not npcHandler:isFocused(cid) then
         if msg == "hi" or msg == "hello" then
             npcHandler:addFocus(cid)
             if player:getStorageValue(storage) == -1 then
                 local text, n = "",  0
                 for k, x in pairs(monsters) do
                     if player:getStorageValue(x.mstorage) < x.amount then
                         n = n + 1
                         text = text .. ", "
                         text = text .. ""..x.amount.." {"..k.."}"
                     end
                 end
                 if n > 1 then
                     npcHandler:say("Hola hola, veo que ya eres rebirth 5, muy bien! Tengo algunas misiones que tendras que hacer para seguir avanzando, derrota"..text..".", cid)
                     npcHandler.topic[cid] = 1
                     xmsg[cid] = msg
                 elseif n == 1 then
                     npcHandler:say("M"..text..".", cid)
                     npcHandler.topic[cid] = 1
                 else
                     npcHandler:say("Ya lo derrotaste, muchas gracias!", cid)
                 end
             elseif player:getStorageValue(storage) == 1 then
                 for k, x in pairs(monsters) do
                     if player:getStorageValue(x.storage) == 1 then
                         npcHandler:say("Mataste ya "..x.amount.." "..k.."?", cid)
                         npcHandler.topic[cid] = 2
                         xmsg[cid] = k
                     end
                 end
             end
         else
             return false
         end
     elseif monsters[cmsg] and npcHandler.topic[cid] == 1 then
         if player:getStorageValue(monsters[cmsg].storage) == -1 then
             npcHandler:say("Buena suerte! Vuelve cuando hayas matado "..monsters[cmsg].amount.." "..cmsg..".", cid)
             player:setStorageValue(storage, 1)
             player:setStorageValue(monsters[cmsg].storage, 1)
         else
             npcHandler:say("Ya hiciste la "..cmsg.." mission.", cid)
         end
         npcHandler.topic[cid] = 0
     elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
         local x = monsters[xmsg[cid]]
         if player:getStorageValue(x.mstorage) >= x.amount then
             npcHandler:say("Muy bien, aqui esta tu recompensa, "..getItemsFromTable(x.items)..".", cid)
             for g = 1, #x.items do
                 player:addItem(x.items[g].id, x.items[g].count)
             end
             player:addExperience(x.exp)
             player:setStorageValue(x.storage, 2)
             player:setStorageValue(storage, -1)
             npcHandler.topic[cid] = 3
         else
             npcHandler:say("No lo has matado aun, te falta "..x.amount -(player:getStorageValue(x.mstorage) + 1).." "..xmsg[cid]..".", cid)
         end
     elseif msgcontains(msg, "task") and npcHandler.topic[cid] == 3 then
         local text, n = "",  0
         for k, x in pairs(monsters) do
             if player:getStorageValue(x.mstorage) < x.amount then
                 n = n + 1
                 text = text .. (n == 1 and "" or ", ")
                 text = text .. "{"..k.."}"
             end
         end
         if text ~= "" then
             npcHandler:say("Quieres hacer otra task? Puedes elegir "..text..".", cid)
             npcHandler.topic[cid] = 1
         else
             npcHandler:say("Ya hiciste todas las task.", cid)
         end
     elseif msgcontains(msg, "no") and npcHandler.topic[cid] == 1 then
         npcHandler:say("Ok then.", cid)
         npcHandler.topic[cid] = 0
     elseif msgcontains(msg, "stop") then
         local text, n = "",  0
         for k, x in pairs(monsters) do
             if player:getStorageValue(x.mstorage) < x.amount then
                 n = n + 1
                 text = text .. (n == 1 and "" or ", ")
                 text = text .. "{"..k.."}"
                 if player:getStorageValue(x.storage) == 1 then
                      player:setStorageValue(x.storage, -1)
                 end
             end
         end
         if player:getStorageValue(storage) == 1 then
             npcHandler:say("Ok, dime si quieres continuar otra task, todavia puedes elegir "..text..".", cid)
         else
             npcHandler:say("No empezaste ninguna nueva task, si quieres empezar una, puedes elegir "..text..".", cid)
         end
         player:setStorageValue(storage, -1)
         npcHandler.topic[cid] = 1
     elseif msgcontains(msg, "list") then
         local text = "Tasks\n\n"
         for k, x in pairs(monsters) do
             if player:getStorageValue(x.mstorage) < x.amount then
                 text = text ..k .." ["..(player:getStorageValue(x.mstorage) + 1).."/"..x.amount.."]:\n  Rewards:\n  "..getItemsFromTable(x.items).."\n  "..x.exp.." experience \n\n"
             else
                 text = text .. k .." [DONE]\n"
             end
         end
         player:showTextDialog(1949, "" .. text)
         npcHandler:say("Here you are.", cid)
     elseif msgcontains(msg, "bye") then
         npcHandler:say("Bye.", cid)
         npcHandler:releaseFocus(cid)
     else
         npcHandler:say("Ah?", cid)
     end
     return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

and this is the creaturescript

Code:
local config = {
     ['hellish rhino'] = {amount = 200, storage = 19023, startstorage = 12244, startvalue = 1},
     ['god'] = {amount = 200, storage = 29024, startstorage = 22245, startvalue = 1},
     ['dragon infernal'] = {amount = 200, storage = 19025, startstorage = 12246, startvalue = 1},
     ['dark cucka'] = {amount = 200, storage = 19026, startstorage = 12247, startvalue = 1},
     ['wailing widow'] = {amount = 200, storage = 19027, startstorage = 12248, startvalue = 1}
}
function onKill(player, target)
     local monster = config[target:getName():lower()]
     if target:isPlayer() or not monster or target:getMaster() then
         return true
     end
     local stor = player:getStorageValue(monster.storage)+1
     if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then
         player:setStorageValue(monster.storage, stor)
         player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.')
     end
     if (stor +1) == monster.amount then
         player:sendTextMessage(MESSAGE_INFO_DESCR, 'Felicitaciones, has matado '..(stor +1)..' '..target:getName()..'s y completado la '..target:getName()..'s mission.')
         player:setStorageValue(monster.storage, stor +1)
     end
     return true
end

plz guys help me fix this annoying error :S
 
I've installed the system and tested it, and it worked fine.

The npc script is really messy and bad written. I have to leave right now 'cause its my brothers birthday but i'll be back in 2 hours and I'll re write the script for you.

By messy I mean it has bad logic and repeated logic that can cause it to probably do some things wrong.

My guess to the problem you had is that while testing it you messed up the storages on your character, because the script doesn't handle that very well.

When I'm back i'll rewrite it and post it here if no one has done already.

edit:

Lua:
-- Monster Tasks by Limos
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local xmsg = {}
function onCreatureAppear(cid)  npcHandler:onCreatureAppear(cid)  end
function onCreatureDisappear(cid)  npcHandler:onCreatureDisappear(cid)  end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg)  end
function onThink()  npcHandler:onThink()  end


local storage = 62010
local monsters = {
   ["Hellish Rhino"] = {storage = 12244, mstorage = 19023, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}},
   ["God"] = {storage = 22245, mstorage = 29024, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}},
   ["Dragon Infernal"] = {storage = 12246, mstorage = 19025, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}},
   ["Dark Cucka"] = {storage = 12247, mstorage = 19026, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}},
   ["Wailing Widow"] = {storage = 12248, mstorage = 19027, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}}
}
local function getItemsFromTable(itemtable)
     local text = ""
     for v = 1, #itemtable do
         count, info = itemtable[v].count, ItemType(itemtable[v].id)
         local ret = ", "
         if v == 1 then
             ret = ""
         elseif v == #itemtable then
             ret = " and "
         end
         text = text .. ret
         text = text .. (count > 1 and count or info:getArticle()).." "..(count > 1 and info:getPluralName() or info:getName())
     end
     return text
end

local function Cptl(f, r)
     return f:upper()..r:lower()
end

local function getTasks(cid)
    local text, n, player = "", 0, Player(cid)
    for k, x in pairs(monsters) do
      if player:getStorageValue(x.mstorage) < x.amount then
            n = n + 1
            text = text .. ", "
            text = text .. ""..x.amount.." {"..k.."}"
        end
    end
    return {text, n}
end

local function stopTasks(cid)
    local text, n, player = "", 0,  Player(cid)
    for k, x in pairs(monsters) do
        if player:getStorageValue(x.mstorage) < x.amount then
            n = n + 1
              text = text .. (n == 1 and "" or ", ")
              text = text .. "{"..k.."}"
              if player:getStorageValue(x.storage) == 1 then
                player:setStorageValue(x.storage, -1)
              end
        end
    end
    return {text, n}  
end

local function getActualTask(cid)
    local name, amount, player = "", 0, Player(cid)
    for k, x in pairs(monsters) do
        if player:getStorageValue(x.storage) == 1 then
            name = k
            amount = x.amount
        end
    end
    return {name, amount}
end

function creatureSayCallback(cid, type, msg)
    local player, cmsg = Player(cid), msg:gsub("(%a)([%w_']*)", Cptl)
    if not npcHandler:isFocused(cid) then
    if msg == "hi" or msg == "hello" then
        npcHandler:addFocus(cid)
        if player:getStorageValue(storage) == -1 then
            local tasks = getTasks(cid)
            local text, n = tasks[1], tasks[2]
            if n > 1 then
                npcHandler:say("Hola hola, veo que ya eres rebirth 5, muy bien! Tengo algunas misiones que tendras que hacer para seguir avanzando, derrota"..text..".", cid)
                npcHandler.topic[cid] = 1
                xmsg[cid] = msg
            elseif n == 1 then
                npcHandler:say("M"..text..".", cid)
                npcHandler.topic[cid] = 1
            else
                npcHandler:say("Ya lo derrotaste, muchas gracias!", cid)
            end
        elseif player:getStorageValue(storage) == 1 then
            local actual = getActualTask(cid)
            npcHandler:say("Mataste ya "..actual[2].." "..actual[1].."?", cid)
            npcHandler.topic[cid] = 2
            xmsg[cid] = actual[1]
        end
    else
        return false
    end
    elseif monsters[cmsg] and npcHandler.topic[cid] == 1 then
        if player:getStorageValue(monsters[cmsg].storage) == -1 then
            npcHandler:say("Buena suerte! Vuelve cuando hayas matado "..monsters[cmsg].amount.." "..cmsg..".", cid)
            player:setStorageValue(storage, 1)
            player:setStorageValue(monsters[cmsg].storage, 1)
            npcHandler.topic[cid] = 0
            xmsg[cid] = nil
        else
            npcHandler:say("Ya hiciste la "..cmsg.." mission.", cid)
            xmsg[cid] = nil
            npcHandler.topic[cid] = 1
        end
    elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
        local x = monsters[xmsg[cid]]
        if player:getStorageValue(x.mstorage) >= x.amount then
            npcHandler:say("Muy bien, aqui esta tu recompensa, "..getItemsFromTable(x.items)..".", cid)
            for g = 1, #x.items do
                player:addItem(x.items[g].id, x.items[g].count)
            end
            player:addExperience(x.exp)
            player:setStorageValue(x.storage, 2)
            player:setStorageValue(storage, -1)
            npcHandler.topic[cid] = 0
            xmsg[cid] = nil
        else
            npcHandler:say("No lo has matado aun, te falta "..x.amount -(player:getStorageValue(x.mstorage) + 1).." "..xmsg[cid]..".", cid)
            npcHandler.topic[cid] = 0
            xmsg[cid] = nil
        end
    elseif msgcontains(msg, "task") then
        if player:getStorageValue(storage) < 0 then
            local tasks = getTasks(cid)
            local text, n = tasks[1], tasks[2]
            if text ~= "" then
                npcHandler:say("Quieres hacer otra task? Puedes elegir "..text..".", cid)
                npcHandler.topic[cid] = 1
            else
                npcHandler:say("Ya hiciste todas las task.", cid)
            end
        else
            local actual = getActualTask(cid)
            npcHandler:say("Usted tiene que matar ".. actual[2] .." " .. actual[1].." antes de hacer otra mission. Listo?", cid)
            npcHandler.topic[cid] = 2
            xmsg[cid] = actual[1]
        end
    elseif msgcontains(msg, "no") then
        npcHandler:say("Ok then.", cid)
        npcHandler.topic[cid] = 0
    elseif msgcontains(msg, "stop") then
        local text, n = "", #monsters
        local result = stopTasks(cid)
        local text, n = result[1], result[2]
        if player:getStorageValue(storage) == 1 then
            npcHandler:say("Ok, dime si quieres continuar otra task, todavia puedes elegir "..text..".", cid)
        else
            npcHandler:say("No empezaste ninguna nueva task, si quieres empezar una, puedes elegir "..text..".", cid)
        end
        player:setStorageValue(storage, -1)
        npcHandler.topic[cid] = 1
    elseif msgcontains(msg, "list") then
        local text = "Tasks\n\n"
        for k, x in pairs(monsters) do
            if player:getStorageValue(x.mstorage) < x.amount then
                text = text ..k .." ["..(player:getStorageValue(x.mstorage) + 1).."/"..x.amount.."]:\n    Rewards:\n      "..getItemsFromTable(x.items).."\n       "..x.exp.." experience \n\n"
            else
                text = text .. k .." [DONE]\n\n"
            end
        end
        player:showTextDialog(1949, "" .. text)
        npcHandler:say("Here you are.", cid)
        npcHandler.topic[cid] = 0
    elseif msgcontains(msg, "bye") then
        npcHandler:say("Bye.", cid)
        npcHandler:releaseFocus(cid)
    else
        npcHandler:say("Ah?", cid)
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)


I haven't changed the structure of the code, I just took some of the loops that creates the NPC phrases to outside functions so it is easier for other ppl who might help you to understand the code.

I changed some of the way the npc works (mainly when reporting a finished mission) and put somethings that were missing (delete xmsg indexes, little beter usage of npchandler.topic etc.)

I still think that the problem you are facing is because you changed your characters value while still in another task. I atleast couldn't reproduce your error.
 
Last edited:
I've installed the system and tested it, and it worked fine.

The npc script is really messy and bad written. I have to leave right now 'cause its my brothers birthday but i'll be back in 2 hours and I'll re write the script for you.

By messy I mean it has bad logic and repeated logic that can cause it to probably do some things wrong.

My guess to the problem you had is that while testing it you messed up the storages on your character, because the script doesn't handle that very well.

When I'm back i'll rewrite it and post it here if no one has done already.

edit:

Lua:
-- Monster Tasks by Limos
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local xmsg = {}
function onCreatureAppear(cid)  npcHandler:onCreatureAppear(cid)  end
function onCreatureDisappear(cid)  npcHandler:onCreatureDisappear(cid)  end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg)  end
function onThink()  npcHandler:onThink()  end


local storage = 62010
local monsters = {
   ["Hellish Rhino"] = {storage = 12244, mstorage = 19023, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}},
   ["God"] = {storage = 22245, mstorage = 29024, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}},
   ["Dragon Infernal"] = {storage = 12246, mstorage = 19025, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}},
   ["Dark Cucka"] = {storage = 12247, mstorage = 19026, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}},
   ["Wailing Widow"] = {storage = 12248, mstorage = 19027, amount = 200, exp = 1000, items = {{id = 28624, count = 1}, {id = 2160, count = 20}}}
}
local function getItemsFromTable(itemtable)
     local text = ""
     for v = 1, #itemtable do
         count, info = itemtable[v].count, ItemType(itemtable[v].id)
         local ret = ", "
         if v == 1 then
             ret = ""
         elseif v == #itemtable then
             ret = " and "
         end
         text = text .. ret
         text = text .. (count > 1 and count or info:getArticle()).." "..(count > 1 and info:getPluralName() or info:getName())
     end
     return text
end

local function Cptl(f, r)
     return f:upper()..r:lower()
end

local function getTasks(cid)
    local text, n, player = "", 0, Player(cid)
    for k, x in pairs(monsters) do
      if player:getStorageValue(x.mstorage) < x.amount then
            n = n + 1
            text = text .. ", "
            text = text .. ""..x.amount.." {"..k.."}"
        end
    end
    return {text, n}
end

local function stopTasks(cid)
    local text, n, player = "", 0,  Player(cid)
    for k, x in pairs(monsters) do
        if player:getStorageValue(x.mstorage) < x.amount then
            n = n + 1
              text = text .. (n == 1 and "" or ", ")
              text = text .. "{"..k.."}"
              if player:getStorageValue(x.storage) == 1 then
                player:setStorageValue(x.storage, -1)
              end
        end
    end
    return {text, n} 
end

local function getActualTask(cid)
    local name, amount, player = "", 0, Player(cid)
    for k, x in pairs(monsters) do
        if player:getStorageValue(x.storage) == 1 then
            name = k
            amount = x.amount
        end
    end
    return {name, amount}
end

function creatureSayCallback(cid, type, msg)
    local player, cmsg = Player(cid), msg:gsub("(%a)([%w_']*)", Cptl)
    if not npcHandler:isFocused(cid) then
    if msg == "hi" or msg == "hello" then
        npcHandler:addFocus(cid)
        if player:getStorageValue(storage) == -1 then
            local tasks = getTasks(cid)
            local text, n = tasks[1], tasks[2]
            if n > 1 then
                npcHandler:say("Hola hola, veo que ya eres rebirth 5, muy bien! Tengo algunas misiones que tendras que hacer para seguir avanzando, derrota"..text..".", cid)
                npcHandler.topic[cid] = 1
                xmsg[cid] = msg
            elseif n == 1 then
                npcHandler:say("M"..text..".", cid)
                npcHandler.topic[cid] = 1
            else
                npcHandler:say("Ya lo derrotaste, muchas gracias!", cid)
            end
        elseif player:getStorageValue(storage) == 1 then
            local actual = getActualTask(cid)
            npcHandler:say("Mataste ya "..actual[2].." "..actual[1].."?", cid)
            npcHandler.topic[cid] = 2
            xmsg[cid] = actual[1]
        end
    else
        return false
    end
    elseif monsters[cmsg] and npcHandler.topic[cid] == 1 then
        if player:getStorageValue(monsters[cmsg].storage) == -1 then
            npcHandler:say("Buena suerte! Vuelve cuando hayas matado "..monsters[cmsg].amount.." "..cmsg..".", cid)
            player:setStorageValue(storage, 1)
            player:setStorageValue(monsters[cmsg].storage, 1)
            npcHandler.topic[cid] = 0
            xmsg[cid] = nil
        else
            npcHandler:say("Ya hiciste la "..cmsg.." mission.", cid)
            xmsg[cid] = nil
            npcHandler.topic[cid] = 1
        end
    elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
        local x = monsters[xmsg[cid]]
        if player:getStorageValue(x.mstorage) >= x.amount then
            npcHandler:say("Muy bien, aqui esta tu recompensa, "..getItemsFromTable(x.items)..".", cid)
            for g = 1, #x.items do
                player:addItem(x.items[g].id, x.items[g].count)
            end
            player:addExperience(x.exp)
            player:setStorageValue(x.storage, 2)
            player:setStorageValue(storage, -1)
            npcHandler.topic[cid] = 0
            xmsg[cid] = nil
        else
            npcHandler:say("No lo has matado aun, te falta "..x.amount -(player:getStorageValue(x.mstorage) + 1).." "..xmsg[cid]..".", cid)
            npcHandler.topic[cid] = 0
            xmsg[cid] = nil
        end
    elseif msgcontains(msg, "task") then
        if player:getStorageValue(storage) < 0 then
            local tasks = getTasks(cid)
            local text, n = tasks[1], tasks[2]
            if text ~= "" then
                npcHandler:say("Quieres hacer otra task? Puedes elegir "..text..".", cid)
                npcHandler.topic[cid] = 1
            else
                npcHandler:say("Ya hiciste todas las task.", cid)
            end
        else
            local actual = getActualTask(cid)
            npcHandler:say("Usted tiene que matar ".. actual[2] .." " .. actual[1].." antes de hacer otra mission. Listo?", cid)
            npcHandler.topic[cid] = 2
            xmsg[cid] = actual[1]
        end
    elseif msgcontains(msg, "no") then
        npcHandler:say("Ok then.", cid)
        npcHandler.topic[cid] = 0
    elseif msgcontains(msg, "stop") then
        local text, n = "", #monsters
        local result = stopTasks(cid)
        local text, n = result[1], result[2]
        if player:getStorageValue(storage) == 1 then
            npcHandler:say("Ok, dime si quieres continuar otra task, todavia puedes elegir "..text..".", cid)
        else
            npcHandler:say("No empezaste ninguna nueva task, si quieres empezar una, puedes elegir "..text..".", cid)
        end
        player:setStorageValue(storage, -1)
        npcHandler.topic[cid] = 1
    elseif msgcontains(msg, "list") then
        local text = "Tasks\n\n"
        for k, x in pairs(monsters) do
            if player:getStorageValue(x.mstorage) < x.amount then
                text = text ..k .." ["..(player:getStorageValue(x.mstorage) + 1).."/"..x.amount.."]:\n    Rewards:\n      "..getItemsFromTable(x.items).."\n       "..x.exp.." experience \n\n"
            else
                text = text .. k .." [DONE]\n\n"
            end
        end
        player:showTextDialog(1949, "" .. text)
        npcHandler:say("Here you are.", cid)
        npcHandler.topic[cid] = 0
    elseif msgcontains(msg, "bye") then
        npcHandler:say("Bye.", cid)
        npcHandler:releaseFocus(cid)
    else
        npcHandler:say("Ah?", cid)
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)


I haven't changed the structure of the code, I just took some of the loops that creates the NPC phrases to outside functions so it is easier for other ppl who might help you to understand the code.

I changed some of the way the npc works (mainly when reporting a finished mission) and put somethings that were missing (delete xmsg indexes, little beter usage of npchandler.topic etc.)

I still think that the problem you are facing is because you changed your characters value while still in another task. I atleast couldn't reproduce your error.
hey man thank you so much for your dedication!! but what do you mean by " i changed the cgaracters value while still in another task"?
gonna test this!
 
If you finished god task and the npc asked for hellish rhino, that means you had the storage 12244 (hellish task on/off) set to 1.

It could be either you messed up your storages with "/set" command, or your managed to bug the npc in a way that it finished your hellish rhino task but didn't reset your storage value.
 
If you finished god task and the npc asked for hellish rhino, that means you had the storage 12244 (hellish task on/off) set to 1.

It could be either you messed up your storages with "/set" command, or your managed to bug the npc in a way that it finished your hellish rhino task but didn't reset your storage value.
i seee....well i have never used that command so idk xd, i hope this solves this issue, i always use this script, i have many different npcs like this and this one is the onluy one giving problem :S
 
Back
Top