Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.30 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4.  
  5.  
  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.  
  11. local tfocus = {}
  12. local tasks = {
  13. ["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},
  14. ["badger"] = {name = "Badger", count = 300, level = {6, 49}, exp = 500, pawpoint = 1, bosspoint = 1, initmsg = "", yesmsg = "", winmsg = "", failmsg = "", storage = 9852},
  15. }
  16.  
  17. function creatureSayCallback(cid, type, msg)
  18. if(not npcHandler:isFocused(cid)) then
  19. return false
  20. end
  21.  
  22. if msgcontains(msg:lower(), "task") or msgcontains(msg:lower(), "mission") then
  23. npcHandler:say("All right, what would you like to hunt, want to see the {list} ?", cid)
  24. tfocus[cid] = 1
  25. elseif msgcontains(msg:lower(), "list") then
  26. local str = "List: \n\n"
  27. for k, v in pairs(tasks) do
  28. 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"
  29. end
  30. doShowTextDialog(cid, 2160, str)
  31. tfocus[cid] = 1
  32. elseif tasks[msg:lower()] and tfocus[cid] == 1 then
  33. local task = tasks[getPlayerStorageValue(cid, "taskname")] and tasks[getPlayerStorageValue(cid, "taskname")] or tasks[msg:lower()]
  34. if getPlayerStorageValue(cid, task.storage) <= 0 then
  35. if getPlayerStorageValue(cid, "taskon") <= 0 then
  36. if getPlayerLevel(cid) >= task.level[1] then
  37. if getPlayerLevel(cid) <= task.level[2] then
  38. npcHandler:say(task.initmsg:format(task.count), cid)
  39. setPlayerStorageValue(cid, "taskname", msg:lower())
  40. tfocus[cid] = 2
  41. else
  42. local str = string.format("The max level for this task is %d, you can not do this task.", task.level[2])
  43. npcHandler:say(str, cid)
  44. end
  45. else
  46. local str = string.format("You don't have level %d to this task.", task.level[1])
  47. npcHandler:say(str, cid)
  48. end
  49. elseif getPlayerStorageValue(cid, "taskcount") > 0 then
  50. npcHandler:say(task.failmsg:format(getPlayerStorageValue(cid, "taskcount")), cid)
  51. tfocus[cid] = 1
  52. elseif getPlayerStorageValue(cid, "taskcount") <= 0 then
  53. npcHandler:say(task.winmsg, cid)
  54. doPlayerAddExp(cid, task.exp)
  55. doSendAnimatedText(getThingPos(cid), task.exp, 215)
  56. doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_2, "You gain "..task.exp.." experience for this task!")
  57. setPlayerStorageValue(cid, "taskname", nil)
  58. setPlayerStorageValue(cid, "taskcount", nil)
  59. setPlayerStorageValue(cid, "taskon", nil)
  60. setPlayerStorageValue(cid, task.storage, 1)
  61. else
  62. npcHandler:say("Error, contact the administrator.", cid)
  63. end
  64. else
  65. npcHandler:say("You've done this task.", cid)
  66. end
  67. elseif msgcontains(msg:lower(), "yes") and tfocus[cid] == 2 then
  68. local task = tasks[getPlayerStorageValue(cid, "taskname")]
  69. tfocus[cid] = 3
  70. npcHandler:say(task.yesmsg, cid)
  71. setPlayerStorageValue(cid, "taskcount", task.count)
  72. setPlayerStorageValue(cid, "taskon", 1)
  73. end
  74.  
  75.  
  76. return true
  77. end
  78.  
  79. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  80. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement