Advertisement
ederfrota

Untitled

Apr 3rd, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.35 KB | None | 0 0
  1. domodlib('task_func')
  2. local keywordHandler = KeywordHandler:new()
  3. local npcHandler = NpcHandler:new(keywordHandler)
  4. NpcSystem.parseParameters(npcHandler)
  5. local talkState = {}
  6. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  7. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  8. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  9. function onThink() npcHandler:onThink() end
  10. function creatureSayCallback(cid, type, msg)
  11. if(not npcHandler:isFocused(cid)) then
  12. return false
  13. end
  14. local talkUser,msg, str,rst = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, msg:lower(),"",""
  15. local task,daily, hours = getTaskMission(cid),getDailyTaskMission(cid), 24
  16. if isInArray({"task","tasks","missao","mission"}, msg) then
  17. if task_sys[task] then
  18. if getPlayerStorageValue(cid, task_sys[task].start) <= 0 then
  19. if getPlayerLevel(cid) >= task_sys[task].level then
  20. setPlayerStorageValue(cid, task_sys[task].start, 1)
  21. npcHandler:say("[Task System] Parabens, agora voce esta participando da Task do "..task_sys[task].name.." e devera matar "..task_sys[task].count.." desta lista: "..getMonsterFromList(task_sys[task].monsters_list)..". "..(#task_sys[task].items > 0 and "Ah e por favor me traga "..getItemsFromList(task_sys[task].items).." para mim." or "").."" , cid)
  22. else
  23. npcHandler:say("Desculpe, Mas voce precisa alcancar level "..task_sys[task].level.." para poder participar da Task dos "..task_sys[task].name.."!", cid)
  24. end
  25. else
  26. npcHandler:say("Desculpe, Mas voce atualmente esta na task "..task_sys[task].name..". Voce pode {entregar} caso ja tenha terminado.", cid)
  27. end
  28. else
  29. npcHandler:say("Desculpe, Mas por enquanto nao tenho mais nenhuma task para voce!", cid)
  30. end
  31. elseif isInArray({"diaria","daili","daily","dayli","diario"}, msg) then
  32. if getPlayerStorageValue(cid, task_sys_storages[6]) - os.time() > 0 then
  33. npcHandler:say("Desculpe, voce deve esperar ate "..os.date("%d %B %Y %X ", getPlayerStorageValue(cid,task_sys_storages[6])).." para iniciar uma nova task diaria!", cid) return true
  34. elseif daily_task[daily] and getPlayerStorageValue(cid, task_sys_storages[5]) >= daily_task[daily].count then
  35. npcHandler:say("Desculpe, voce tem task para {entregar} !", cid) return true
  36. end
  37. local r = doRandomDailyTask(cid)
  38. if r == 0 then
  39. npcHandler:say("Desculpe, mas voce nao tem level para completar nenhuma Task diaria.", cid) return true
  40. end
  41. setPlayerStorageValue(cid, task_sys_storages[4], r)
  42. setPlayerStorageValue(cid, task_sys_storages[6], os.time()+hours*3600)
  43. setPlayerStorageValue(cid, task_sys_storages[7], 1)
  44. setPlayerStorageValue(cid, task_sys_storages[5], 0)
  45. local dtask = daily_task[r]
  46. npcHandler:say("[Daily Task System] Parabens, agora voce esta participando da Task Diaria do "..dtask.name.." e devera matar "..dtask.count.." monstros desta lista: "..getMonsterFromList(dtask.monsters_list).." atΓ© "..os.date("%d %B %Y %X ", getPlayerStorageValue(cid,task_sys_storages[6]))..". Boa sorte!" , cid)
  47. elseif isInArray({"receber","reward","recompensa","report","reportar","entregar","entrega"}, msg) then
  48. local v, k = task_sys[task], daily_task[daily]
  49. if v then -- original task
  50. if getPlayerStorageValue(cid, v.start) > 0 then
  51. if getPlayerStorageValue(cid,task_sys_storages[3]) >= v.count then
  52. if #v.items > 0 and not doRemoveItemsFromList(cid, v.items) then
  53. npcHandler:say("Desculpe, Mas voce tambem precisa entregar os itens desta lista: "..getItemsFromList(v.items), cid) return true
  54. end
  55. if v.exp > 0 then doPlayerAddExp(cid, v.exp) str = str.."".. (str == "" and "" or ", ") .." "..v.exp.." de exp" end
  56. if v.points > 0 then setPlayerStorageValue(cid, task_sys_storages[2], (getTaskPoints(cid)+v.points)) str = str.."".. (str == "" and "" or ", ") .." + "..v.points.."task points" end
  57. if v.money > 0 then doPlayerAddMoney(cid, v.money) str = str.."".. (str == "" and "" or ", ") ..""..v.money.." gps" end
  58. if table.maxn(v.reward) > 0 then GiveRewardsTask(cid, v.reward) str = str.."".. (str == "" and "" or ", ") ..""..getItemsFromList(v.reward) end
  59. npcHandler:say("Obrigado pela sua ajuda Recompensas: "..(str == "" and "nenhuma" or ""..str.."").." por ter completado a task do "..v.name, cid)
  60. setPlayerStorageValue(cid, task_sys_storages[3], 0)
  61. setPlayerStorageValue(cid, task_sys_storages[1], (task+1))
  62. else
  63. npcHandler:say("Desculpe, Mas voce ainda nao terminou a sua task do "..v.name..". Preciso que mate mais "..(getPlayerStorageValue(cid, task_sys_storages[3]) < 0 and v.count or -(getPlayerStorageValue(cid,task_sys_storages[3])-v.count)).." Destes monstros terriveis!", cid)
  64. end
  65. end
  66. end
  67. if k then -- daily task
  68. if getPlayerStorageValue(cid, task_sys_storages[7]) > 0 then
  69. if getPlayerStorageValue(cid, task_sys_storages[5]) >= k.count then
  70. if k.exp > 0 then doPlayerAddExp(cid, v.exp) rst = rst.."".. (rst == "" and "" or ", ") .." "..k.exp.." de exp" end
  71. if k.points > 0 then setPlayerStorageValue(cid, task_sys_storages[2], (getTaskPoints(cid)+k.points)) rst = rst.."".. (rst == "" and "" or ", ") .." + "..k.points.."task points" end
  72. if k.money > 0 then doPlayerAddMoney(cid, k.money) rst = rst.."".. (rst == "" and "" or ", ") ..""..k.money.." gps" end
  73. if table.maxn(k.reward) > 0 then GiveRewardsTask(cid, k.reward) rst = rst.."".. (rst == "" and "" or ", ") ..""..getItemsFromList(k.reward) end
  74. npcHandler:say("Obrigado pela sua ajuda! Recompensas: "..(rst == "" and "nenhuma" or ""..rst.."").." por ter completado a task do "..k.name, cid)
  75. setPlayerStorageValue(cid, task_sys_storages[4], 0)
  76. setPlayerStorageValue(cid, task_sys_storages[5], 0)
  77. setPlayerStorageValue(cid, task_sys_storages[7], 0)
  78. else
  79. npcHandler:say("Desculpe, Mas voce ainda nao terminou a sua task diaria do "..k.name..". Preciso que mate mais "..(getPlayerStorageValue(cid, task_sys_storages[5]) < 0 and k.count or -(getPlayerStorageValue(cid,task_sys_storages[5])-k.count)).." Destes monstros!", cid)
  80. end
  81. end
  82. end
  83. elseif msg == "no" then
  84. selfSay("Tudo bem entao", cid)
  85. talkState[talkUser] = 0
  86. npcHandler:releaseFocus(cid)
  87. end
  88. return true
  89. end
  90. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  91. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement