Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TASK_SYSTEM = {
- list = {
- ["trolls"] = {killsRequired = 10, storageFromStart = 10001, monsters = {"Troll", "Troll Champion"}, categorie = "low", exp = 0, items = {}, money = 100, talkstate = 1},
- ["rats"] = {killsRequired = 10, storageFromStart = 10001, monsters = {"Rat", "Cave Rat"}, categorie = "low", exp = 0, items = {}, money = 100, talkstate = 2},
- ["rotworms"] = {killsRequired = 10, storageFromStart = 10001, monsters = {"Rotworm", "Carrion Rotworm"}, categorie = "medium", exp = 0, items = {}, money = 100, talkstate = 3},
- ["cyclops"] = {killsRequired = 10, storageFromStart = 10001, monsters = {"Cyclop", "Cyclop Smith"}, categorie = "high", exp = 0, items = {}, money = 100, talkstate = 4},
- },
- cache = nil, -- Dont change it.
- storage_global = 929292, -- Choose one storage for it.
- }
- 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
- npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|. Say {task}, {consult}, {cancel} or {help} to know more about that or done to receive your award!')
- local function addCacheTemporarily(msgTable)
- for k, v in pairs(msgTable) do
- if msg == v.categorie then
- if TASK_SYSTEM.cache == nil then
- TASK_SYSTEM.cache = " ".."{"..v.."}"
- else
- TASK_SYSTEM.cache = TASK_SYSTEM.cache ..", ".."{"..v.."}"
- end
- end
- end
- return TASK_SYSTEM.cache
- end
- function creatureSayCallback(cid, type, msg)
- if not npcHandler:isFocused(cid) then
- return false
- end
- if isInArray({'task','mission','quest'}, msg:lower()) then
- npcHandler:say("The tasks are divided by categories, we have: {low}, {medium} or {high}. We also have {addons}, {specials} and {timed} tasks.", cid)
- elseif isInArray({'low', 'medium', 'high'}, msg:lower()) then
- for k, v in pairs(TASK_SYSTEM.list) do
- if msg == v.categorie then
- if TASK_SYSTEM.cache == nil then
- TASK_SYSTEM.cache = " ".."{"..k.."}"
- else
- TASK_SYSTEM.cache = TASK_SYSTEM.cache .." | ".."{"..k.."}"
- end
- end
- end
- npcHandler:say("Currently for {"..msg.."} we have the following monsters:"..TASK_SYSTEM.cache.." which one do you want?", cid)
- TASK_SYSTEM.cache = nil
- elseif TASK_SYSTEM.list[msg:lower()] then
- addCacheTemporarily(TASK_SYSTEM.list[msg:lower()].monsters)
- npcHandler:say("You need to defeat an amount of "..tonumber(TASK_SYSTEM.list[msg:lower()].killsRequired).." of "..TASK_SYSTEM.cache.." to complete this task. Do you accept this challenge?", cid)
- TASK_SYSTEM.cache = nil
- end
- --for k, v in pairs(TASK_SYSTEM) do
- -- print(v.categorie)
- --end
- return true
- end
- npcHandler:addModule(FocusModule:new())
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement