Oskar1121

Untitled

Sep 27th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.90 KB | None | 0 0
  1. domodlib('gaidens_conf')
  2.  
  3. TYPE_ITEMBACK = 0
  4. TYPE_KILL = 1
  5.  
  6. local keywordHandler = KeywordHandler:new()
  7. local npcHandler = NpcHandler:new(keywordHandler)
  8. NpcSystem.parseParameters(npcHandler)
  9.  
  10. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  11. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  12. function onThink() npcHandler:onThink() end
  13. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  14.  
  15. local talkUser = {}
  16.  
  17. local function doAddExp(cid, amount)
  18. return doSendAnimatedText(getThingPos(cid), amount, COLOR_WHITE) and doPlayerAddExperience(cid, amount)
  19. end
  20.  
  21. local function doTakeReward(cid, table)
  22. for i = 1, #table / 3 do
  23. if table[i * 3 - 2] == REWARD_ITEM then
  24. doPlayerAddItem(cid, table[i * 3 - 1], table[i * 3], true)
  25. elseif table[i * 3 - 2] == REWARD_EXP then
  26. doAddExp(cid, table[i * 3])
  27. elseif table[i * 3 - 2] == REWARD_STORAGE then
  28. doCreatureSetStorage(cid, table[i * 3 - 1], table[i * 3])
  29. elseif table[i * 3 - 2] == REWARD_MONEY then
  30. doPlayerAddMoney(cid, table[i * 3])
  31. elseif table[i * 3 - 2] == REWARD_SKILL then
  32. doPlayerSetSkill(cid, table[i * 3 - 1], getPlayerSkillLevel(cid, table[i * 3 - 1]) + table[i * 3])
  33. elseif table[i * 3 - 2] == REWARD_ADDON then
  34. doPlayerAddOutfit(cid, (getPlayerSex(cid) == 0 and table[i * 3 - 1][1] or table[i * 3 - 1][2]), table[i * 3])
  35. elseif table[i * 3 - 2] == REWARD_LEVEL then
  36. doPlayerAddLevel(cid, table[i * 3])
  37. end
  38. end
  39. end
  40.  
  41. local function getDescription(cid, status, storage, first)
  42. local count = #status.details / 2
  43. local detail, complete = getDetails(cid, status, storage, true)
  44. talkUser[cid] = 0
  45. if status.var == TYPE_KILL then
  46. local message = 'You have already started a mission where you must kill %s. Good luck!'
  47. if first then
  48. message = 'You have starting a first mission where you must kill %s. Good luck!'
  49. end
  50.  
  51. return selfSay(message:format(detail), cid)
  52. elseif status.var == TYPE_ITEMBACK then
  53. local message = 'You have already started a mission where you must gather %s. Come back when you get it all.'
  54. if first then
  55. message = 'You have starting a first mission where you must gather %s. Come back when you get it all. Good luck!'
  56. end
  57.  
  58. return selfSay(message:format(detail), cid)
  59. else
  60. return selfSay('You are not started any mission. If you want to start {mission} just ask me.', cid)
  61. end
  62. end
  63.  
  64. function creatureSayCallback(cid, type, msg)
  65. if not npcHandler:isFocused(cid) or not npcHandler:isInRange(cid) then
  66. return false
  67. end
  68.  
  69. local var = superUberDuperTaskList[getCreatureName(getNpcCid())]
  70. if not var then
  71. selfSay('Something wrong. Probably mission list are empty or something like that.', cid)
  72. return true
  73. end
  74.  
  75. local value = getCreatureStorage(cid, var.storage)
  76. local status = var[value]
  77. if msg:find('mission') then
  78. if not status then
  79. 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)
  80. talkUser[cid] = 1
  81. else
  82. getDescription(cid, status, var.storage + 100)
  83. end
  84. elseif msg:find('report') then
  85. if status then
  86. if status.var == TYPE_ITEMBACK then
  87. local detail, complete = getDetails(cid, status)
  88. selfSay('Do you have all requirements items? [' .. detail .. ']', cid)
  89. talkUser[cid] = 2
  90. else
  91. getDescription(cid, status, var.storage + 100)
  92. end
  93. else
  94. selfSay('You don\'t have started any {mission}.', cid)
  95. end
  96. elseif msg:find('yes') then
  97. if talkUser[cid] == 1 then
  98. if not status then
  99. doCreatureSetStorage(cid, var.storage, 1)
  100. status = var[1]
  101. end
  102.  
  103. getDescription(cid, status, var.storage + 100)
  104. elseif talkUser[cid] == 2 then
  105. local detail, complete = getDetails(cid, status, var.storage + 100, true)
  106. if complete then
  107. for i = 1, #status.details / 2 do
  108. doPlayerRemoveItem(cid, status.details[i * 2 - 1], status.details[i * 2])
  109. end
  110.  
  111. doCreatureSetStorage(cid, var.storage, value + 1)
  112. doTakeReward(cid, status.rewards)
  113. selfSay('Congratulations! You complete a task!', cid)
  114.  
  115. status = var[value + 1]
  116. if status then
  117. local detail, complete = getDetails(cid, status, var.storage + 100, true)
  118. if status.var == TYPE_KILL then
  119. selfSay('You have already started a mission where you must kill ' .. detail .. '.', cid)
  120. elseif status.var == TYPE_ITEMBACK then
  121. selfSay('You have already started a mission where you must gather ' .. detail .. '. Come back when you get it all.', cid)
  122. end
  123. end
  124. else
  125. selfSay('Hmm... Something wrong. You do not have enough items what I need. [' .. detail .. ']', cid)
  126. end
  127. end
  128.  
  129. talkUser[cid] = 0
  130. end
  131. end
  132.  
  133. npcHandler:setMessage(MESSAGE_GREET, "Hi Hey Hello!")
  134. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  135. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment