• 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 RevScript Task System Convertion

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
932
Solutions
23
Reaction score
444
Location
Santiago - Chile
Hi! I would like to do a request. I have this task system that is working well for my 8.6 server (TFS 1.4 Nekiro), the system is wrote with the old 0.X syntaxis and it doesn't have a modal window that is usefull for me, considering that I use 8.6. The code is a little messy since i've edited this years ago, I wonder if someone can write this same system, with the new 1.X syntax and with a little detail:
  • When you finish the task, add a storage value that verify that the player end the task (example: questFinished = XXXX parameter). Would like to use this storage as requeriement to open certain doors or access to certain places.
Here is the whole script:

NPC
Code:
local tasks = {
    [1] = {questStarted = 1510, questStorage = 65000, killsRequired = 200, raceName = "Son of Verminors", rewards = {{enable = true, type = "exp", values = 2360000}, {enable = true, type = "money", values = 25000}}},
    [2] = {questStarted = 1511, questStorage = 65001, killsRequired = 200, raceName = "Plaguesmiths", rewards = {{enable = true, type = "exp", values = 1800000}, {enable = true, type = "money", values = 25000}}},
    [3] = {questStarted = 1512, questStorage = 65002, killsRequired = 100, raceName = "Rotworms", rewards = {{enable = true, type = "exp", values = 16000}, {enable = true, type = "money", values = 25000}}},
    [4] = {questStarted = 1513, questStorage = 65003, killsRequired = 100, raceName = "Cyclops", rewards = {{enable = true, type = "exp", values = 30000}, {enable = true, type = "money", values = 25000}}},
    [5] = {questStarted = 1514, questStorage = 65004, killsRequired = 200, raceName = "Heros", rewards = {{enable = true, type = "exp", values = 480000}, {enable = true, type = "money", values = 25000}}},
    [6] = {questStarted = 1515, questStorage = 65005, killsRequired = 200, raceName = "Dragons", rewards = {{enable = true, type = "exp", values = 280000}, {enable = true, type = "money", values = 25000}}},
    [7] = {questStarted = 1516, questStorage = 65006, killsRequired = 100, raceName = "Dragon Lords", rewards = {{enable = true, type = "exp", values = 420000}, {enable = true, type = "money", values = 25000}}},
    [8] = {questStarted = 1517, questStorage = 65007, killsRequired = 200, raceName = "Frost Dragons", rewards = {{enable = true, type = "exp", values = 840000}, {enable = true, type = "money", values = 25000}}},
    [9] = {questStarted = 1518, questStorage = 65008, killsRequired = 200, raceName = "Warlocks", rewards = {{enable = true, type = "exp", values = 1600000}, {enable = true, type = "money", values = 25000}}},
    [10] = {questStarted = 1519, questStorage = 65009, killsRequired = 150, raceName = "Hydras", rewards = {{enable = true, type = "exp", values = 630000}, {enable = true, type = "money", values = 25000}}},
    [11] = {questStarted = 1520, questStorage = 65010, killsRequired = 150, raceName = "Demons", rewards = {{enable = true, type = "exp", values = 1800000}, {enable = true, type = "money", values = 25000}}},
    [12] = {questStarted = 1521, questStorage = 65011, killsRequired = 100, raceName = "Vampires", rewards = {{enable = true, type = "exp", values = 141500}, {enable = true, type = "money", values = 25000}}},
    [13] = {questStarted = 1522, questStorage = 65012, killsRequired = 200, raceName = "Demon Outcasts", rewards = {{enable = true, type = "exp", values = 3480000}, {enable = true, type = "money", values = 25000}}},
    [14] = {questStarted = 1523, questStorage = 65013, killsRequired = 200, raceName = "Serpent Spawns", rewards = {{enable = true, type = "exp", values = 940000}, {enable = true, type = "money", values = 25000}}},
    [15] = {questStarted = 1524, questStorage = 65014, killsRequired = 150, raceName = "Grim Reapers", rewards = {{enable = true, type = "exp", values = 1650000}, {enable = true, type = "money", values = 25000}}},
    [16] = {questStarted = 1525, questStorage = 65015, killsRequired = 200, raceName = "Behemoths", rewards = {{enable = true, type = "exp", values = 1000000}, {enable = true, type = "money", values = 25000}}},
    [17] = {questStarted = 1526, questStorage = 65016, killsRequired = 150, raceName = "Bog Raiders", rewards = {{enable = true, type = "exp", values = 480000}, {enable = true, type = "money", values = 25000}}},
    [18] = {questStarted = 1527, questStorage = 65017, killsRequired = 200, raceName = "Choking Fears", rewards = {{enable = true, type = "exp", values = 2490000}, {enable = true, type = "money", values = 25000}}},
    [19] = {questStarted = 1528, questStorage = 65018, killsRequired = 200, raceName = "Crystal Spiders", rewards = {{enable = true, type = "exp", values = 860000}, {enable = true, type = "money", values = 25000}}},
    [20] = {questStarted = 1529, questStorage = 65019, killsRequired = 100, raceName = "Giant Spiders", rewards = {{enable = true, type = "exp", values = 502000}, {enable = true, type = "money", values = 25000}}},
    [21] = {questStarted = 1530, questStorage = 65020, killsRequired = 100, raceName = "Nightmares", rewards = {{enable = true, type = "exp", values = 537500}, {enable = true, type = "money", values = 25000}}},
    [22] = {questStarted = 1531, questStorage = 65021, killsRequired = 200, raceName = "Undead Dragons", rewards = {{enable = true, type = "exp", values = 3380000}, {enable = true, type = "money", values = 25000}}},
    [23] = {questStarted = 1532, questStorage = 65022, killsRequired = 100, raceName = "Betrayed Wraiths", rewards = {{enable = true, type = "exp", values = 1200000}, {enable = true, type = "money", values = 25000}}},
    [24] = {questStarted = 1533, questStorage = 65023, killsRequired = 200, raceName = "Blightwalkers", rewards = {{enable = true, type = "exp", values = 2340000}, {enable = true, type = "money", values = 25000}}},
    [25] = {questStarted = 1534, questStorage = 65024, killsRequired = 400, raceName = "Dark Torturers", rewards = {{enable = true, type = "exp", values = 3720000}, {enable = true, type = "money", values = 25000}}},
    [26] = {questStarted = 1535, questStorage = 65025, killsRequired = 100, raceName = "Defilers", rewards = {{enable = true, type = "exp", values = 1110000}, {enable = true, type = "money", values = 25000}}},
    [27] = {questStarted = 1536, questStorage = 65026, killsRequired = 200, raceName = "Destroyers", rewards = {{enable = true, type = "exp", values = 2700000}, {enable = true, type = "money", values = 25000}}},
    [28] = {questStarted = 1537, questStorage = 65027, killsRequired = 100, raceName = "Furys", rewards = {{enable = true, type = "exp", values = 1350000}, {enable = true, type = "money", values = 25000}}},
    [29] = {questStarted = 1538, questStorage = 65028, killsRequired = 100, raceName = "Hellhounds", rewards = {{enable = true, type = "exp", values = 1360000}, {enable = true, type = "money", values = 25000}}},
    [30] = {questStarted = 1539, questStorage = 65029, killsRequired = 100, raceName = "Juggernauts", rewards = {{enable = true, type = "exp", values = 1562500}, {enable = true, type = "money", values = 25000}}}
}

