Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --npc/scripts/task.lua
- local tasks =
- {
- [1] = {questStarted = 1510, questStorage = 65000, killsRequired = 600,mount = "Widow Queen", raceName = "Giant Spiders", rewards = {{enable = true, type = "item", values = 9007}}},
- [2] = {questStarted = 1511, questStorage = 65001, killsRequired = 400,mount = "Racing Bird", raceName = "medusas", rewards = {{enable = true, type = "item", values = 10127}}},
- [3] = {questStarted = 1512, questStorage = 65002, killsRequired = 800,mount = "War Bear", raceName = "Cyclops", rewards = {{enable = true, type = "item", values = 9019}}},
- [4] = {questStarted = 1513, questStorage = 65003, killsRequired = 500,mount = "black sheep", raceName = "Necromancers", rewards = {{enable = true, type = "item", values = 10129}}},
- [5] = {questStarted = 1514, questStorage = 65004, killsRequired = 700,mount = "Midnight Panther", raceName = "Dark Torturers", rewards = {{enable = true, type = "item", values = 9653}}},
- [6] = {questStarted = 1515, questStorage = 65005, killsRequired = 500,mount = "draptor", raceName = "Lizards chosens", rewards = {{enable = true, type = "item", values = 9662}}},
- [7] = {questStarted = 1516, questStorage = 65006, killsRequired = 300,mount = "titanica", raceName = "Water Elementals",rewards = {{enable = true, type = "item", values = 9981}}},
- [8] = {questStarted = 1517, questStorage = 65007, killsRequired = 400,mount = "Tin Lizzard", raceName = "Dragon lords", rewards = {{enable = true, type = "item", values = 9980}}},
- [9] = {questStarted = 1518, questStorage = 65008, killsRequired = 900,mount = "Blazebringer", raceName = "Demons", rewards = {{enable = true, type = "item", values = 10108}}},
- [10] = {questStarted = 1519, questStorage = 65009, killsRequired = 700,mount = "Rapid Boar", raceName = "Behemoths", rewards = {{enable = true, type = "item", values = 10124}}},
- [11] = {questStarted = 1520, questStorage = 65010, killsRequired = 800,mount = "Stampor Mount", raceName = "Hydras", rewards = {{enable = true, type = "item", values = 10125}}},
- [12] = {questStarted = 1521, questStorage = 65011, killsRequired = 100,mount = "Undead Cadaver", raceName = "Armagedons", rewards = {{enable = true, type = "item", values = 11773}}},
- [13] = {questStarted = 1522, questStorage = 65012, killsRequired = 400,mount = "Dragon ", raceName = "Dragons", rewards = {{enable = true, type = "item", values = 10530}}},
- [14] = {questStarted = 1523, questStorage = 65013, killsRequired = 700,mount = "Nightmare", raceName = "Nightmares", rewards = {{enable = true, type = "item", values = 8974}}},
- [15] = {questStarted = 1524, questStorage = 65014, killsRequired = 400,mount = "Quara Predator", raceName = "Quara Predators", rewards = {{enable = true, type = "item", values = 10142}}},
- [16] = {questStarted = 1525, questStorage = 65015, killsRequired = 800,mount = "Undead Dragon", raceName = "Undead Dragons", rewards = {{enable = true, type = "item", values = 10150}}},
- [17] = {questStarted = 1526, questStorage = 65016, killsRequired = 700,mount = "Panda", raceName = "Warlocks", rewards = {{enable = true, type = "item", values = 10173}}},
- [18] = {questStarted = 1527, questStorage = 65017, killsRequired = 700,mount = "Tarantula ", raceName = "Tarantulas", rewards = {{enable = true, type = "item", values = 6102}}},
- [19] = {questStarted = 1528, questStorage = 65018, killsRequired = 500,mount = "Donkey ", raceName = "furys", rewards = {{enable = true, type = "item", values = 12641}}},
- [20] = {questStarted = 1529, questStorage = 65019, killsRequired = 300,mount = "Tiger Slug ", raceName = "deepling warriors", rewards = {{enable = true, type = "item", values = 8298}}},
- [21] = {questStarted = 1530, questStorage = 65020, killsRequired = 600,mount = "Uniwheel ", raceName = "war golems", rewards = {{enable = true, type = "item", values = 13292}}},
- [22] = {questStarted = 1531, questStorage = 65021, killsRequired = 700,mount = "Crystal Wolf ", raceName = "mad mages", rewards = {{enable = true, type = "item", values = 13293}}},
- [23] = {questStarted = 1532, questStorage = 65022, killsRequired = 700,mount = "War Horse ", raceName = "deepling giant pros", rewards = {{enable = true, type = "item", values = 13294}}},
- [24] = {questStarted = 1533, questStorage = 65023, killsRequired = 800,mount = "Kingly Deer ", raceName = "floor blobs", rewards = {{enable = true, type = "item", values = 13298}}},
- [25] = {questStarted = 1534, questStorage = 65024, killsRequired = 800,mount = "Tamed Panda ", raceName = "crawlers", rewards = {{enable = true, type = "item", values = 13295}}},
- [26] = {questStarted = 1535, questStorage = 65025, killsRequired = 800,mount = "Dromedary ", raceName = "spidiris", rewards = {{enable = true, type = "item", values = 13307}}},
- [27] = {questStarted = 1536, questStorage = 65026, killsRequired = 600,mount = "King Scorpion ", raceName = "deepling guards", rewards = {{enable = true, type = "item", values = 13305}}},
- [28] = {questStarted = 1537, questStorage = 65027, killsRequired = 50,mount = "Horse ", raceName = "esmeraldas", rewards = {{enable = true, type = "item", values = 10063}}},
- [29] = {questStarted = 1538, questStorage = 65028, killsRequired = 700,mount = "Fire War Horse ", raceName = "askarak demons", rewards = {{enable = true, type = "item", values = 13247}}},
- [30] = {questStarted = 1539, questStorage = 65029, killsRequired = 900,mount = "Shadow Draptor ", raceName = "kollos", rewards = {{enable = true, type = "item", values = 13538}}},
- }
- 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.", cid)
- local text = ""
- for i = 1, table.maxn(tasks) do
- text = text .. (text == "" and "" or "\n") .. i .. " - " .. tasks[i].raceName .. " ["..tasks[i].mount.. " mount] ".. (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
- 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)
- 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() == "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
- if(tasks[t].rewards[i].enable) then
- if isInArray({"item", 1}, tasks[t].rewards[i].type) then
- doPlayerAddItem(cid, tasks[t].rewards[i].values, 1)
- end
- end
- end
- local rank = getCreatureStorage(cid, rankStorage)
- selfSay("Great!... you have finished the task number " .. t .. ", Good job.", cid)
- return doCreatureSetStorage(cid, tasks[t].questStarted, 2)
- end
- return true
- end
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Add Comment
Please, Sign In to add comment