Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local keywordHandler = KeywordHandler:new()
- local npcHandler = NpcHandler:new(keywordHandler)
- NpcSystem.parseParameters(npcHandler)
- 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 tfocus = {}
- local tasks = {
- ["crocodile"] = {name = "Crocodile", count = 300, level = {6, 490}, exp = 800, pawpoint = 1, bosspoint = 1, initmsg = "They are a nuisance! You’ll find them here in the jungle near the river. Hunt %d crocodiles and you’ll get a nice reward. Interested?", yesmsg = "Happy hunting, old chap! Come back to me when you are through with your task.", winmsg = "You has killed all the crocodiles, take this reward!", failmsg = "You don't killed all the crocodiles, go kill! %d Crocodiles waiting for you...", storage = 9853},
- ["badger"] = {name = "Badger", count = 300, level = {6, 49}, exp = 500, pawpoint = 1, bosspoint = 1, initmsg = "", yesmsg = "", winmsg = "", failmsg = "", storage = 9852},
- }
- function creatureSayCallback(cid, type, msg)
- if(not npcHandler:isFocused(cid)) then
- return false
- end
- if msgcontains(msg:lower(), "task") or msgcontains(msg:lower(), "mission") then
- npcHandler:say("All right, what would you like to hunt, want to see the {list} ?", cid)
- tfocus[cid] = 1
- elseif msgcontains(msg:lower(), "list") then
- local str = "List: \n\n"
- for k, v in pairs(tasks) do
- str = str..v.name.." -> Count: "..v.count.." Level Min: "..v.level[1].." Level Max: "..v.level[2].." Experience gain: "..v.exp.." Paw & Fur Points: "..v.pawpoint.." Boss Points: "..v.bosspoint..".\n\n"
- end
- doShowTextDialog(cid, 2160, str)
- tfocus[cid] = 1
- elseif tasks[msg:lower()] and tfocus[cid] == 1 then
- local task = tasks[getPlayerStorageValue(cid, "taskname")] and tasks[getPlayerStorageValue(cid, "taskname")] or tasks[msg:lower()]
- if getPlayerStorageValue(cid, task.storage) <= 0 then
- if getPlayerStorageValue(cid, "taskon") <= 0 then
- if getPlayerLevel(cid) >= task.level[1] then
- if getPlayerLevel(cid) <= task.level[2] then
- npcHandler:say(task.initmsg:format(task.count), cid)
- setPlayerStorageValue(cid, "taskname", msg:lower())
- tfocus[cid] = 2
- else
- local str = string.format("The max level for this task is %d, you can not do this task.", task.level[2])
- npcHandler:say(str, cid)
- end
- else
- local str = string.format("You don't have level %d to this task.", task.level[1])
- npcHandler:say(str, cid)
- end
- elseif getPlayerStorageValue(cid, "taskcount") > 0 then
- npcHandler:say(task.failmsg:format(getPlayerStorageValue(cid, "taskcount")), cid)
- tfocus[cid] = 1
- elseif getPlayerStorageValue(cid, "taskcount") <= 0 then
- npcHandler:say(task.winmsg, cid)
- doPlayerAddExp(cid, task.exp)
- doSendAnimatedText(getThingPos(cid), task.exp, 215)
- doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_2, "You gain "..task.exp.." experience for this task!")
- setPlayerStorageValue(cid, "taskname", nil)
- setPlayerStorageValue(cid, "taskcount", nil)
- setPlayerStorageValue(cid, "taskon", nil)
- setPlayerStorageValue(cid, task.storage, 1)
- else
- npcHandler:say("Error, contact the administrator.", cid)
- end
- else
- npcHandler:say("You've done this task.", cid)
- end
- elseif msgcontains(msg:lower(), "yes") and tfocus[cid] == 2 then
- local task = tasks[getPlayerStorageValue(cid, "taskname")]
- tfocus[cid] = 3
- npcHandler:say(task.yesmsg, cid)
- setPlayerStorageValue(cid, "taskcount", task.count)
- setPlayerStorageValue(cid, "taskon", 1)
- end
- return true
- end
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement