Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.15 KB | None | 0 0
  1. TASK_SYSTEM = {
  2.     list = {
  3.         ["trolls"] = {killsRequired = 10, storageFromStart = 10001, monsters = {"Troll", "Troll Champion"}, categorie = "low", exp = 0, items = {}, money = 100, talkstate = 1},
  4.         ["rats"] = {killsRequired = 10, storageFromStart = 10001, monsters = {"Rat", "Cave Rat"}, categorie = "low", exp = 0, items = {}, money = 100, talkstate = 2},
  5.         ["rotworms"] = {killsRequired = 10, storageFromStart = 10001, monsters = {"Rotworm", "Carrion Rotworm"}, categorie = "medium", exp = 0, items = {}, money = 100, talkstate = 3},
  6.         ["cyclops"] = {killsRequired = 10, storageFromStart = 10001, monsters = {"Cyclop", "Cyclop Smith"}, categorie = "high", exp = 0, items = {}, money = 100, talkstate = 4},
  7.     },
  8.  
  9.     cache = nil, -- Dont change it.
  10.     storage_global = 929292, -- Choose one storage for it.
  11.  
  12. }
  13.  
  14. local keywordHandler = KeywordHandler:new()
  15. local npcHandler = NpcHandler:new(keywordHandler)
  16. NpcSystem.parseParameters(npcHandler)
  17. local talkState = {}
  18. function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)            end
  19. function onCreatureDisappear(cid)            npcHandler:onCreatureDisappear(cid)            end
  20. function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg)        end
  21. function onThink()                    npcHandler:onThink()                    end
  22.  
  23. npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|. Say {task}, {consult}, {cancel} or {help} to know more about that or done to receive your award!')
  24.  
  25. local function addCacheTemporarily(msgTable)
  26.     for k, v in pairs(msgTable) do
  27.         if msg == v.categorie then
  28.             if TASK_SYSTEM.cache == nil then
  29.                 TASK_SYSTEM.cache = " ".."{"..v.."}"
  30.             else
  31.                 TASK_SYSTEM.cache = TASK_SYSTEM.cache ..", ".."{"..v.."}"
  32.             end
  33.         end
  34.     end
  35.     return TASK_SYSTEM.cache
  36. end
  37.  
  38. function creatureSayCallback(cid, type, msg)
  39.     if not npcHandler:isFocused(cid) then
  40.         return false
  41.     end
  42.  
  43.     if isInArray({'task','mission','quest'}, msg:lower()) then
  44.         npcHandler:say("The tasks are divided by categories, we have: {low}, {medium} or {high}. We also have {addons}, {specials} and {timed} tasks.", cid)
  45.     elseif isInArray({'low', 'medium', 'high'}, msg:lower()) then
  46.         for k, v in pairs(TASK_SYSTEM.list) do
  47.             if msg == v.categorie then
  48.                 if TASK_SYSTEM.cache == nil then
  49.                     TASK_SYSTEM.cache = " ".."{"..k.."}"
  50.                 else
  51.                     TASK_SYSTEM.cache = TASK_SYSTEM.cache .." | ".."{"..k.."}"
  52.                 end
  53.             end
  54.         end
  55.         npcHandler:say("Currently for {"..msg.."} we have the following monsters:"..TASK_SYSTEM.cache.." which one do you want?", cid)
  56.         TASK_SYSTEM.cache = nil
  57.     elseif TASK_SYSTEM.list[msg:lower()] then
  58.         addCacheTemporarily(TASK_SYSTEM.list[msg:lower()].monsters)
  59.         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)
  60.         TASK_SYSTEM.cache = nil
  61.     end
  62.     --for k, v in pairs(TASK_SYSTEM) do
  63.     --  print(v.categorie)
  64.     --end
  65.  
  66.     return true
  67. end
  68. npcHandler:addModule(FocusModule:new())
  69. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement