Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- domodlib('task_func')
- 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 talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
- local msg = string.lower(msg)
- if isInArray({"task","tasks"}, msg) then
- npcHandler:say("Hmm.. you need an task mission, yah? I can give you acess to kill {rat}, {troll}, {rotworm}, {cyclops}, {thornback tortoise}, {tarantula}, {monkey}, {mammoth}, {carniphila}, {minotaur}, {stone golem}, {dragon}, {bonebeast}, {ice golem}, {crystal spider}, {nightmare}, {hydra}, {giant spider}, {ancient scarab}, {bonebeast}, {nightmare}, {serpent spawn}, {medusa}, {} and {}. What creature you want to hunt?", cid)
- talkState[talkUser] = 1
- elseif talkState[talkUser] == 1 then
- if tasktabble[msg] then
- if CheckTask(cid) ~= true then
- local contagem = getPlayerStorageValue(cid, tasktabble[msg].storage)
- if (contagem == -1) then contagem = 1 end
- if not tonumber(contagem) then npcHandler:say('Sorry, you finished task of '..msg, cid) return true end
- setPlayerStorageValue(cid, tasktabble[msg].storage_start, 1)
- npcHandler:say("Great! you started the "..msg.." task and need to kill "..string.sub(((contagem)-1)-tasktabble[msg].count, 2).." ."..msg, cid)
- talkState[talkUser] = 0
- else
- npcHandler:say('Sorry, you are in a task!', cid)
- talkState[talkUser] = 0
- end
- else
- npcHandler:say('I need the correct information about the creature, please use {!task} to see all tasks availables.', cid)
- talkState[talkUser] = 1
- end
- elseif isInArray({"receber","reward","report"}, msg) then
- if CheckTask(cid) then
- for k, v in pairs(tasktabble) do
- racetype = k
- if getPlayerStorageValue(cid,v.storage_start) >= 1 then
- local contagem = getPlayerStorageValue(cid, v.storage)
- if (contagem == -1) then contagem = 1 end
- if not tonumber(contagem) then npcHandler:say('You only can receive the itens one time per task!', cid) return true end
- if (((contagem)-1) >= v.count) then
- for _, check in pairs(configbosses_task) do
- if string.lower(check.race) == string.lower(racetype) then
- local on = getPlayersOnline()
- for i=1, #on do
- if HavePlayerPosition(on[i], check.FromPosToPos[1],check.FromPosToPos[2]) then
- selfSay('aguarde alguns instantes, tem pessoas fazendo a task.', cid) return true
- end
- end
- doTeleportThing(cid, check.Playerpos)
- local function checkArea(cid)
- if not isCreature(cid) then return LUA_ERROR end
- if HavePlayerPosition(cid, check.FromPosToPos[1],check.FromPosToPos[2]) then
- doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
- end
- end
- addEvent(checkArea, check.time*60*1000, cid)
- end
- end
- local str = ""
- if v.exp ~= nil then doPlayerAddExp(cid, v.exp ) str = str.."".. (str == "" and "" or "and ") .." "..v.exp.." experience points" end
- if v.money ~= nil then doPlayerAddMoney(cid, v.money) str = str.."".. (str == "" and "" or "and ") ..""..v.money.." gps" end
- if v.reward ~= nil then doAddItemsFromList(cid,v.reward) str = str.."".. (str == "" and "" or ", ") ..""..getItemsFromList(v.reward) end
- npcHandler:say("Thank you for helping! Your reward is:"..(str == "" and "nothing" or ""..str.."").." for finish the task "..k, cid)
- setPlayerStorageValue(cid, v.storage, "Finished")
- setPlayerStorageValue(cid, v.storage_start, 0)
- setPlayerStorageValue(cid, 521456, getPlayerStorageValue(cid, 521456) == -1 and 1 or getPlayerStorageValue(cid, 521456)+1)
- finisheAllTask(cid)
- else
- npcHandler:say('Sorry, you killed only '..((contagem)-1)..' de '..v.count..' '..k, cid)
- end
- end
- end
- else
- npcHandler:say("You are not in a task to receive an reward.", cid)
- end
- elseif isInArray({"sair","leave","exit"}, msg) then
- if CheckTask(cid) then
- talkState[talkUser] = 2
- for k, v in pairs(tasktabble) do
- if getPlayerStorageValue(cid,v.storage_start) >= 1 then
- storagesair = v.storage_start
- local contagem = getPlayerStorageValue(cid, v.storage)
- if (contagem == -1) then contagem = 1 end
- npcHandler:say('You have an progress off '..k..' and have killed '..((contagem)-1)..' '..k..' really want to leave from this task?', cid)
- end
- end
- else
- npcHandler:say("You are not in a task.", cid)
- end
- elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
- setPlayerStorageValue(cid, storagesair, 0)
- npcHandler:say("Você foi retirado da task com sucesso!", cid)
- elseif msg == "no" then
- selfSay("Ok.", cid)
- talkState[talkUser] = 0
- npcHandler:releaseFocus(cid)
- end
- return TRUE
- end
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement