• 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 NPC Task System

Ahoi

Active Member
Joined
Sep 23, 2016
Messages
105
Reaction score
30
TFS 0.3.6 / TFS 0.4

1) Can anyone share task system?

2) How to make NPC show list in book for example?

THANK YOU!
 
Last edited:
Solution
1)
Search the forum for 'Grizzly Adams' or 'Killing in the name of'
It's been released multiple times. :oops:

2)
Once you have the script, you'd want to create an onUse script, and use a combination of things in order for the proper text to show.

If you want a generic list of tasks, then you can simply write them into the book and distribute it.
If you want a list of available tasks, then you'll want to check the storage value of the quest, before adding it into the book.
Since each task is typically a separate storage value, you could just create a table and iterate through it.

I'd do something like this
Lua:
-- if task storage is not equal to task_complete_value, will show in book available

local tasks = {
    -- {storage...
1)
Search the forum for 'Grizzly Adams' or 'Killing in the name of'
It's been released multiple times. :oops:

2)
Once you have the script, you'd want to create an onUse script, and use a combination of things in order for the proper text to show.

If you want a generic list of tasks, then you can simply write them into the book and distribute it.
If you want a list of available tasks, then you'll want to check the storage value of the quest, before adding it into the book.
Since each task is typically a separate storage value, you could just create a table and iterate through it.

I'd do something like this
Lua:
-- if task storage is not equal to task_complete_value, will show in book available

local tasks = {
    -- {storage, task_complete_value, "task description"}
    {11111, 3, "rotworms"},
    {11111, 3, "hydras"},
    {11111, 3, "cyclops"}
}

local function showTasks(cid)
    local text = "Available Tasks:\n"
    local counter = 0
    for i = 1, #tasks do
        if getCreatureStorage(cid, tasks[i][1]) ~= tasks[i][2] then
            text = text .. "\n" .. tasks[i][3] .. ""
            counter = counter + 1
        end
    end
    if counter == 0 then
        text = text .. "\nNone."
    end
    counter = 0
    text = text .. "\n\nCompleted Tasks:\n"
    for i = 1, #tasks do
        if getCreatureStorage(cid, tasks[i][1]) == tasks[i][2] then
            text = text .. "\n" .. tasks[i][3] .. ""
            counter = counter + 1
        end
    end
    if counter == 0 then
        text = text .. "\nNone."
    end
    doShowTextDialog(cid, 11134, text)
    return true
end
 
Solution
Back
Top