Oskar1121

Untitled

Sep 26th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. domodlib('superUberDuperTaski_conf')
  2.  
  3. local keywordHandler = KeywordHandler:new()
  4. local npcHandler = NpcHandler:new(keywordHandler)
  5. NpcSystem.parseParameters(npcHandler)
  6.  
  7. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  8. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  9. function onThink() npcHandler:onThink() end
  10. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  11.  
  12. local talkUser = {}
  13.  
  14. local function doAddExp(cid, amount)
  15. return doSendAnimatedText(getThingPos(cid), amount, COLOR_WHITE) and doPlayerAddExperience(cid, amount)
  16. end
  17.  
  18. local function doTakeReward(cid, table, repeatable, value)
  19. for i = 1, #table / 3 do
  20. if table[i * 3 - 2] == REWARD_ITEM then
  21. doPlayerAddItem(cid, table[i * 3 - 1], table[i * 3], true)
  22. elseif table[i * 3 - 2] == REWARD_EXP then
  23. doAddExp(cid, table[i * 3])
  24. elseif table[i * 3 - 2] == REWARD_STORAGE then
  25. doCreatureSetStorage(cid, table[i * 3 - 1], table[i * 3])
  26. elseif table[i * 3 - 2] == REWARD_MONEY then
  27. doPlayerAddMoney(cid, table[i * 3])
  28. elseif table[i * 3 - 2] == REWARD_SKILL then
  29. doPlayerSetSkill(cid, table[i * 3 - 1], getPlayerSkillLevel(cid, table[i * 3 - 1]) + table[i * 3])
  30. elseif table[i * 3 - 2] == REWARD_ADDON then
  31. doPlayerAddOutfit(cid, (getPlayerSex(cid) == 0 and table[i * 3 - 1][1] or table[i * 3 - 1][2]), table[i * 3])
  32. elseif table[i * 3 - 2] == REWARD_LEVEL then
  33. doPlayerAddLevel(cid, table[i * 3])
  34. end
  35. end
  36. end
  37.  
  38. local function getDescription(cid, status, storage, first)
  39. local count = #status.details / 2
  40. local detail, complete = getDetails(cid, status, storage)
  41. talkUser[cid] = 0
  42. if status.var == TYPE_KILL then
  43. local message = 'You have already started a mission where you must kill %s. Come back when you done it.'
  44. if first then
  45. message = 'You have starting a first mission where you must kill %s. Good luck!'
  46. end
  47.  
  48. return selfSay(message:format(detail), cid)
  49. elseif status.var == TYPE_ITEMBACK then
  50. local message = 'You have already started a mission where you must gather %s. Come back when you get it all.'
  51. if first then
  52. message = 'You have starting a first mission where you must gather %s. Come back when you get it all. Good luck!'
  53. end
  54.  
  55. return selfSay(message:format(detail), cid)
  56. else
  57. return selfSay('You are not started any task. If you want to start {task} just ask me.', cid)
  58. end
  59. end
  60.  
  61. function creatureSayCallback(cid, type, msg)
  62. if not npcHandler:isFocused(cid) or not npcHandler:isInRange(cid) then
  63. return false
  64. end
  65.  
  66. local var = task[getCreatureName(getNpcCid())]
  67. if not var then
  68. selfSay('Something wrong. Probably task list are empty or something like that.', cid)
  69. return true
  70. end
  71.  
  72. local storage = getCreatureStorage(cid, var.storage)
  73. local status = var[storage]
  74. if msg:find('task') then
  75. if storage == -1 then
  76. selfSay('Hi ' .. getCreatureName(cid) .. '! Do you want to start Naruto Gaiden? If you finish it you would get permamently bonus to drop x 2!', cid)
  77. talkUser[cid] = 1
  78. else
  79. getDescription(cid, status, var.storage + 100)
  80. end
  81. elseif msg:find('yes') then
  82. if talkUser[cid] == 1 then
  83. doCreatureSetStorage(cid, var.storage, 1)
  84. getDescription(cid, status, var.storage + 100)
  85. talkUser[cid] = 0
  86. end
  87. end
  88. end
  89.  
  90. npcHandler:setMessage(MESSAGE_GREET, "Hi Hey Hello!")
  91. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  92. npcHandler:addModule(FocusModule:new())
Add Comment
Please, Sign In to add comment