Ir para conteúdo
DESCRIÇÃO
Anuncie aqui neste countdown e dê maior visibilidade ao seu lançamento | Full Global • Custom Quests • Custom Outfits • Lottery System • Version 15x
Inicia em: --
Participar

Featured Replies

Postado

Olá boa noite.

Preciso de uma ajuda de vocês

Estou com script de task de addon porem ele entrega o item addon doll para o player após cumprir sua task.

Porem gostaria que o próprio npc adiciona o addon completo após o player finalizar sua task em vez de dar o item como recompensa.

Lib

Citar

TASK_ADDON = {

    addon_doll_ID = 11138,
    
    addons = {
        ["citizen"] = {
            [0] = {lookType = 136, addons = 3},
            [1] = {lookType = 128, addons = 3}
        },
        ["wizard"] = {
            [0] = {lookType = 149, addons = 3},
            [1] = {lookType = 145, addons = 3}
        },
        ["summoner"] = {
            [0] = {lookType = 141, addons = 3},
            [1] = {lookType = 133, addons = 3}
        },
        ["warrior"] = {
            [0] = {lookType = 142, addons = 3},
            [1] = {lookType = 134, addons = 3}
        }
    },

    monsters = {
        ["dragon"] = {storage = 7010, mstorage = 70000, amount = 10, exp = 0, addon = "citizen", races = {"dragon hatchling", "dragon lord", "dragon lord hatchling"}},
        ["cyclops"] = {storage = 7011, mstorage = 70001, amount = 5, exp = 1500, addon = "wizard", races = {"cyclops drone", "cyclops smith", "cyclops warrior"}},
        ["rotworm"] = {storage = 7012, mstorage = 70002, amount = 8, exp = 1500, addon = "warrior", races = {"carrion worm"}},
        ["hydra"] = {storage = 7013, mstorage = 70003, amount = 1, exp = 500, addon = "summoner"}
    },
    
    storage = 52000
}

function doPlayerReceiveAddonDoll(cid, addon_name)
    local doll = doPlayerAddItem(cid, TASK_ADDON.addon_doll_ID, 1)
    local descr = getItemDescriptionsById(TASK_ADDON.addon_doll_ID).description
    local newLine = descr:len() > 0 and "\n" or ""
    doItemSetAttribute(doll, "description", string.format("%s %sIt contains the %s addon.", descr, newLine, addon_name))
end

function getTaskMonsterByAddon(addon)
    for monster, info in pairs(TASK_ADDON.monsters) do
        if info.addon == addon then
            return monster
        end
    end
end

 

Npc

Citar

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local npcTopic, xmsg = {}, {}
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 capitalizeAll(str) -- by dwarfer
    return str:lower():gsub("%w+", 
        function(w) 
          return w:sub(1,1):upper() .. w:sub(2)
    end)
end

