• 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 Help for task system 1.5

gustavok2

Member
Joined
Nov 22, 2013
Messages
27
Reaction score
5
Hello everyone,

I am trying to implement a task system in this source from MillhioreBT. (GitHub - MillhioreBT/forgottenserver-downgrade: TFS Downgrade 1.5 8.6))

I followed all the instructions from various topics, but unfortunately, I was not successful and couldn't find any solution for this issue.

Every time I receive this error in the console:
1719167084773.png
Could you help me understand this error?

I attached the all scripts.

Config:
killingInTheNameOfQuest.lua
LUA:
--[[
    TODO
        Unite all related variables / functions in a table
        rewrite functions like "getTasksByPlayer" to "Player.getTasks"
]]

RANK_NONE = 0
RANK_JOIN = 1
RANK_HUNTSMAN = 2
RANK_RANGER = 3
RANK_BIGGAMEHUNTER = 4
RANK_TROPHYHUNTER = 5
RANK_ELITEHUNTER = 6

REWARD_MONEY = 1
REWARD_EXP = 2
REWARD_ACHIEVEMENT = 3
REWARD_STORAGE = 4
REWARD_POINT = 5
REWARD_ITEM = 6

QUESTSTORAGE_BASE = 1500
JOIN_STOR = 100157
KILLSSTORAGE_BASE = 65000
REPEATSTORAGE_BASE = 48950
POINTSSTORAGE = 2500
tasks =
{
    [1] = {killsRequired = 100, raceName = "Trolls", level = {6, 19}, premium = false, creatures = {"troll", "troll champion", "island troll", "swamp troll"}, rewards = {{type = "exp", value = {200}},{type = "money", value = {200}}}},
    [2] = {killsRequired = 150, raceName = "Goblins", level = {6, 19}, premium = false, creatures = {"goblin", "goblin assassin", "goblin leader"}, rewards = {{type = "exp", value = {300}},{type = "money", value = {250}}}},
    [3] = {killsRequired = 300, raceName = "Crocodiles", level = {6, 49}, premium = false, creatures = {"crocodile"}, rewards = {{type = "exp", value = {800}},{type = "achievement", value = {"Blood-Red Snapper"}},{type = "storage", value = {35000, 1}},{type = "points", value = {1}}}},
    [4] = {killsRequired = 300, raceName = "Badgers", level = {6, 49}, premium = false, creatures = {"badger"}, rewards = {{type = "exp", value = {500}},{type = "points", value = {1}}}},
    }

tasksByPlayer = 3
repeatTimes = 3

function Player.getPawAndFurRank(self)
    return (self:getStorageValue(POINTSSTORAGE) >= 100 and RANK_ELITEHUNTER or self:getStorageValue(POINTSSTORAGE) >= 70 and RANK_TROPHYHUNTER or self:getStorageValue(POINTSSTORAGE) >= 40 and RANK_BIGGAMEHUNTER or self:getStorageValue(POINTSSTORAGE) >= 20 and RANK_RANGER or self:getStorageValue(POINTSSTORAGE) >= 10 and RANK_HUNTSMAN or self:getStorageValue(JOIN_STOR) == 1 and RANK_JOIN or RANK_NONE)
end

function Player.getPawAndFurPoints(self)
    return math.max(self:getStorageValue(POINTSSTORAGE), 0)
end

function getTaskByName(name, table)
    local t = (table and table or tasks)
    for k, v in pairs(t) do
        if v.name then
            if v.name:lower() == name:lower() then
                return k
            end
        else
            if v.raceName:lower() == name:lower() then
                return k
            end
        end
    end
    return false
end