local rankStorage = 32150
local choose = {}

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 getTasksStarted(cid)
    local tmp = {}
    for k, v in pairs(tasks) do
        if getCreatureStorage(cid, v.questStarted) == 1 then
            table.insert(tmp, k)
        end
    end
    return tmp
end

function getTaskByName(name)
    for k, v in pairs(tasks) do
        if v.raceName:lower() == name:lower() then
            return k
        end
    end
    return false
end

function creatureSayCallback(cid, type, msg)

    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
    if isInArray({"task", "tasks"}, msg:lower()) then
        selfSay("There you can see the following tasks, please tell me the {number of the task} that you want to do. If you want to finish a task say, example: {report dragon lords}. To change your current task to another you can {cancel} tasks.", cid)
        local text = ""
        for i = 1, table.maxn(tasks) do
           text = text .. (text == "" and "" or "\n") .. i .. " - " .. tasks[i].raceName .. (getCreatureStorage(cid, tasks[i].questStarted) == 1 and " [...]" or getCreatureStorage(cid, tasks[i].questStarted) == 2 and " [x]" or "")
        end
        return doShowTextDialog(cid, 5956, text)

    elseif getTaskByName(msg) or tasks[tonumber(msg)] then
        msg = (getTaskByName(msg) or tonumber(msg))
        if getCreatureStorage(cid, tasks[msg].questStarted) == 1 then
            selfSay("You already started this task.", cid)
            talkState[talkUser] = 0
            return true
        end
        if getCreatureStorage(cid, tasks[msg].questStarted) == 2 then
            selfSay("You already finished this task.", cid)
            talkState[talkUser] = 0
            return true
        end
        local startedTasks = getTasksStarted(cid)
        if #startedTasks > 0 then
        selfSay("You already started " .. tasks[startedTasks[1]].raceName .. " task. You cannot start more then one task at once. If you want to finish a task say, example: {report dragon lords}. To change your current task to another you can {cancel} tasks.", cid)
        talkState[talkUser] = 0
        return true
        end
        if tasks[msg].level and getPlayerLevel(cid) < tasks[msg].level then
            selfSay("You need level " .. tasks[msg].level .. " or higher to make this task.", cid)
            talkState[talkUser] = 0
            return true
        end
        selfSay("Are you sure that do you want to start the task number " .. msg .. "? In this task you will need to defeat " .. tasks[msg].killsRequired .. " " .. tasks[msg].raceName .. ".", cid)
        choose[cid] = msg
        talkState[talkUser] = 1
    elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
        doCreatureSetStorage(cid, tasks[choose[cid]].questStarted, 1)
        doCreatureSetStorage(cid, tasks[choose[cid]].questStorage, 0)
        selfSay("You have started the task number " .. choose[cid] .. ", remember... in this task you will need to defeat " .. tasks[choose[cid]].killsRequired .. " " .. tasks[choose[cid]].raceName .. ". Good luck!", cid)
        talkState[talkUser] = 0
        return true
