Oskar1121

Untitled

Oct 10th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.88 KB | None | 0 0
  1. <?xml version='1.0' encoding='ISO-8859-1'?>
  2. <mod name='Daily Task' version='1.0' enabled='yes'>
  3. <config name='DailyTask_conf'><![CDATA[
  4. TASKTYPE_KILL = 1
  5. TASKTYPE_ITEM = 2
  6.  
  7. storageMain = 4000
  8. storageCount = 4001
  9. storageTimer = 4002
  10.  
  11. timerDuration = 24 * 60 * 60 -- 24h * 60m * 60s
  12.  
  13. messageAlreadyDone = 'Sorry, you already did dailytask today.'
  14. messageKilled = 'You have killed %s of %d. Total killed %d / %d.'
  15. messageNotGain = 'Sorry, but You must take a dailytask firstly. You can do it by writing: !dailytask.'
  16. messageNotDone = 'Sorry, you are not able to finish dailytask.'
  17.  
  18. taskList = {
  19. {level = {1, 100}, type = TASKTYPE_KILL, list = {'wolf', 'bear'}, amount = 50,
  20. reward = {
  21. randomize = false,
  22. {REWARD_ITEM, 2347, 50},
  23. {REWARD_EXP, 750000}
  24. }},
  25.  
  26. {level = {1, 100}, type = TASKTYPE_KILL, list = {'farmer', 'bandit', 'shinobazu'}, amount = 100,
  27. reward = {
  28. randomize = false,
  29. {REWARD_ITEM, 2347, 100},
  30. {REWARD_EXP, 1000000}
  31. }},
  32. {level = {1, 100}, type = TASKTYPE_KILL, list = {'prisoner', 'sound shinobi'}, amount = 150,
  33. reward = {
  34. randomize = false,
  35. {REWARD_ITEM, 2347, 100},
  36. {REWARD_EXP, 1500000}
  37. }},
  38. {level = {101, 300}, type = TASKTYPE_KILL, list = {'monk'}, amount = 250,
  39. reward = {
  40. randomize = false,
  41. {REWARD_ITEM, 2349, 25},
  42. {REWARD_EXP, 6500000}
  43. }},
  44. {level = {101, 300}, type = TASKTYPE_KILL, list = {'sand shinobi'}, amount = 300,
  45. reward = {
  46. randomize = false,
  47. {REWARD_ITEM, 2349, 25},
  48. {REWARD_EXP, 7500000}
  49. }},
  50. {level = {101, 300}, type = TASKTYPE_KILL, list = {'anbu'}, amount = 400,
  51. reward = {
  52. randomize = false,
  53. {REWARD_ITEM, 2349, 25},
  54. {REWARD_EXP, 8500000}
  55. }},
  56. {level = {301, 500}, type = TASKTYPE_KILL, list = {'zetsu clone'}, amount = 500,
  57. reward = {
  58. randomize = false,
  59. {REWARD_ITEM, 2349, 50},
  60. {REWARD_EXP, 50000000}
  61. }},
  62. {level = {301, 500}, type = TASKTYPE_KILL, list = {'samurai'}, amount = 500,
  63. reward = {
  64. randomize = false,
  65. {REWARD_ITEM, 2349, 50},
  66. {REWARD_EXP, 50000000}
  67. }},
  68. {level = {301, 500}, type = TASKTYPE_KILL, list = {'golem', 'elite golem'}, amount = 500,
  69. reward = {
  70. randomize = false,
  71. {REWARD_ITEM, 2349, 50},
  72. {REWARD_EXP, 50000000}
  73. }},
  74. {level = {501, 800}, type = TASKTYPE_KILL, list = {'senju member', 'uchiha member'}, amount = 750,
  75. reward = {
  76. randomize = false,
  77. {REWARD_ITEM, 2349, 75},
  78. {REWARD_EXP, 100000000}
  79. }},
  80. {level = {501, 800}, type = TASKTYPE_KILL, list = {'cursed samurai'}, amount = 500,
  81. reward = {
  82. randomize = false,
  83. {REWARD_ITEM, 2349, 75},
  84. {REWARD_EXP, 100000000}
  85. }},
  86. {level = {501, 800}, type = TASKTYPE_KILL, list = {'akatsuki member'}, amount = 500,
  87. reward = {
  88. randomize = false,
  89. {REWARD_ITEM, 2349, 75},
  90. {REWARD_EXP, 100000000}
  91. }},
  92. {level = {801, 2000}, type = TASKTYPE_KILL, list = {'edo tensei member'}, amount = 1000,
  93. reward = {
  94. randomize = false,
  95. {REWARD_ITEM, 2349, 100},
  96. {REWARD_EXP, 500000000}
  97. }},
  98.  
  99. {level = {801, 2000}, type = TASKTYPE_KILL, list = {'rikudou member'}, amount = 1000,
  100. reward = {
  101. randomize = false,
  102. {REWARD_ITEM, 2349, 100},
  103. {REWARD_EXP, 500000000}
  104. }},
  105.  
  106. {level = {2001, 10000}, type = TASKTYPE_KILL, list = {'rikudou member'}, amount = 5000,
  107. reward = {
  108. randomize = false,
  109. {REWARD_ITEM, 2346, 5},
  110. {REWARD_EXP, 500000000}
  111. }},
  112.  
  113. {level = {2001, 10000}, type = TASKTYPE_KILL, list = {'rikudou member'}, amount = 10000,
  114. reward = {
  115. randomize = false,
  116. {REWARD_ITEM, 2346, 10},
  117. {REWARD_EXP, 1000000000}
  118. }},
  119.  
  120. {level = {2001, 10000}, type = TASKTYPE_KILL, list = {'obito', 'madara', 'naruto', 'sasuke'}, amount = 200,
  121. reward = {
  122. randomize = false,
  123. {REWARD_ITEM, 2344, 1},
  124. {REWARD_EXP, 1000000000}
  125. }}
  126.  
  127. }
  128.  
  129. function getTask(cid)
  130. local level = getPlayerLevel(cid)
  131. local list = {}
  132. for i = 1, #taskList do
  133. if level >= taskList[i].level[1] and level <= taskList[i].level[2] then
  134. table.insert(list, i)
  135. end
  136. end
  137.  
  138. return list[math.random(#list)]
  139. end
  140.  
  141. function addReward(cid, var)
  142. if var[1] == REWARD_ITEM then
  143. if type(var[3]) == 'table' then
  144. doPlayerAddItem(cid, var[2], math.random(var[3][1], var[3][2]))
  145. else
  146. doPlayerAddItem(cid, var[2], var[3])
  147. end
  148. elseif var[1] == REWARD_EXP then
  149. doSendAnimatedText(getThingPos(cid), var[2], COLOR_WHITE)
  150. doPlayerAddExperience(cid, var[2])
  151. end
  152. end
  153.  
  154. function addRewards(cid, list)
  155. if list.randomize then
  156. addReward(cid, list[math.random(#list)])
  157. else
  158. for _, v in pairs(list) do
  159. if type(v) == 'table' then
  160. print(v[1])
  161. addReward(cid, v)
  162. end
  163. end
  164. end
  165.  
  166. doCreatureSetStorage(cid, storageMain, -1)
  167. doCreatureSetStorage(cid, storageCount, -1)
  168. end
  169.  
  170. function getMonsterKilled(cid, list)
  171. local var = getCreatureStorage(cid, storageCount)
  172. local result = {}
  173. for i = 1, #list do
  174. result[list[i]] = 0
  175. end
  176.  
  177. if var ~= -1 then
  178. local strExplode = tostring(var):explode(';')
  179. for i = 1, #strExplode / 2 do
  180. result[strExplode[i * 2 - 1]] = strExplode[i * 2]
  181. end
  182. end
  183.  
  184. return result
  185. end
  186.  
  187. function showTask(cid, id)
  188. local var = taskList[id]
  189. if not var then
  190. return false
  191. end
  192.  
  193. local text = 'You daily quest is '
  194. if var.type == TASKTYPE_ITEM then
  195. text = text .. 'bring '
  196.  
  197. local count = #var.list / 2
  198. for i = 1, count do
  199. text = text .. '\n' .. getItemNameById(var.list[i * 2 - 1]) .. ' (' .. getPlayerItemCount(cid, var.list[i * 2 - 1]) .. ' / ' .. var.list[i * 2] .. ')'
  200.  
  201. if i < count then
  202. text = text .. ', '
  203. end
  204. end
  205. elseif var.type == TASKTYPE_KILL then
  206. text = text .. 'kill ' .. var.amount
  207.  
  208. local count = #var.list
  209. local monsterList = getMonsterKilled(cid, var.list)
  210. for i = 1, count do
  211. text = text .. '\n' .. var.list[i] .. ' (' .. monsterList[var.list[i]] .. ')'
  212.  
  213. if i < count then
  214. text = text .. ', '
  215. end
  216. end
  217. end
  218.  
  219. text = text .. '.'
  220. doShowTextDialog(cid, 1961, text)
  221. end
  222.  
  223. function addTask(cid)
  224. local id = getTask(cid)
  225.  
  226. doCreatureSetStorage(cid, storageMain, id)
  227. doCreatureSetStorage(cid, storageTimer, os.time() + timerDuration)
  228. showTask(cid, id)
  229.  
  230. if taskList[id].type == TASKTYPE_KILL then
  231. registerCreatureEvent(cid, 'DailyTaskOnKill')
  232. end
  233. end
  234.  
  235. ]]></config>
  236.  
  237. <talkaction words='!dailytask' event='script'><![CDATA[
  238. domodlib('DailyTask_conf')
  239.  
  240. function onSay(cid, words, param, channel)
  241. local id = getCreatureStorage(cid, storageMain)
  242. if id > 0 then
  243. showTask(cid, id)
  244. return true
  245. end
  246.  
  247. if getCreatureStorage(cid, storageTimer) > os.time() then
  248. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, messageAlreadyDone)
  249. return true
  250. end
  251.  
  252. addTask(cid)
  253. return true
  254. end
  255.  
  256. ]]></talkaction>
  257.  
  258. <talkaction words='!report' event='script'><![CDATA[
  259. domodlib('DailyTask_conf')
  260.  
  261. function onSay(cid, words, param, channel)
  262. local id = getCreatureStorage(cid, storageMain)
  263. if id <= 0 then
  264. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, messageNotGain)
  265. return true
  266. end
  267.  
  268. local var = taskList[id]
  269. if var.type == TASKTYPE_KILL then
  270. local monsterList = getMonsterKilled(cid, var.list)
  271. local count = 0
  272. for k, v in pairs(monsterList) do
  273. count = count + tonumber(v)
  274. end
  275.  
  276. if count < var.amount then
  277. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, messageNotDone)
  278. return true
  279. end
  280. elseif var.type == TASKTYPE_ITEM then
  281. local count = #var.list / 2
  282. for i = 1, count do
  283. if getPlayerItemCount(cid, var.list[i * 2 - 1]) < var.list[i * 2] then
  284. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, messageNotDone)
  285. return true
  286. end
  287. end
  288.  
  289. for i = 1, count do
  290. doPlayerRemoveItem(cid, var.list[i * 2 - 1], var.list[i * 2])
  291. end
  292. end
  293.  
  294. addRewards(cid, var.reward)
  295. return true
  296. end
  297.  
  298. ]]></talkaction>
  299.  
  300. <event type="login" name="DailyTaskLogin" event="script"><![CDATA[
  301. domodlib('DailyTask_conf')
  302.  
  303. function onLogin(cid)
  304. local id = getCreatureStorage(cid, storageMain)
  305. if id < 1 then
  306. return true
  307. end
  308.  
  309. local var = taskList[id]
  310. if var.type == TASKTYPE_KILL then
  311. registerCreatureEvent(cid, 'DailyTaskOnKill')
  312. end
  313.  
  314. return true
  315. end
  316. ]]></event>
  317.  
  318. <event type="kill" name="DailyTaskOnKill" event="script"><![CDATA[
  319. domodlib('DailyTask_conf')
  320.  
  321. function onKill(cid, target)
  322. local id = getCreatureStorage(cid, storageMain)
  323. if id < 1 then
  324. return true
  325. end
  326.  
  327. local var = taskList[id]
  328. local name = getCreatureName(target):lower()
  329. if isInArray(var.list, name) then
  330. local monsterList = getMonsterKilled(cid, var.list)
  331.  
  332. monsterList[name] = monsterList[name] + 1
  333.  
  334. local buffer, i = '', 0
  335. local description = ''
  336. local count = 0
  337. for k, v in pairs(monsterList) do
  338. i = i + 1
  339. count = count + tonumber(v)
  340. buffer = buffer .. k .. ';' .. v
  341. description = description .. k .. ' (' .. v .. ')'
  342. if i < #var.list then
  343. buffer = buffer .. ';'
  344. description = description .. ', '
  345. end
  346. end
  347.  
  348. doCreatureSetStorage(cid, storageCount, buffer)
  349. if count <= var.amount then
  350. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, messageKilled:format(description, var.amount, count, var.amount))
  351. end
  352. end
  353.  
  354. return true
  355. end
  356. ]]></event>
  357.  
  358. </mod>
Add Comment
Please, Sign In to add comment