• 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 task questlog simple question

olekpro

Member
Joined
Nov 1, 2014
Messages
121
Reaction score
6
Lua:
function task:new(player, npcHandler)
    if task:getCompleted(player) > 0 then
        player:setStorageValue(task.storage.questlog,2)
        task:reward(player, npcHandler)
        task:set(player, 0)
        return false
    end

    if task:onTask(player) > 0 then
        npcHandler:say("You already have a task.", player:getId())
        task:debug(player:getName() .. " is already on a task " .. task.tasks[task:onTask(player)].name  .. ".")
        return false
    end

    local lastFinished = task:getFinished(player)
    if lastFinished == #task.tasks then
        npcHandler:say("You have completed all the tasks!", player:getId())
        return false
    end

    local newTask = lastFinished + 1
    task:set(player, newTask)
    npcHandler:say(task.tasks[newTask].description, player:getId())
    player:setStorageValue(task.storage.questlog + 1,1)

    return true

end

how to save player task.storage.questlog for each player? it reset after function for basic value...
 
XML:
<quest name="Monster Slayer" startstorageid="20001" startstoragevalue="1">
        <mission name="Rotworm Slayer" storageid="20002" startvalue="1" endvalue="3">
            <missionstate id="1" description="You are trying to help our server by killing monsters! Your quest now is: kill rotworms!" />
            <missionstate id="2" description="Help me again to complete this task!" />
            <missionstate id="3" description="You did it! Good job!!" />
        </mission>
        <mission name="Dragon Slayer" storageid="20003" startvalue="1" endvalue="3">
            <missionstate id="1" description="You are trying to help our server by killing monsters! Your quest now is: kill dragons!" />
            <missionstate id="2" description="Help me again to complete this task!" />
                        <missionstate id="3" description="You did it! Good job!!" />
        </mission>
        <mission name="Demon" storageid="20004" startvalue="1" endvalue="3">
            <missionstate id="1" description="demonz!" />
            <missionstate id="2" description="Help me again to complete this task!" />
                        <missionstate id="3" description="You did it! Good job!!" />
        </mission>
             <mission name="Black Knight" storageid="20005" startvalue="1" endvalue="3">
            <missionstate id="1" description="rats!" />
            <missionstate id="2" description="Help me again to complete this task!" />
                        <missionstate id="3" description="You did it! Good job!!" />
        </mission>
                <mission name="Dragon Lord" storageid="20006" startvalue="1" endvalue="3">
            <missionstate id="1" description="test5!" />
            <missionstate id="2" description="Help me again to complete this task!" />
                        <missionstate id="3" description="You did it! Good job!!" />
        </mission>
        
    </quest>



first:

Lua:
local newTask = lastFinished + 1
    task:set(player, newTask)
    npcHandler:say(task.tasks[newTask].description, player:getId())
        if player:getStorageValue(task.storage.questlog) == 1 then             
        player:setStorageValue((task.storage.questlog),2)                       
        player:setStorageValue(task.storage.questlog+1,1)                       
        return false
        end
        if player:getStorageValue(task.storage.questlog + 1) == 2 then         
        player:setStorageValue((task.storage.questlog +1),3)                   
        player:setStorageValue(task.storage.questlog+2,1)                 
        return false
        end
        if player:getStorageValue(task.storage.questlog + 2) == 2 then         
        player:setStorageValue((task.storage.questlog+2),3)             
        player:setStorageValue(task.storage.questlog+3,1)             
        return false
        end
        if player:getStorageValue(task.storage.questlog + 3) == 2 then         
        player:setStorageValue((task.storage.questlog+3),3)                 
        player:setStorageValue(task.storage.questlog+4,1)               
        return false
        end

        if player:getStorageValue(task.storage.questlog + 4) == 2 then         
            player:setStorageValue((task.storage.questlog+4),3)               
            player:setStorageValue(task.storage.questlog+5,1)               
            return false
            end

    return true

end

Lua:
function task:new(player, npcHandler)
    if task:getCompleted(player) > 0 then
        if player:getStorageValue(task.storage.questlog + 1) == 1 then           
            player:setStorageValue(task.storage.questlog+1,2)                
            task:reward(player, npcHandler)
            task:set(player, 0)
        return false
        end
        if player:getStorageValue(task.storage.questlog + 2) == 1 then       
                 player:setStorageValue(task.storage.questlog+2,2)       
                 task:reward(player, npcHandler)
                 task:set(player, 0)
        return false
        end
        if player:getStorageValue(task.storage.questlog + 3) == 1 then          
                 player:setStorageValue(task.storage.questlog+3,2)            
                 task:reward(player, npcHandler)
                 task:set(player, 0)
        return false
        end
        if player:getStorageValue(task.storage.questlog + 4) == 1 then         
                 player:setStorageValue(task.storage.questlog+4,2)            
                 task:reward(player, npcHandler)
                 task:set(player, 0)
        return false
        end
        task:reward(player, npcHandler)
        task:set(player, 0)

        if player:getStorageValue(task.storage.questlog + 5) == 1 then       
            player:setStorageValue(task.storage.questlog+5,3)           
            task:reward(player, npcHandler)
            task:set(player, 0)
   return false
   end
   task:reward(player, npcHandler)
   task:set(player, 0)
        return false
    end
It is working well now. But.. this code look horrible and adding new "task" is sick, can somebody automatic it?
you see always +2, +3, +4 made some function p = p +1 idk how because ALWAYS p is reset..i don't get it already
 
Back
Top