• TibiaFace

    Tibiaface | Una comunidad Open Tibia donde encontras : mapas, scripts, Otserver, npc y amigos etc ...

    .
    demo menumenu

    Afiliados



    Votar:

    [Sistema] [1.5] Simple Task 4.0 | Vodkart | revscript

    Compartir:

    Ver el tema anterior Ver el tema siguiente Ir abajo  Mensaje (Página 1 de 1.)

    samsung123

    samsung123
    Miembro
    Miembro
    Créditos : Vodkart & Demonbholder
    Hice esto en otland, me da flojera traducir lo que hice antes. con el tiempo lo hare


    I am migrating from 0.4 to 1.5 I really liked a script of a Brazilian "Vodk". take the script and convert it to resvscript with 1.5 functions
    tested on 1.5 nekiro downgrade 8.0
    Context:
    task:kill certain amount of monsters, to receive rewards such as Exp, money and items. progressive
    you will have to finish task 1 to advance to task 2
    daily: same but you can get 1x every 24 hours to complete,

    Revscripts (CreatureEvent / talkations)

    scripts/taskandadaily.lua
    Código:
    -- original credits Simple Task 4.0 (tfs 0.4): Vodkart & Demonbholder

    local creatureEvent = CreatureEvent("Task")

    function creatureEvent.onLogin(player)
        player:registerEvent("killtasks")
        return true
    end

    creatureEvent:register()




    local talkAction = TalkAction("!task")

    function talkAction.onSay(player, words, param, type)
    param,task,daily = param:lower(), player:getTaskMission(), player:getDailyTaskMission()
    if isInArray({"counter","contador"},param) then
        print("counter")
        player:setStorageValue(task_sys_storages[8], player:getStorageValue(task_sys_storages[8]) <= 0 and 1 or 0)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,"[Task System] The counter was "..(player:getStorageValue(task_sys_storages[8]) <= 0 and "ativado" or "desativado")..".") return true
    elseif isInArray({"daily","diaria"},param) then
        print("daily")
        if not daily_task[daily] or player:getStorageValue(task_sys_storages[7]) <= 0 then
            player:sendCancelMessage("Sorry, but you're not on any Daily Task.") return true
        elseif player:getStorageValue(task_sys_storages[6]) - os.time() <= 0 and player:getStorageValue(task_sys_storages[5]) < daily_task[daily].count then
            player:showTextDialog("Sorry, but you didn't finish the Daily Task in time! Please go back to npc and start a new Daily Task!") return true
        end
        return player:showTextDialog(1953, "[->] CURRENT DAILY TASK INFO [<-]\n\nNome: "..daily_task[daily].name.."\nProgreso: ["..(player:getStorageValue(task_sys_storages[5]) < 0 and 0 or player:getStorageValue(task_sys_storages[5])).."/"..daily_task[daily].count.."]\nPlazo de entrega: "..os.date("%d %B %Y %X ", player:getStorageValue(task_sys_storages[6])).."\nMonsters to hunt:: "..getMonsterFromList(daily_task[daily].monsters_list).."\n\n[->] CURRENT TASK REWARDS [<-]\n\nMoney: "..(daily_task[daily].money > 0 and daily_task[daily].money or 0).."\nExperiencia: "..(daily_task[daily].exp > 0 and daily_task[daily].exp or 0).."\nTask Points: "..daily_task[daily].points.."\nItems: "..(#daily_task[daily].reward > 0 and getItemsFromList(daily_task[daily].reward) or "Nenhum item de recompensa")..".")
    end
    if not task_sys[task] or player:getStorageValue(task_sys[task].start) <= 0 then
        player:sendCancelMessage("you are not in any task.") return true
    end
    return player:showTextDialog(1953, "-> CURRENT TASK ["..player:getTaskMission().."/"..#task_sys.."] <-\n\nTask Name: "..task_sys[task].name.."\nTask Level: "..task_sys[task].level.."\nTask Progress: ["..(player:getStorageValue(task_sys_storages[3]) < 0 and 0 or player:getStorageValue(task_sys_storages[3])).."/"..task_sys[task].count.."]\nMonster To Hunt: "..getMonsterFromList(task_sys[task].monsters_list)..".\nItens Para Entrega: "..(#task_sys[task].items > 0 and getItemsFromList(task_sys[task].items) or "Nenhum")..".\n\n[->] CURRENT TASK REWARDS [<-]\n\nReward Money: "..(task_sys[task].money > 0 and task_sys[task].money or 0).."\nReward Experiencia: "..(task_sys[task].exp > 0 and task_sys[task].exp or 0).."\nReward Points: "..task_sys[task].points.."\nRedward Items: "..(#task_sys[task].reward > 0 and getItemsFromList(task_sys[task].reward) or "no reward items")..".")
    end

    --talkAction:accountType(ACCOUNT_TYPE_GOD)
    --talkAction:access(true)
    talkAction:separator(" ")
    talkAction:register()


    local creatureEvent = CreatureEvent("killtasks")

    function creatureEvent.onKill(creature, target)
    if creature:isPlayer() and target:isMonster() then
     
            local t,daily = task_sys[creature:getTaskMission()], daily_task[creature:getDailyTaskMission()]
      
            if t and creature:getStorageValue(t.start) > 0 and isInArray(t.monsters_list, target:getName()) and creature:getStorageValue(task_sys_storages[3]) < t.count then
        
                creature:setStorageValue(task_sys_storages[3], creature:getStorageValue(task_sys_storages[3]) < 0 and 1 or (creature:getStorageValue(task_sys_storages[3])+1))
                if creature:getStorageValue(task_sys_storages[8]) <= 0 and creature:getStorageValue(task_sys_storages[3]) < t.count then
                     creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE,"[Task System] defeated Total [" .. creature:getStorageValue(task_sys_storages[3]) .. "/" .. t.count .. "] of the Task of " .. t.name .. ".")
                end
                if creature:getStorageValue(task_sys_storages[3]) >= t.count then
                     creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE,"[Task System] Felicidades! You finished the Task of "..t.name..", go back to npc seems to get your reward.")
                end
            end
            if daily and creature:getStorageValue(task_sys_storages[7]) > 0 and creature:getStorageValue(task_sys_storages[6]) - os.time() >= 0 and isInArray(daily.monsters_list, target:getName()) and creature:getStorageValue(task_sys_storages[5]) < daily.count then
                creature:setStorageValue(task_sys_storages[5], creature:getStorageValue(task_sys_storages[5]) < 0 and 1 or (creature:getStorageValue(task_sys_storages[5])+1))
                if creature:getStorageValue(task_sys_storages[8]) <= 0 and creature:getStorageValue(task_sys_storages[5]) < daily.count then
                     creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,"[Daily Task System] defeated Total [" .. creature:getStorageValue(task_sys_storages[5]) .. "/" .. daily.count .. "] of the Task of " .. daily.name .. ".")
                end
                if creature:getStorageValue(task_sys_storages[5]) >= daily.count then
                     creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE,"[Daily Task System] Felicidades! You finished the Task of "..daily.name..", go back to npc seems to get your reward.")
                end
            end
        end
        return true
    end

    creatureEvent:register()


    data/global.lua
    add in the end

    Código:
    task_sys = {
        [1] = {name = "demon", start = 176201, monsters_list = {"demon"}, level = 8, count = 300, points = 0, items = {}, reward = {{2160,20}}, exp = 3000000, money = 2000},
    [2] = {name = "juggernaut", start = 176201, monsters_list = {"juggernaut"}, level = 8, count = 300, points = 0, items = {}, reward = {{2160,50}}, exp = 4000000, money = 2000},
    [3] = {name = "bazir", start = 176201, monsters_list = {"bazir"}, level = 8, count = 3, points = 0, items = {}, reward = {{2160,30}}, exp = 2000000, money = 2000},
    [4] = {name = "Birds", start = 176201, monsters_list = {"chicken","flamingo","parrot","penguin","seagull","terror bird"}, level = 8, count = 200, points = 0, items = {}, reward = {{2160,10}}, exp = 1000000, money = 2000},

    }
    daily_task = {
        [1] = {name = "juggernaut" ,monsters_list = {"juggernaut"}, count = 100, points = 3, reward = {{2173,1}}, exp = 130000, money = 200000},
        [2] = {name = "demon" ,monsters_list = {"demon"}, count = 30, points = 3, reward = {{2173,1}}, exp = 130000, money = 200000},
        [3] = {name = "Birds" ,monsters_list = {"chicken","flamingo","parrot","penguin","seagull","terror bir"}, count = 30, points = 3, reward = {{2173,1}}, exp = 130000, money = 200000},
        [4] = {name = "orshabaal" ,monsters_list = {"orshabaal"}, count = 30, points = 3, reward = {{2173,1}}, exp = 130000, money = 200000},
     
    }
    task_sys_storages = {176601, 176602, 176603, 176604, 176605, 176606, 176607, 176608} -- task, points, count, daily task, daily count, daily time , daily start, contador
    function Player.getTaskMission(self)
     
        return self:getStorageValue(task_sys_storages[1]) < 0 and 1 or self:getStorageValue(task_sys_storages[1])
    end
    function Player.getDailyTaskMission(self)
     
        return self:getStorageValue(task_sys_storages[4]) < 0 and 1 or self:getStorageValue(task_sys_storages[4])
    end
    function Player.getTaskPoints(self)
     
        return self:getStorageValue(task_sys_storages[2]) < 0 and 0 or self:getStorageValue(task_sys_storages[2])
    end

    function Player.randomDailyTask(self)
        local t = {
            [{6,49}] = {1,3},
            [{50,79}] = {1,3},
            [{80,129}] = {1,3},
            [{130,math.huge}] = {1,3}
        }
        for a , b in pairs(t) do
            if self:getLevel()  >= a[1] and self:getLevel() <= a[2] then
                return math.random(b[1], b[2])
            end
        end
        return 0
    end
    function Player.GetRankTask(self)
        local ranks = {
            [{1, 20}] = "Huntsman",
            [{21, 50}] = "Ranger",
            [{51, 100}] = "Big Game Hunter",
            [{101, 200}] = "Trophy Hunter",
            [{201, math.huge}] = "Elite Hunter"
        }
        for v , r in pairs(ranks) do
            if self:getTaskPoints() >= v[1] and self:getTaskPoints() <= v[2] then
                return r
            end
        end
        return 0
    end

    function getItemsFromList(items)
        local str = ''
        if table.maxn(items) > 0 then
            for i = 1, table.maxn(items) do
                str = str .. items[i][2] .. ' ' .. getItemName(items[i][1])
                if i ~= table.maxn(items) then str = str .. ', '
                end
            end
        end
        return str
    end


    function Player.doRemoveItemsFromList(self,items)
        local count = 0
        if table.maxn(items) > 0 then
            for i = 1, table.maxn(items) do
                if self:getItemCount(items[i][1]) >= items[i][2] then
                count = count + 1 end
            end
        end
        if count == table.maxn(items) then
            for i = 1, table.maxn(items) do self:removeItem(items[i][1],items[i][2]) end
        else
            return false
        end
        return true
    end

    function getMonsterFromList(monster)
        local str = ''
        if #monster > 0 then
            for i = 1, #monster do
                str = str .. monster[i]
                if i ~= #monster then str = str .. ', ' end
            end
        end
        return str
    end


    function Player.GiveRewardsTask(self, items)
        local backpack = self:addItem(1999, 1) -- backpackID
        for _, i_i in ipairs(items) do
            local item, amount = i_i[1],i_i[2]
            if isItemStackable(item) or amount == 1 then
                doAddContainerItem(backpack, item, amount)
            else
                for i = 1, amount do
                    doAddContainerItem(backpack, item, 1)
                end
            end
        end
    end

    NPC:
    data\npc\scripts
    create taskdaily.lua

    Código:
    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(),"",""

         task,daily, hours = player:getTaskMission(),player:getDailyTaskMission(), 24
        if isInArray({"task","tasks","missao","mission"}, msg) then
            if task_sys[task] then
                if player:getStorageValue(task_sys[task].start) <= 0 then
                    if player:getLevel() >= task_sys[task].level then
                        player:setStorageValue(task_sys[task].start, 1)
                        npcHandler:say("[Task System] Congratulations, you are now participating in the Task of "..task_sys[task].name.." and shall kill "..task_sys[task].count.." from this list: "..getMonsterFromList(task_sys[task].monsters_list)..". "..(#task_sys[task].items > 0 and "Oh and please bring me "..getItemsFromList(task_sys[task].items).." for me." or "").."" , cid)
                    else
                        npcHandler:say("Sorry, but you need to reach level "..task_sys[task].level.." to be able to participate in the Task of "..task_sys[task].name.."!", cid)
                    end
                else
                    npcHandler:say("Sorry, but you are currently on the task "..task_sys[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","daili","daily","dayli","diario"}, msg) then
            if player:getStorageValue(task_sys_storages[6]) - os.time() > 0 then
                npcHandler:say("Sorry, you must wait until "..os.date("%d %B %Y %X ", player:getStorageValue(task_sys_storages[6])).." to start a new daily task!", cid) return true
            elseif daily_task[daily] and player:getStorageValue(task_sys_storages[5]) >= daily_task[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(task_sys_storages[4], r)
            player:setStorageValue(task_sys_storages[6], os.time()+hours*3600)
            player:setStorageValue(task_sys_storages[7], 1)
            player:setStorageValue(task_sys_storages[5], 0)
           local dtask = daily_task[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(task_sys_storages[6]))..". Good luck!" , cid)
        elseif isInArray({"receber","reward","recompensa","report","reportar","entregar","entrega"}, msg) then
            local v, k = task_sys[task], daily_task[daily]
            if v then -- original task
                if player:getStorageValue(v.start) > 0 then
                    if player:getStorageValue(task_sys_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.."".. (str == "" and "" or ", ") .." "..v.exp.." de exp" end
                     if v.points > 0 then player:setStorageValue(task_sys_storages[2], (player:getTaskPoints()+v.points)) str = str.."".. (str == "" and "" or ", ") .." + "..v.points.."task points" end
                     if v.money > 0 then player:addMoney(v.money) str = str.."".. (str == "" and "" or ", ") ..""..v.money.." gps" end
                     if table.maxn(v.reward) > 0 then player:GiveRewardsTask(v.reward) str = str.."".. (str == "" and "" or ", ") ..""..getItemsFromList(v.reward) end
                        npcHandler:say("Thanks for your help Rewards: "..(str == "" and "nenhuma" or ""..str.."").." for completing the task of "..v.name, cid)
                        player:setStorageValue(task_sys_storages[3], 0)
                        player:setStorageValue(task_sys_storages[1], (task+1))
                    else
                        npcHandler:say("Sorry, but you haven't finished your do task yet. "..v.name..". I need you to kill more "..(player:getStorageValue(task_sys_storages[3]) < 0 and v.count or -(player:getStorageValue(task_sys_storages[3])-v.count)).." of these terrible monsters!", cid)
                    end
                end
            end
            if k then -- daily task
                if player:getStorageValue(task_sys_storages[7]) > 0 then
                    if player:getStorageValue(task_sys_storages[5]) >= k.count then
                    if k.exp > 0 then player:addExperience(k.exp) rst = rst.."".. (rst == "" and "" or ", ") .." "..k.exp.." de exp" end
                     if k.points > 0 then player:setStorageValue(task_sys_storages[2], (player:getTaskPoints()+k.points)) rst = rst.."".. (rst == "" and "" or ", ") .." + "..k.points.."task points" end
                     if k.money > 0 then player:addMoney(k.money) rst = rst.."".. (rst == "" and "" or ", ") ..""..k.money.." gps" end
                     if table.maxn(k.reward) > 0 then player:GiveRewardsTask(k.reward) rst = rst.."".. (rst == "" and "" or ", ") ..""..getItemsFromList(k.reward) end
                        npcHandler:say("Obrigado pela sua ajuda! Recompensas: "..(rst == "" and "nenhuma" or ""..rst.."").." por ter completado a task do "..k.name, cid)
                        player:setStorageValue(task_sys_storages[4], 0)
                        player:setStorageValue(task_sys_storages[5], 0)
                        player:setStorageValue(task_sys_storages[7], 0)
                        else
                        npcHandler:say("Sorry, but you still haven't finished your daily task "..k.name..". I need you to kill more "..(player:getStorageValue(task_sys_storages[5]) < 0 and k.count or -(player:getStorageValue(task_sys_storages[5])-k.count)).." of these monsters!", cid)
                    end
                end
            end
        elseif msg == "no" then
            selfSay("Tudo bem então", cid)
            talkState[talkUser] = 0
            npcHandler:releaseFocus(cid)
        end
        return true
    end
    npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    npcHandler:addModule(FocusModule:new())


    NPC.XML
    data\npc
    Create Daily y tasks.xml

    Código:
    <?xml version="1.0" encoding="UTF-8"?>
    <npc name="task and daily" script="taskdaily.lua" walkinterval="0">
        <health now="100" max="100"/>
        <look type="657"/>
        <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>


    Setting: in global.lua
    very easy

    Código:
    task_sys = {

        [1] = {name = "demon", start = 176201, monsters_list = {"demon"}, level = 8, count = 300, points = 0, items = {}, reward = {{2160,20}}, exp = 3000000, money = 2000},

    [2] = {name = "juggernaut", start = 176201, monsters_list = {"juggernaut"}, level = 8, count = 300, points = 0, items = {}, reward = {{2160,50}}, exp = 4000000, money = 2000},

    [3] = {name = "bazir", start = 176201, monsters_list = {"bazir"}, level = 8, count = 3, points = 0, items = {}, reward = {{2160,30}}, exp = 2000000, money = 2000},

    [4] = {name = "Birds", start = 176201, monsters_list = {"chicken","flamingo","parrot","penguin","seagull","terror bird"}, level = 8, count = 200, points = 0, items = {}, reward = {{2160,10}}, exp = 1000000, money = 2000},



    }

    daily_task = {

        [1] = {name = "juggernaut" ,monsters_list = {"juggernaut"}, count = 100, points = 3, reward = {{2173,1}}, exp = 130000, money = 200000},

        [2] = {name = "demon" ,monsters_list = {"demon"}, count = 30, points = 3, reward = {{2173,1}}, exp = 130000, money = 200000},

        [3] = {name = "Birds" ,monsters_list = {"chicken","flamingo","parrot","penguin","seagull","terror bir"}, count = 30, points = 3, reward = {{2173,1}}, exp = 130000, money = 200000},

        [4] = {name = "orshabaal" ,monsters_list = {"orshabaal"}, count = 30, points = 3, reward = {{2173,1}}, exp = 130000, money = 200000},

     

    }

    use:
    go NPC
    hi
    daily
    task
    kill monster

    10:43 escribió:[Task System] defeated Total [3/300] of the Task of demon."

    !task (shows progress and information)

    s escribió:-> CURRENT TASK [2/4] <-

    Task Name: demon

    Task Level: 8

    Task Progress: [3/300]

    Monster To Hunt: demon.

    Itens Para Entrega: Nenhum.



    [->] CURRENT TASK REWARDS [<-]

    Reward Money: 2000

    Reward Experiencia: 4000000

    Reward Points: 0

    Redward Items: 1 amulet of loss.."


    !task daily (same but only daily)


    !task counter (It is a command that turns ON or OFF the counter of monsters killed in the task on its Channel.)


    Note:
    • i delete look system because I don't like haha
    • I don't know the difference between global.lua and lib . I have more experience in global so I put all the functions there. I don't know if it's correct
    • google traductor xd



    Requires test

    im not expert

    2 participantes

    kierko95

    kierko95
    Nuevo Miembro
    Nuevo Miembro
    wow, nice mean !! thx

    2 participantes

    Ver el tema anterior Ver el tema siguiente Volver arriba  Mensaje (Página 1 de 1.)

    Permisos de este foro:
    No puedes responder a temas en este foro.

     

    BienvenidosTibiaFace es una comunidad de Open Tibia. Para participar debes estar registrado (click para Regístrate).