function creatureSayCallback(cid, type, msg)
    local talkUser, msg = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, string.lower(msg)
    if(not npcHandler:isFocused(cid)) then
        if isInArray({"hi", "hello"}, msg) then
            npcHandler:addFocus(cid)
            npcHandler:say("Hi, "..getPlayerName(cid)..". If you are interested in doing some {tasks}, I can reward you up to your work. Besides, you can {stop} your currently task or see a reward {list}.", cid)
            npcTopic[talkUser] = 1
        else
            return false
        end
    elseif msgcontains(msg, "tasks") and npcTopic[talkUser] == 1 then
        if getPlayerStorageValue(cid, TASK_ADDON.storage) == -1 then
            local text, n = "",  0
            for k, x in pairs(TASK_ADDON.monsters) do
                if getPlayerStorageValue(cid, x.mstorage) < x.amount then
                    n = n + 1
                    text = text .. "{"..capitalizeAll(x.addon).."}"..", "
                end
            end
            if n > 1 then
                npcHandler:say("I have tasks addons for " .. text .. " which one do you choose?", cid)
                npcTopic[talkUser] = 2
                xmsg[talkUser] = msg
            elseif n == 1 then
                npcHandler:say("I have one last task for you" .. text .. " addon.", cid)
                npcTopic[talkUser] = 2
            else
                npcHandler:say("You already did all tasks, I have nothing for you to do anymore, good job though.", cid)
                npcTopic[talkUser] = 0
            end
        else
            for k, x in pairs(TASK_ADDON.monsters) do
                if getPlayerStorageValue(cid, x.storage) == 1 then
                    npcHandler:say("Did you kill "..x.amount.." "..k.."?", cid)
                    npcTopic[talkUser] = 3
                    xmsg[talkUser] = k
                end
            end
        end
    elseif TASK_ADDON.monsters[getTaskMonsterByAddon(msg)] and npcTopic[talkUser] == 2 then 
        local task = TASK_ADDON.monsters[getTaskMonsterByAddon(msg)] 
        if getPlayerStorageValue(cid, task.storage) == -1 then
            npcHandler:say("Good luck, come back when you killed "..task.amount.." "..capitalizeAll(getTaskMonsterByAddon(msg))..".", cid)
            setPlayerStorageValue(cid, TASK_ADDON.storage, 1)
            setPlayerStorageValue(cid, task.storage, 1)
            npcTopic[talkUser] = 0
        else
            npcHandler:say("You already did the "..capitalizeAll(msg).." mission.", cid)
        end
    elseif msgcontains(msg, "yes") and npcTopic[talkUser] == 3 then
        if getPlayerStorageValue(cid, TASK_ADDON.storage) == 1 then
            for k, p in pairs(TASK_ADDON.monsters) do
                if getPlayerStorageValue(cid, p.storage) == 1 then
                    xmsg[talkUser] = k
                end
            end
            local x = TASK_ADDON.monsters[xmsg[talkUser]]
            if getPlayerStorageValue(cid, x.mstorage) >= x.amount then
                local addon_name = x.addon
                npcHandler:say("Good job! As promised, I will reward you properly. Take this valuable addon doll! It contains the "..addon_name.." addon.", cid)
                doPlayerReceiveAddonDoll(cid, x.addon)
                if x.exp > 0 then
                    doSendAnimatedText(getPlayerPosition(cid), x.exp, COLOR_WHITE)
                    doPlayerAddExperience(cid, x.exp)
                end
                setPlayerStorageValue(cid, TASK_ADDON.storage, -1)
                setPlayerStorageValue(cid, x.storage, 2)
                npcTopic[talkUser] = 4
            else
                npcHandler:say("You didn't kill them all, you still need to kill "..x.amount -(getPlayerStorageValue(cid, x.mstorage) + 1).." "..xmsg[talkUser]..".", cid)
                npcTopic[talkUser] = 0
            end
        else
            npcHandler:say("You didn't start any new task yet, if you want to start one, you can choose among some {tasks}.", cid)
            npcTopic[talkUser] = 1
        end
    elseif msgcontains(msg, "no") and npcTopic[talkUser] == 3 then
        npcHandler:say("I understood. It is not an easy task. Come back when you finished.", cid)
        npcTopic[talkUser] = 1
    elseif msgcontains(msg, "task") and npcTopic[talkUser] == 4 then
        local text, n = "", 0
        for k, x in pairs(TASK_ADDON.monsters) do
            if getPlayerStorageValue(cid, x.storage) < 2 then
                n = n + 1
                text = text .. (n == 1 and "" or ", ")
                text = text .. "{"..capitalizeAll(k).."}"
            end
        end
        if text ~= "" then
            npcHandler:say("Want to do another task? You can choose "..text..".", cid)
            npcTopic[talkUser] = 2
        else
            npcHandler:say("You already did all tasks.", cid)
            npcTopic[talkUser] = 0
        end
    elseif msgcontains(msg, "stop") and npcTopic[talkUser] == 1 then
        local text, n = "",  0
        for k, x in pairs(TASK_ADDON.monsters) do
            if getPlayerStorageValue(cid, x.storage) < 2 then
                n = n + 1
                text = text .. (n == 1 and "" or ", ")
                text = text .. "{"..capitalizeAll(x.addon).."}"
                if getPlayerStorageValue(cid, x.storage) == 1 then
                    setPlayerStorageValue(cid, x.storage, -1)
                    setPlayerStorageValue(cid, x.mstorage, -1)
                end
            end
        end
        if text ~= "" then
            if getPlayerStorageValue(cid, TASK_ADDON.storage) == 1 then
                npcHandler:say("Alright, let me know if you want to continue another task addon, you can still choose "..text..".", cid)
            else
                npcHandler:say("You didn't start any new task addon yet, if you want to start one, you can choose "..text..".", cid)
            end
            setPlayerStorageValue(cid, TASK_ADDON.storage, -1)
            npcTopic[talkUser] = 2
        else
            npcHandler:say("You have already finished all my tasks. Good job!", cid)
            npcTopic[talkUser] = 1
        end
    elseif msgcontains(msg, "list") and npcTopic[talkUser] == 1 then
        local text = "Addon Tasks\n\n"
        for k, x in pairs(TASK_ADDON.monsters) do
            if getPlayerStorageValue(cid, x.storage) < 2 then
                local count = getPlayerStorageValue(cid, x.mstorage) < x.amount and 1 or 0
                text = text ..capitalizeAll(k).. " [" .. (getPlayerStorageValue(cid, x.mstorage) + count).. "/" .. x.amount .. "]:\n Reward: "..capitalizeAll(x.addon).." Addon Doll\n ".. (x.exp > 0 and x.exp .." experience points \n\n" or "\n")
            else
                text = text .. capitalizeAll(k) .. " [DONE]\n\n"
            end
        end
        doShowTextDialog(cid, 1953, text)
        npcHandler:say("Here you are.", cid)
    elseif msgcontains(msg, "bye") then
        npcHandler:say("Bye.", cid)
        npcHandler:releaseFocus(cid)
    else
        npcHandler:say("I'm very busy for jokes now...", cid)
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

 

 

 

  • 4 months later...

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.1k
  • Posts 512.4k

Informação Importante

Confirmação de Termo