elseif msg:lower() == "cancel" then
   local startedTasks = getTasksStarted(cid)

   if #startedTasks == 0 then
      selfSay("You don't have any task started.", cid)
      talkState[talkUser] = 0
      return true
   end

   selfSay("Do you want to cancel " .. tasks[startedTasks[1]].raceName .. " task? Are you sure?", cid)
   talkState[talkUser] = 2
   return true

elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then
   local startedTasks = getTasksStarted(cid)

   if #startedTasks == 0 then
      selfSay("You don't have any task started.", cid)
      talkState[talkUser] = 0
      return true
   end

   doCreatureSetStorage(cid, tasks[startedTasks[1]].questStarted, -1)
   doCreatureSetStorage(cid, tasks[startedTasks[1]].questStorage, -1)
   selfSay("Task " .. tasks[startedTasks[1]].raceName .. " cancelled. Now you can choose other task.", cid)
   talkState[talkUser] = 0
   return true
    elseif msg:lower() == "report" then
        local t = getTasksStarted(cid)
        local response = "You are currently making " .. (#t > 1 and "these" or "this") .. " task" .. (#t > 1 and "s" or "") .. ":\n"
        if table.maxn(t) > 0 then
            for _, tsk in ipairs(t) do
                if getCreatureStorage(cid, tasks[tsk].questStorage) < 0 then
                    doCreatureSetStorage(cid, tasks[tsk].questStorage, 0)
                end
                response = response .. " Name: " .. tasks[tsk].raceName .. " Kills: " .. getCreatureStorage(cid, tasks[tsk].questStorage) .. " - " .. tasks[tsk].killsRequired .. ".\n"
            end
            response = response .. "Please say report and the name of the task that do you want to report, example: 'Report Trolls'."
            return selfSay(response, cid)
        else
            return selfSay("You need to start at least one task first.", cid)
        end
    elseif string.sub(msg:lower(), 0, 6) == "report" then
        local t = getTaskByName(string.sub(msg, 8, string.len(msg)))
        if not t then
            return selfSay("That task does not exists.", cid)
        end

        if getCreatureStorage(cid, tasks[t].questStarted) == 2 then
            return selfSay("You already finished this task.", cid)
        end

        if getCreatureStorage(cid, tasks[t].questStarted) < 1 then
            return selfSay("You don't have started this task.", cid)
        end

        if tasks[t].killsRequired > getCreatureStorage(cid, tasks[t].questStorage) then
            return selfSay("Current " .. getCreatureStorage(cid, tasks[t].questStorage) .. " " .. tasks[t].raceName .. " killed, you need to kill " .. tasks[t].killsRequired .. ".", cid)
        end

        for i = 1, table.maxn(tasks[t].rewards) do
            for k_, reward in pairs(tasks[t].rewards) do
                if(reward.enable) then
                    if isInArray({"boss", "teleport", 1}, reward.type) then
                        doTeleportThing(cid, reward.values)
                    elseif isInArray({"exp", "experience", 2}, reward.type) then
                        doPlayerAddExperience(cid, reward.values)
                    elseif isInArray({"item", 3}, reward.type) then
                        doPlayerAddItem(cid, reward.values[1], reward.values[2])
                    elseif isInArray({"money", 4}, reward.type) then
                        doPlayerAddMoney(cid, reward.values)
                    elseif isInArray({"storage", "stor", 5}, reward.type) then
                        doCreatureSetStorage(cid, reward.values[1], reward.values[2])
                    elseif isInArray({"points", "rank", 2}, reward.type) then
                        doCreatureSetStorage(cid, rankStorage, getCreatureStorage(cid, rankStorage) + reward.values)
                    else
                        print("[Warning - Npc::KillingInTheNameOf] Wrong reward type: " .. (reward.type or "nil") .. ", reward could not be loaded.")
                    end
                end
            end
        end
        local rank = getCreatureStorage(cid, rankStorage)
        selfSay("Great!... you have finished the task number " .. t .. "" .. (rank > 4 and ", you are a " or "") .. "" .. (((rank > 4 and rank < 10) and ("Huntsman") or (rank > 9 and rank < 20) and ("Ranger") or (rank > 19 and rank < 30) and ("Big Game Hunter") or (rank > 29 and rank < 50) and ("Trophy Hunter") or (rank > 49) and ("Elite Hunter")) or "") .. ". Good job.", cid)
        return doCreatureSetStorage(cid, tasks[t].questStarted, 2)
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Creaturescript
Code:
local questCreatures =
{
    ["son of verminor"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15000, killsRequired = 200, raceName = "Son of Verminors"},
 
    ["plaguesmith"] = {questStarted = 1511, questStorage = 65001, creatureStorage = 15007, killsRequired = 200, raceName = "Plaguesmiths"},
 
    ["rotworm"] = {questStarted = 1512, questStorage = 65002, creatureStorage = 15011, killsRequired = 100, raceName = "Rotworms"},
    ["carriom worm"] = {questStarted = 1512, questStorage = 65002, creatureStorage = 15012, killsRequired = 100, raceName = "Rotworms"},
 
    ["cyclops"] = {questStarted = 1513, questStorage = 65003, creatureStorage = 15013, killsRequired = 100, raceName = "Cyclops"},
    ["cyclops smith"] = {questStarted = 1513, questStorage = 65003, creatureStorage = 15014, killsRequired = 100, raceName = "Cyclops"},
    ["cyclops drone"] = {questStarted = 1513, questStorage = 65003, creatureStorage = 15015, killsRequired = 100, raceName = "Cyclops"},
 
 
    ["hero"] = {questStarted = 1514, questStorage = 65004, creatureStorage = 15016, killsRequired = 200, raceName = "Heros"},
 
    ["dragon"] = {questStarted = 1515, questStorage = 65005, creatureStorage = 15017, killsRequired = 200, raceName = "Dragons"},
 
    ["dragon lord"] = {questStarted = 1516, questStorage = 65006, creatureStorage = 15018, killsRequired = 100, raceName = "Dragon Lords"},
 
    ["frost dragon"] = {questStarted = 1517, questStorage = 65007, creatureStorage = 15019, killsRequired = 200, raceName = "Frost Dragons"},
 
    ["warlock"] = {questStarted = 1518, questStorage = 65008, creatureStorage = 15020, killsRequired = 200, raceName = "Warlocks"},
 
    ["hydra"] = {questStarted = 1519, questStorage = 65009, creatureStorage = 15021, killsRequired = 150, raceName = "Hydras"},
 
    ["demon"] = {questStarted = 1520, questStorage = 65010, creatureStorage = 15022, killsRequired = 150, raceName = "Demons"},

    ["vampire bride"] = {questStarted = 1521, questStorage = 65011, creatureStorage = 15027, killsRequired = 100, raceName = "Vampires"},
    ["vampire"] = {questStarted = 1521, questStorage = 65011, creatureStorage = 15028, killsRequired = 100, raceName = "Vampires"},
  
    ["demon outcast"] = {questStarted = 1522, questStorage = 65012, creatureStorage = 15032, killsRequired = 200, raceName = "Demon Outcasts"},

    ["serpent spawn"] = {questStarted = 1523, questStorage = 65013, creatureStorage = 15036, killsRequired = 200, raceName = "Serpent Spawns"},
 
    ["grim reaper"] = {questStarted = 1524, questStorage = 65014, creatureStorage = 15040, killsRequired = 150, raceName = "Grim Reapers"},
   
    ["behemoth"] = {questStarted = 1525, questStorage = 65015, creatureStorage = 15041, killsRequired = 200, raceName = "Behemoths"},
 
    ["bog raider"] = {questStarted = 1526, questStorage = 65016, creatureStorage = 15048, killsRequired = 150, raceName = "Bog Raiders"},
 
    ["choking fear"] = {questStarted = 1527, questStorage = 65017, creatureStorage = 15049, killsRequired = 200, raceName = "Bonebeasts"},
 
    ["crystal spider"] = {questStarted = 1528, questStorage = 65018, creatureStorage = 15050, killsRequired = 200, raceName = "Crystal Spiders"},
 
    ["giant spider"] = {questStarted = 1529, questStorage = 65019, creatureStorage = 15051, killsRequired = 100, raceName = "Giant Spiders"},
 
    ["nightmare"] = {questStarted = 1530, questStorage = 65020, creatureStorage = 15052, killsRequired = 100, raceName = "Nightmares"},
 
    ["undead dragon"] = {questStarted = 1531, questStorage = 65021, creatureStorage = 15053, killsRequired = 200, raceName = "Undead Dragons"},
 
    ["betrayed wraith"] = {questStarted = 1532, questStorage = 65022, creatureStorage = 15054, killsRequired = 100, raceName = "Betrayed Wraiths"},
    ["blightwalker"] = {questStarted = 1533, questStorage = 65023, creatureStorage = 15055, killsRequired = 200, raceName = "Blightwalkers"},
 
    ["dark torturer"] = {questStarted = 1534, questStorage = 65024, creatureStorage = 15056, killsRequired = 400, raceName = "Dark Torturers"},
    ["defiler"] = {questStarted = 1535, questStorage = 65025, creatureStorage = 15057, killsRequired = 100, raceName = "defilers"},
 
    ["destroyer"] = {questStarted = 1536, questStorage = 65026, creatureStorage = 15058, killsRequired = 200, raceName = "Destroyers"},
 
    ["fury"] = {questStarted = 1537, questStorage = 65027, creatureStorage = 15071, killsRequired = 100, raceName = "Furys"},
 
    ["hellhound"] = {questStarted = 1538, questStorage = 65028, creatureStorage = 15073, killsRequired = 100, raceName = "Hellhounds"},

    ["juggernaut"] = {questStarted = 1539, questStorage = 65029, creatureStorage = 15075, killsRequired = 100, raceName = "Juggernauts"}
}
 
local msgType = MESSAGE_STATUS_CONSOLE_ORANGE
 
function onKill(cid, target, lastHit)
 
local creature = questCreatures[getCreatureName(target):lower()]
 
    if creature then
        if isPlayer(target) or isSummon(target) then return true end
 
        if getCreatureStorage(cid, creature.questStarted) > 0 then
            if getCreatureStorage(cid, creature.questStorage) < creature.killsRequired then
                if getCreatureStorage(cid, creature.questStorage) < 0 then
                    doCreatureSetStorage(cid, creature.questStorage, 0)
                end
 
                if getCreatureStorage(cid, creature.creatureStorage) < 0 then
                    doCreatureSetStorage(cid, creature.creatureStorage, 0)
                end
                doCreatureSetStorage(cid, creature.questStorage, getCreatureStorage(cid, creature.questStorage) + 1)
                doCreatureSetStorage(cid, creature.creatureStorage, getCreatureStorage(cid, creature.creatureStorage) + 1)
                doPlayerSendTextMessage(cid, msgType, getCreatureStorage(cid, creature.creatureStorage) .. " " .. getCreatureName(target) .. " defeated. Total [" .. getCreatureStorage(cid, creature.questStorage) .. "/" .. creature.killsRequired .. "] " .. creature.raceName .. ".")
            end
        end
    end
    return true
end

I'm not 100% sure if this is all the requiered configuration of the script, since I haven't take a look into this old datapack in some time.
Hope this conversion can be done, thanks in advance.

Regards!
 

Phoenixin

Active Member
Joined
Dec 20, 2009
Messages
14
Reaction score
26
Para que task son esos scrips grizli Addams? Necesito accer las task de grizzli Addams que el boot las haga solas
si necesitas ayuda de verdad intenta utilizar un mismo idioma para comunicarte, este es un foro de habla inglesa; si te sientes un poco excluido o necesitas comunicarte en tu idioma existe una sección de hablantes nativos del español.

PD: si tienes intención de que traduzcan tu mensaje, te recomiendo antes de realizar un post administrar bien tu ortografía ya que la tradución puede llegar a ser compleja para aquellos no nativos del español.
 
Top