function Player.getTasks(self)
    local canmake = {}
    local able = {}
    for k, v in pairs(tasks) do
        if self:getStorageValue(QUESTSTORAGE_BASE + k) < 1 and self:getStorageValue(REPEATSTORAGE_BASE + k) < repeatTimes then
            able[k] = true
            if self:getLevel() < v.level[1] or self:getLevel() > v.level[2] then
                able[k] = false
            end
            if v.storage and self:getStorageValue(v.storage[1]) < v.storage[2] then
                able[k] = false
            end

            if v.rank then
                if self:getPawAndFurRank() < v.rank then
                    able[k] = false
                end
            end

            if v.premium then
                if not self:isPremium() then
                    able[k] = false
                end
            end

            if able[k] then
                canmake[#canmake + 1] = k
            end
        end
    end
    return canmake
end

function Player.canStartTask(self, name, table)
    local v = ""
    local id = 0
    local t = (table and table or tasks)
    for k, i in pairs(t) do
        if i.name then
            if i.name:lower() == name:lower() then
                v = i
                id = k
                break
            end
        else
            if i.raceName:lower() == name:lower() then
                v = i
                id = k
                break
            end
        end
    end
    if v == "" then
        return false
    end
    if self:getStorageValue(QUESTSTORAGE_BASE + id) > 0 then
        return false
    end
    if self:getStorageValue(REPEATSTORAGE_BASE +  id) >= repeatTimes or v.norepeatable and self:getStorageValue(REPEATSTORAGE_BASE +  id) > 0 then
        return false
    end
    if v.level and self:getLevel() >= v.level[1] and self:getLevel() <= v.level[2] then
        if v.premium then
            if self:isPremium() then
                if v.rank then
                    if self:getPawAndFurRank() >= v.rank then
                        if v.storage then
                            if self:getStorageValue(v.storage[1]) >= v.storage then
                                return true
                            end
                        else
                            return true
                        end
                    end
                else
                    return true
                end
            else
                return true
            end
        else
            return true
        end
    end
    return false
end

function Player.getStartedTasks(self)
    local tmp = {}
    for k, v in pairs(tasks) do
        if self:getStorageValue(QUESTSTORAGE_BASE + k) > 0 and self:getStorageValue(QUESTSTORAGE_BASE + k) < 2 then
            tmp[#tmp + 1] = k
        end
    end
    return tmp
end

--in case other scripts are using these functions, i'll let them here
function getPlayerRank(cid) local p = Player(cid) return p and p:getPawAndFurRank() end
function getPlayerTasksPoints(cid) local p = Player(cid) return p and p:getPawAndFurPoints() end
function getTasksByPlayer(cid) local p = Player(cid) return p and p:getTasks() end
function canStartTask(cid, name, table) local p = Player(cid) return p and p:canStartTask(name, table) end
function getPlayerStartedTasks(cid) local p = Player(cid) return p and p:getStartedTasks() end

i linked the lib on global.lua
dofile('data/lib/miscellaneous/killingInTheNameOfQuest.lua')


 

Attachments

 
Abdala Ragab followed all the steps from this thread, but I am still receiving these errors :(

1719190219310.png
The errors above occur when I say Hi, task and when I use the command !task
 
LUA:
local npcHandler = NpcHandler:new(KeywordHandler:new())
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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 function completeMission(cid, missionNumber)
    local requiredItems = {}
    local missingItems = {}
    local playerItems = {}
    if missionNumber == 1 then
        requiredItems = {{id = 6527, count = 50}, {id = 6527, count = 50}, {id = 6527, count = 50}}
    elseif missionNumber == 2 then
        requiredItems = {{id = 6527, count = 50}, {id = 6527, count = 50}, {id = 6527, count = 50}}
    end

    for _, item in ipairs(requiredItems) do
        local playerItemCount = getPlayerItemCount(cid, item.id)
        if playerItemCount < item.count then
            table.insert(missingItems, {id = item.id, missingCount = item.count - playerItemCount})
        else
            table.insert(playerItems, {id = item.id, count = playerItemCount})
        end
    end

    if #missingItems == 0 then
        for _, item in ipairs(requiredItems) do
            doPlayerRemoveItem(cid, item.id, item.count)
        end
        if missionNumber == 1 then
            doPlayerAddItem(cid, 10137, 5)
            setPlayerStorageValue(cid, 1000, 1)
        elseif missionNumber == 2 then
            doPlayerAddItem(cid, 10136, 5)
            setPlayerStorageValue(cid, 1001, 1)
        end
        return true, {}
    else
        return false, missingItems
    end
end

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    if msgcontains(msg, "mission") then
        if player:getStorageValue(1000) ~= 1 then
            npcHandler:say("Your Mission is to bring me 50 of christmas token, 50 of christmas token, and 50 of christmas token. To claim your reward, say 'reward' after collecting all required items.", cid)
        elseif player:getStorageValue(1000) == 1 and player:getStorageValue(1001) ~= 1 then
            npcHandler:say("Your next Mission is to bring me 50 of christmas token, 50 of christmas token, and 50 of christmas token. To claim your reward, say 'reward' after collecting all required items.", cid)
        else
            npcHandler:say("You have completed all available missions. Thank you for your help!", cid)
        end
    elseif msgcontains(msg, "reward") then
        if player:getStorageValue(1000) ~= 1 then
            local success, missingItems = completeMission(cid, 1)
            if success then
                npcHandler:say("You have been rewarded with 5 of item name mmmm.", cid)
            else
                local message = "You haven't collected all the required items yet. You still need:"
                for _, item in ipairs(missingItems) do
                    message = message .. "\n" .. item.missingCount .. " of item " .. getItemNameById(item.id)
                end
                npcHandler:say(message, cid)
            end
        elseif player:getStorageValue(1000) == 1 and player:getStorageValue(1001) ~= 1 then
            local success, missingItems = completeMission(cid, 2)
            if success then
                npcHandler:say("You have been rewarded with 5 of item name xxxx.", cid)
            else
                local message = "You haven't collected all the required items yet. You still need:"
                for _, item in ipairs(missingItems) do
                    message = message .. "\n" .. item.missingCount .. " of item " .. getItemNameById(item.id)
                end
                npcHandler:say(message, cid)
            end
        else
            npcHandler:say("You have already received all the rewards.", cid)
        end
    end

    return true
end

npcHandler:setMessage(MESSAGE_GREET, "Hello, |PLAYERNAME|. How can I assist you today? You can start a mission by saying 'mission'.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="task and daily" script="taskdaily.lua" walkinterval="0">
    <health now="100" max="100"/>
    <look type="104"/>
    <parameters>
        <parameter key="message_greet" value="Hello |PLAYERNAME|. Do you want to do a {task} or a {daily} task? You want to {deliver} your task and receive prizes for it" />
    </parameters>
</npc>
 
LUA:
local npcHandler = NpcHandler:new(KeywordHandler:new())
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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 function completeMission(cid, missionNumber)
    local requiredItems = {}
    local missingItems = {}
    local playerItems = {}
    if missionNumber == 1 then
        requiredItems = {{id = 6527, count = 50}, {id = 6527, count = 50}, {id = 6527, count = 50}}
    elseif missionNumber == 2 then
        requiredItems = {{id = 6527, count = 50}, {id = 6527, count = 50}, {id = 6527, count = 50}}
    end

    for _, item in ipairs(requiredItems) do
        local playerItemCount = getPlayerItemCount(cid, item.id)
        if playerItemCount < item.count then
            table.insert(missingItems, {id = item.id, missingCount = item.count - playerItemCount})
        else
            table.insert(playerItems, {id = item.id, count = playerItemCount})
        end
    end

    if #missingItems == 0 then
        for _, item in ipairs(requiredItems) do
            doPlayerRemoveItem(cid, item.id, item.count)
        end
        if missionNumber == 1 then
            doPlayerAddItem(cid, 10137, 5)
            setPlayerStorageValue(cid, 1000, 1)
        elseif missionNumber == 2 then
            doPlayerAddItem(cid, 10136, 5)
            setPlayerStorageValue(cid, 1001, 1)
        end
        return true, {}
    else
        return false, missingItems
    end
end

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    if msgcontains(msg, "mission") then
        if player:getStorageValue(1000) ~= 1 then
            npcHandler:say("Your Mission is to bring me 50 of christmas token, 50 of christmas token, and 50 of christmas token. To claim your reward, say 'reward' after collecting all required items.", cid)
        elseif player:getStorageValue(1000) == 1 and player:getStorageValue(1001) ~= 1 then
            npcHandler:say("Your next Mission is to bring me 50 of christmas token, 50 of christmas token, and 50 of christmas token. To claim your reward, say 'reward' after collecting all required items.", cid)
        else
            npcHandler:say("You have completed all available missions. Thank you for your help!", cid)
        end
    elseif msgcontains(msg, "reward") then
        if player:getStorageValue(1000) ~= 1 then
            local success, missingItems = completeMission(cid, 1)
            if success then
                npcHandler:say("You have been rewarded with 5 of item name mmmm.", cid)
            else
                local message = "You haven't collected all the required items yet. You still need:"
                for _, item in ipairs(missingItems) do
                    message = message .. "\n" .. item.missingCount .. " of item " .. getItemNameById(item.id)
                end
                npcHandler:say(message, cid)
            end
        elseif player:getStorageValue(1000) == 1 and player:getStorageValue(1001) ~= 1 then
            local success, missingItems = completeMission(cid, 2)
            if success then
                npcHandler:say("You have been rewarded with 5 of item name xxxx.", cid)
            else
                local message = "You haven't collected all the required items yet. You still need:"
                for _, item in ipairs(missingItems) do
                    message = message .. "\n" .. item.missingCount .. " of item " .. getItemNameById(item.id)
                end
                npcHandler:say(message, cid)
            end
        else
            npcHandler:say("You have already received all the rewards.", cid)
        end
    end

    return true
end

npcHandler:setMessage(MESSAGE_GREET, "Hello, |PLAYERNAME|. How can I assist you today? You can start a mission by saying 'mission'.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="task and daily" script="taskdaily.lua" walkinterval="0">
    <health now="100" max="100"/>
    <look type="104"/>
    <parameters>
        <parameter key="message_greet" value="Hello |PLAYERNAME|. Do you want to do a {task} or a {daily} task? You want to {deliver} your task and receive prizes for it" />
    </parameters>
</npc>
This NPC script is wrong, it doesn't seem to be for tasks.
 
This NPC script is wrong, it doesn't seem to be for tasks.
aha my bad xD
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    local talkUser, msg, str, rst = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, msg:lower(), "", ""
    local task, daily, hours = player:getTaskMission(), player:getDailyTaskMission(), 24

    if isInArray({"task", "tasks", "missao", "mission"}, msg) then
        if taskSystem[task] then
            if player:getStorageValue(taskSystem[task].start) <= 0 then
                if player:getLevel() >= taskSystem[task].level then
                    player:setStorageValue(taskSystem[task].start, 1)
                    npcHandler:say("[Task System] Congratulations, you are now participating in the Task of "..taskSystem[task].name.." and shall kill "..taskSystem[task].count.." from this list: "..getMonsterFromList(taskSystem[task].monsters_list)..". "..(#taskSystem[task].items > 0 and "Oh and please bring me "..getItemsFromList(taskSystem[task].items).." for me." or "").."" , cid)
                else
                    npcHandler:say("Sorry, but you need to reach level "..taskSystem[task].level.." to be able to participate in the Task of "..taskSystem[task].name.."!", cid)
                end
            else
                npcHandler:say("Sorry, but you are currently on the task "..taskSystem[task].name..". You may {reward} if it's already over.", cid)
            end
        else
            npcHandler:say("Sorry, but for now I don't have any more tasks for you!", cid)
        end
    elseif isInArray({"diaria", "daily", "dayli", "diario"}, msg) then
        if player:getStorageValue(taskSystem_storages[6]) - os.time() > 0 then
            npcHandler:say("Sorry, you must wait until "..os.date("%d %B %Y %X ", player:getStorageValue(taskSystem_storages[6])).." to start a new daily task!", cid)
            return true
        elseif dailyTasks[daily] and player:getStorageValue(taskSystem_storages[5]) >= dailyTasks[daily].count then
            npcHandler:say("Sorry, do you have task for {reward}!", cid)
            return true
        end
        local r = player:randomDailyTask()
        if r == 0 then
            npcHandler:say("Sorry, but you don't have the level to complete any daily tasks.", cid)
            return true
        end
        player:setStorageValue(taskSystem_storages[4], r)
        player:setStorageValue(taskSystem_storages[6], os.time() + hours * 3600)
        player:setStorageValue(taskSystem_storages[7], 1)
        player:setStorageValue(taskSystem_storages[5], 0)
        local dtask = dailyTasks[r]
        npcHandler:say("[Daily Task System] Congratulations, you are now participating in the Daily Task of "..dtask.name.." and shall kill "..dtask.count.." monsters from this list: "..getMonsterFromList(dtask.monsters_list).." up until "..os.date("%d %B %Y %X ", player:getStorageValue(taskSystem_storages[6]))..". Good luck!" , cid)
    elseif isInArray({"receber", "reward", "recompensa", "report", "reportar", "entregar", "entrega"}, msg) then
        local v, k = taskSystem[task], dailyTasks[daily]
        if v then -- Original Task
            if player:getStorageValue(v.start) > 0 then
                if player:getStorageValue(taskSystem_storages[3]) >= v.count then
                    if #v.items > 0 and not doRemoveItemsFromList(cid, v.items) then
                        npcHandler:say("Sorry, but you also need to deliver the items on this list: "..getItemsFromList(v.items), cid)
                        return true
                    end

                    if v.exp > 0 then
                        player:addExperience(v.exp)
                        str = str.." "..v.exp.." experience"
                    end
                    if v.points > 0 then
                        player:setStorageValue(taskSystem_storages[2], (player:getTaskPoints() + v.points))
                        str = str.." + "..v.points.." task points"
                    end
                    if v.money > 0 then
                        player:addMoney(v.money)
                        str = str.." "..v.money.." gold coins"
                    end
                    if table.maxn(v.reward) > 0 then
                        player:giveRewardsTask(v.reward)
                        str = str.." "..getItemsFromList(v.reward)
                    end
                    npcHandler:say("Thank you for your help! Rewards: "..(str == "" and "none" or str).." for completing the task of "..v.name, cid)
                    player:setStorageValue(taskSystem_storages[3], 0)
                    player:setStorageValue(taskSystem_storages[1], (task + 1))
                else
                    npcHandler:say("Sorry, but you haven't finished your task "..v.name.." yet. I need you to kill more "..(player:getStorageValue(taskSystem_storages[3]) < 0 and v.count or -(player:getStorageValue(taskSystem_storages[3]) - v.count)).." of these terrible monsters!", cid)
                end
            else
            npcHandler:say("I'm sorry, but you have already completed a daily task today, and therefore, you cannot undertake another one. Please return tomorrow, and we can discuss it further. If you're interested, I can offer you another regular task. Simply say 'task' to express your interest.", cid)
            end
        end

        if k then -- Daily Task
            if player:getStorageValue(taskSystem_storages[7]) > 0 then
                if player:getStorageValue(taskSystem_storages[5]) >= k.count then
                    if k.exp > 0 then
                        player:addExperience(k.exp)
                        rst = rst.." "..k.exp.." experience"
                    end
                    if k.points > 0 then
                        player:setStorageValue(taskSystem_storages[2], (player:getTaskPoints() + k.points))
                        rst = rst.." + "..k.points.." task points"
                    end
                    if k.money > 0 then
                        player:addMoney(k.money)
                        rst = rst.." "..k.money.." gold coins"
                    end
                    if table.maxn(k.reward) > 0 then
                        player:giveRewardsTask(k.reward)
                        rst = rst.." "..getItemsFromList(k.reward)
                    end
                    npcHandler:say("Thank you for your help! Rewards: "..(rst == "" and "none" or rst).." for completing the daily task of "..k.name, cid)
                    player:setStorageValue(taskSystem_storages[4], 0)
                    player:setStorageValue(taskSystem_storages[5], 0)
                    player:setStorageValue(taskSystem_storages[7], 0)
                else
                    npcHandler:say("Sorry, but you haven't finished your daily task "..k.name.." yet. I need you to kill more "..(player:getStorageValue(taskSystem_storages[5]) < 0 and k.count or -(player:getStorageValue(taskSystem_storages[5]) - k.count)).." of these monsters!", cid)
                end   
            end
        end
    elseif msg == "no" then
        npcHandler:say("Alright then.", cid)
        talkState[talkUser] = 0
        npcHandler:releaseFocus(cid)
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
aha my bad xD
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    local talkUser, msg, str, rst = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, msg:lower(), "", ""
    local task, daily, hours = player:getTaskMission(), player:getDailyTaskMission(), 24

    if isInArray({"task", "tasks", "missao", "mission"}, msg) then
        if taskSystem[task] then
            if player:getStorageValue(taskSystem[task].start) <= 0 then
                if player:getLevel() >= taskSystem[task].level then
                    player:setStorageValue(taskSystem[task].start, 1)
                    npcHandler:say("[Task System] Congratulations, you are now participating in the Task of "..taskSystem[task].name.." and shall kill "..taskSystem[task].count.." from this list: "..getMonsterFromList(taskSystem[task].monsters_list)..". "..(#taskSystem[task].items > 0 and "Oh and please bring me "..getItemsFromList(taskSystem[task].items).." for me." or "").."" , cid)
                else
                    npcHandler:say("Sorry, but you need to reach level "..taskSystem[task].level.." to be able to participate in the Task of "..taskSystem[task].name.."!", cid)
                end
            else
                npcHandler:say("Sorry, but you are currently on the task "..taskSystem[task].name..". You may {reward} if it's already over.", cid)
            end
        else
            npcHandler:say("Sorry, but for now I don't have any more tasks for you!", cid)
        end
    elseif isInArray({"diaria", "daily", "dayli", "diario"}, msg) then
        if player:getStorageValue(taskSystem_storages[6]) - os.time() > 0 then
            npcHandler:say("Sorry, you must wait until "..os.date("%d %B %Y %X ", player:getStorageValue(taskSystem_storages[6])).." to start a new daily task!", cid)
            return true
        elseif dailyTasks[daily] and player:getStorageValue(taskSystem_storages[5]) >= dailyTasks[daily].count then
            npcHandler:say("Sorry, do you have task for {reward}!", cid)
            return true
        end
        local r = player:randomDailyTask()
        if r == 0 then
            npcHandler:say("Sorry, but you don't have the level to complete any daily tasks.", cid)
            return true
        end
        player:setStorageValue(taskSystem_storages[4], r)
        player:setStorageValue(taskSystem_storages[6], os.time() + hours * 3600)
        player:setStorageValue(taskSystem_storages[7], 1)
        player:setStorageValue(taskSystem_storages[5], 0)
        local dtask = dailyTasks[r]
        npcHandler:say("[Daily Task System] Congratulations, you are now participating in the Daily Task of "..dtask.name.." and shall kill "..dtask.count.." monsters from this list: "..getMonsterFromList(dtask.monsters_list).." up until "..os.date("%d %B %Y %X ", player:getStorageValue(taskSystem_storages[6]))..". Good luck!" , cid)
    elseif isInArray({"receber", "reward", "recompensa", "report", "reportar", "entregar", "entrega"}, msg) then
        local v, k = taskSystem[task], dailyTasks[daily]
        if v then -- Original Task
            if player:getStorageValue(v.start) > 0 then
                if player:getStorageValue(taskSystem_storages[3]) >= v.count then
                    if #v.items > 0 and not doRemoveItemsFromList(cid, v.items) then
                        npcHandler:say("Sorry, but you also need to deliver the items on this list: "..getItemsFromList(v.items), cid)
                        return true
                    end

                    if v.exp > 0 then
                        player:addExperience(v.exp)
                        str = str.." "..v.exp.." experience"
                    end
                    if v.points > 0 then
                        player:setStorageValue(taskSystem_storages[2], (player:getTaskPoints() + v.points))
                        str = str.." + "..v.points.." task points"
                    end
                    if v.money > 0 then
                        player:addMoney(v.money)
                        str = str.." "..v.money.." gold coins"
                    end
                    if table.maxn(v.reward) > 0 then
                        player:giveRewardsTask(v.reward)
                        str = str.." "..getItemsFromList(v.reward)
                    end
                    npcHandler:say("Thank you for your help! Rewards: "..(str == "" and "none" or str).." for completing the task of "..v.name, cid)
                    player:setStorageValue(taskSystem_storages[3], 0)
                    player:setStorageValue(taskSystem_storages[1], (task + 1))
                else
                    npcHandler:say("Sorry, but you haven't finished your task "..v.name.." yet. I need you to kill more "..(player:getStorageValue(taskSystem_storages[3]) < 0 and v.count or -(player:getStorageValue(taskSystem_storages[3]) - v.count)).." of these terrible monsters!", cid)
                end
            else
            npcHandler:say("I'm sorry, but you have already completed a daily task today, and therefore, you cannot undertake another one. Please return tomorrow, and we can discuss it further. If you're interested, I can offer you another regular task. Simply say 'task' to express your interest.", cid)
            end
        end

        if k then -- Daily Task
            if player:getStorageValue(taskSystem_storages[7]) > 0 then
                if player:getStorageValue(taskSystem_storages[5]) >= k.count then
                    if k.exp > 0 then
                        player:addExperience(k.exp)
                        rst = rst.." "..k.exp.." experience"
                    end
                    if k.points > 0 then
                        player:setStorageValue(taskSystem_storages[2], (player:getTaskPoints() + k.points))
                        rst = rst.." + "..k.points.." task points"
                    end
                    if k.money > 0 then
                        player:addMoney(k.money)
                        rst = rst.." "..k.money.." gold coins"
                    end
                    if table.maxn(k.reward) > 0 then
                        player:giveRewardsTask(k.reward)
                        rst = rst.." "..getItemsFromList(k.reward)
                    end
                    npcHandler:say("Thank you for your help! Rewards: "..(rst == "" and "none" or rst).." for completing the daily task of "..k.name, cid)
                    player:setStorageValue(taskSystem_storages[4], 0)
                    player:setStorageValue(taskSystem_storages[5], 0)
                    player:setStorageValue(taskSystem_storages[7], 0)
                else
                    npcHandler:say("Sorry, but you haven't finished your daily task "..k.name.." yet. I need you to kill more "..(player:getStorageValue(taskSystem_storages[5]) < 0 and k.count or -(player:getStorageValue(taskSystem_storages[5]) - k.count)).." of these monsters!", cid)
                end  
            end
        end
    elseif msg == "no" then
        npcHandler:say("Alright then.", cid)
        talkState[talkUser] = 0
        npcHandler:releaseFocus(cid)
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
same error :(:
1719199413709.png
 
Check lip
npcsystem
LUA:
-- Advanced NPC System by Jiddo

shop_amount = {}
shop_cost = {}
shop_rlname = {}
shop_itemid = {}
shop_container = {}
shop_npcuid = {}
shop_eventtype = {}
shop_subtype = {}
shop_destination = {}
shop_premium = {}

npcs_loaded_shop = {}
npcs_loaded_travel = {}

if not NpcSystem then
    -- Loads the underlying classes of the npcsystem.
    dofile('data/npc/lib/npcsystem/keywordhandler.lua')
    dofile('data/npc/lib/npcsystem/npchandler.lua')
    dofile('data/npc/lib/npcsystem/modules.lua')

    -- Global npc constants:

    -- Greeting and unGreeting keywords. For more information look at the top of modules.lua
    FOCUS_GREETWORDS = {'hi', 'hello'}
    FOCUS_FAREWELLWORDS = {'bye', 'farewell'}

    -- The word for requesting trade window. For more information look at the top of modules.lua
    SHOP_TRADEREQUEST = {'trade'}

    -- The word for accepting/declining an offer. CAN ONLY CONTAIN ONE FIELD! For more information look at the top of modules.lua
    SHOP_YESWORD = {'yes'}
    SHOP_NOWORD = {'no'}

    -- Pattern used to get the amount of an item a player wants to buy/sell.
    PATTERN_COUNT = '%d+'

    -- Talkdelay behavior. For more information, look at the top of npchandler.lua.
    NPCHANDLER_TALKDELAY = TALKDELAY_ONTHINK

    -- Constant strings defining the keywords to replace in the default messages.
    --    For more information, look at the top of npchandler.lua...
    TAG_PLAYERNAME = '|PLAYERNAME|'
    TAG_ITEMCOUNT = '|ITEMCOUNT|'
    TAG_TOTALCOST = '|TOTALCOST|'
    TAG_ITEMNAME = '|ITEMNAME|'

    NpcSystem = {}

    -- Gets an npcparameter with the specified key. Returns nil if no such parameter is found.
    function NpcSystem.getParameter(key)
        local ret = getNpcParameter(tostring(key))
        if (type(ret) == 'number' and ret == 0) then
            return nil
        else
            return ret
        end
    end

    -- Parses all known parameters for the npc. Also parses parseable modules.
    function NpcSystem.parseParameters(npcHandler)
        local ret = NpcSystem.getParameter('idletime')
        if ret then
            npcHandler.idleTime = tonumber(ret)
        end
        local ret = NpcSystem.getParameter('talkradius')
        if ret then
            npcHandler.talkRadius = tonumber(ret)
        end
        local ret = NpcSystem.getParameter('message_greet')
        if ret then
            npcHandler:setMessage(MESSAGE_GREET, ret)
        end
        local ret = NpcSystem.getParameter('message_farewell')
        if ret then
            npcHandler:setMessage(MESSAGE_FAREWELL, ret)
        end
        local ret = NpcSystem.getParameter('message_decline')
        if ret then
            npcHandler:setMessage(MESSAGE_DECLINE, ret)
        end
        local ret = NpcSystem.getParameter('message_needmorespace')
        if ret then
            npcHandler:setMessage(MESSAGE_NEEDMORESPACE, ret)
        end
        local ret = NpcSystem.getParameter('message_needspace')
        if ret then
            npcHandler:setMessage(MESSAGE_NEEDSPACE, ret)
        end
        local ret = NpcSystem.getParameter('message_sendtrade')
        if ret then
            npcHandler:setMessage(MESSAGE_SENDTRADE, ret)
        end
        local ret = NpcSystem.getParameter('message_noshop')
        if ret then
            npcHandler:setMessage(MESSAGE_NOSHOP, ret)
        end
        local ret = NpcSystem.getParameter('message_oncloseshop')
        if ret then
            npcHandler:setMessage(MESSAGE_ONCLOSESHOP, ret)
        end
        local ret = NpcSystem.getParameter('message_onbuy')
        if ret then
            npcHandler:setMessage(MESSAGE_ONBUY, ret)
        end
        local ret = NpcSystem.getParameter('message_onsell')
        if ret then
            npcHandler:setMessage(MESSAGE_ONSELL, ret)
        end
        local ret = NpcSystem.getParameter('message_missingmoney')
        if ret then
            npcHandler:setMessage(MESSAGE_MISSINGMONEY, ret)
        end
        local ret = NpcSystem.getParameter('message_needmoney')
        if ret then
            npcHandler:setMessage(MESSAGE_NEEDMONEY, ret)
        end
        local ret = NpcSystem.getParameter('message_missingitem')
        if ret then
            npcHandler:setMessage(MESSAGE_MISSINGITEM, ret)
        end
        local ret = NpcSystem.getParameter('message_needitem')
        if ret then
            npcHandler:setMessage(MESSAGE_NEEDITEM, ret)
        end
        local ret = NpcSystem.getParameter('message_idletimeout')
        if ret then
            npcHandler:setMessage(MESSAGE_IDLETIMEOUT, ret)
        end
        local ret = NpcSystem.getParameter('message_walkaway')
        if ret then
            npcHandler:setMessage(MESSAGE_WALKAWAY, ret)
        end
        local ret = NpcSystem.getParameter('message_alreadyfocused')
        if ret then
            npcHandler:setMessage(MESSAGE_ALREADYFOCUSED, ret)
        end
        local ret = NpcSystem.getParameter('message_buy')
        if ret then
            npcHandler:setMessage(MESSAGE_BUY, ret)
        end
        local ret = NpcSystem.getParameter('message_sell')
        if ret then
            npcHandler:setMessage(MESSAGE_SELL, ret)
        end
        local ret = NpcSystem.getParameter('message_bought')
        if ret then
            npcHandler:setMessage(MESSAGE_BOUGHT, ret)
        end
        local ret = NpcSystem.getParameter('message_sold')
        if ret then
            npcHandler:setMessage(MESSAGE_SOLD, ret)
        end
        local ret = NpcSystem.getParameter('message_walkaway_male')
        if ret then
            npcHandler:setMessage(MESSAGE_WALKAWAY_MALE, ret)
        end
        local ret = NpcSystem.getParameter('message_walkaway_female')
        if ret then
            npcHandler:setMessage(MESSAGE_WALKAWAY_FEMALE, ret)
        end

        -- Parse modules.
        for parameter, module in pairs(Modules.parseableModules) do
            local ret = NpcSystem.getParameter(parameter)
            if ret then
                local number = tonumber(ret)
                if number ~= 0 and module.parseParameters then
                    local instance = module:new()
                    npcHandler:addModule(instance)
                    instance:parseParameters()
                end
            end
        end
    end
end
 
Check lip
npcsystem
LUA:
-- Advanced NPC System by Jiddo

shop_amount = {}
shop_cost = {}
shop_rlname = {}
shop_itemid = {}
shop_container = {}
shop_npcuid = {}
shop_eventtype = {}
shop_subtype = {}
shop_destination = {}
shop_premium = {}

npcs_loaded_shop = {}
npcs_loaded_travel = {}

if not NpcSystem then
    -- Loads the underlying classes of the npcsystem.
    dofile('data/npc/lib/npcsystem/keywordhandler.lua')
    dofile('data/npc/lib/npcsystem/npchandler.lua')
    dofile('data/npc/lib/npcsystem/modules.lua')

    -- Global npc constants:

    -- Greeting and unGreeting keywords. For more information look at the top of modules.lua
    FOCUS_GREETWORDS = {'hi', 'hello'}
    FOCUS_FAREWELLWORDS = {'bye', 'farewell'}

    -- The word for requesting trade window. For more information look at the top of modules.lua
    SHOP_TRADEREQUEST = {'trade'}

    -- The word for accepting/declining an offer. CAN ONLY CONTAIN ONE FIELD! For more information look at the top of modules.lua
    SHOP_YESWORD = {'yes'}
    SHOP_NOWORD = {'no'}

    -- Pattern used to get the amount of an item a player wants to buy/sell.
    PATTERN_COUNT = '%d+'

    -- Talkdelay behavior. For more information, look at the top of npchandler.lua.
    NPCHANDLER_TALKDELAY = TALKDELAY_ONTHINK

    -- Constant strings defining the keywords to replace in the default messages.
    --    For more information, look at the top of npchandler.lua...
    TAG_PLAYERNAME = '|PLAYERNAME|'
    TAG_ITEMCOUNT = '|ITEMCOUNT|'
    TAG_TOTALCOST = '|TOTALCOST|'
    TAG_ITEMNAME = '|ITEMNAME|'

    NpcSystem = {}

    -- Gets an npcparameter with the specified key. Returns nil if no such parameter is found.
    function NpcSystem.getParameter(key)
        local ret = getNpcParameter(tostring(key))
        if (type(ret) == 'number' and ret == 0) then
            return nil
        else
            return ret
        end
    end

    -- Parses all known parameters for the npc. Also parses parseable modules.
    function NpcSystem.parseParameters(npcHandler)
        local ret = NpcSystem.getParameter('idletime')
        if ret then
            npcHandler.idleTime = tonumber(ret)
        end
        local ret = NpcSystem.getParameter('talkradius')
        if ret then
            npcHandler.talkRadius = tonumber(ret)
        end
        local ret = NpcSystem.getParameter('message_greet')
        if ret then
            npcHandler:setMessage(MESSAGE_GREET, ret)
        end
        local ret = NpcSystem.getParameter('message_farewell')
        if ret then
            npcHandler:setMessage(MESSAGE_FAREWELL, ret)
        end
        local ret = NpcSystem.getParameter('message_decline')
        if ret then
            npcHandler:setMessage(MESSAGE_DECLINE, ret)
        end
        local ret = NpcSystem.getParameter('message_needmorespace')
        if ret then
            npcHandler:setMessage(MESSAGE_NEEDMORESPACE, ret)
        end
        local ret = NpcSystem.getParameter('message_needspace')
        if ret then
            npcHandler:setMessage(MESSAGE_NEEDSPACE, ret)
        end
        local ret = NpcSystem.getParameter('message_sendtrade')
        if ret then
            npcHandler:setMessage(MESSAGE_SENDTRADE, ret)
        end
        local ret = NpcSystem.getParameter('message_noshop')
        if ret then
            npcHandler:setMessage(MESSAGE_NOSHOP, ret)
        end
        local ret = NpcSystem.getParameter('message_oncloseshop')
        if ret then
            npcHandler:setMessage(MESSAGE_ONCLOSESHOP, ret)
        end
        local ret = NpcSystem.getParameter('message_onbuy')
        if ret then
            npcHandler:setMessage(MESSAGE_ONBUY, ret)
        end
        local ret = NpcSystem.getParameter('message_onsell')
        if ret then
            npcHandler:setMessage(MESSAGE_ONSELL, ret)
        end
        local ret = NpcSystem.getParameter('message_missingmoney')
        if ret then
            npcHandler:setMessage(MESSAGE_MISSINGMONEY, ret)
        end
        local ret = NpcSystem.getParameter('message_needmoney')
        if ret then
            npcHandler:setMessage(MESSAGE_NEEDMONEY, ret)
        end
        local ret = NpcSystem.getParameter('message_missingitem')
        if ret then
            npcHandler:setMessage(MESSAGE_MISSINGITEM, ret)
        end
        local ret = NpcSystem.getParameter('message_needitem')
        if ret then
            npcHandler:setMessage(MESSAGE_NEEDITEM, ret)
        end
        local ret = NpcSystem.getParameter('message_idletimeout')
        if ret then
            npcHandler:setMessage(MESSAGE_IDLETIMEOUT, ret)
        end
        local ret = NpcSystem.getParameter('message_walkaway')
        if ret then
            npcHandler:setMessage(MESSAGE_WALKAWAY, ret)
        end
        local ret = NpcSystem.getParameter('message_alreadyfocused')
        if ret then
            npcHandler:setMessage(MESSAGE_ALREADYFOCUSED, ret)
        end
        local ret = NpcSystem.getParameter('message_buy')
        if ret then
            npcHandler:setMessage(MESSAGE_BUY, ret)
        end
        local ret = NpcSystem.getParameter('message_sell')
        if ret then
            npcHandler:setMessage(MESSAGE_SELL, ret)
        end
        local ret = NpcSystem.getParameter('message_bought')
        if ret then
            npcHandler:setMessage(MESSAGE_BOUGHT, ret)
        end
        local ret = NpcSystem.getParameter('message_sold')
        if ret then
            npcHandler:setMessage(MESSAGE_SOLD, ret)
        end
        local ret = NpcSystem.getParameter('message_walkaway_male')
        if ret then
            npcHandler:setMessage(MESSAGE_WALKAWAY_MALE, ret)
        end
        local ret = NpcSystem.getParameter('message_walkaway_female')
        if ret then
            npcHandler:setMessage(MESSAGE_WALKAWAY_FEMALE, ret)
        end

        -- Parse modules.
        for parameter, module in pairs(Modules.parseableModules) do
            local ret = NpcSystem.getParameter(parameter)
            if ret then
                local number = tonumber(ret)
                if number ~= 0 and module.parseParameters then
                    local instance = module:new()
                    npcHandler:addModule(instance)
                    instance:parseParameters()
                end
            end
        end
    end
end
same error:
I'm using the default lib from this source from the MillhioreBT repository, I tested it with your lib, but it's not working either:
1719242486666.png
 

Similar threads

Replies
1
Views
161
Back
Top