Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.91 KB | None | 0 0
  1. -- ########################################################
  2. -- ##### Name: Adriano Swatt' #####
  3. -- ##### Version: 3.0 #####
  4. -- ########################################################
  5. -- ##### Developed by Adriano Swatt' #####
  6. -- ##### Contact: adrianoswat@yahoo.com.br #####
  7. -- ##### PERSONALIZED TASK SYSTEM BY SWATT' #####
  8. -- ########################################################
  9.  
  10. -- [[ EXPLAIN // EXPLICAÇÃO // COMO CONFIGURAR ]] --
  11. -- storage = Storage Que Salva: Task Ativa/Repetição/Dia/Hora/Minute
  12. -- countSto = Storage Que Salva Quantidade que Matou
  13. -- count = Quantidade Total Que Precisará Matar
  14. -- price = Preço da Task em Gold Coins
  15. -- repeated = Quantas Vezes Pode Realizar a Task
  16. -- inDay = Day Value: Quantos dias para realizar // false: se a task fica ativa até a conclusão
  17. -- awards = [1] = {id = Premio, multiply = quantidade} // seguindo modelo // usar [1] = {id = "exp", multiply = QUANTIDADE}
  18. -- DICA: Deixe sempre a Experiência por último
  19. _SETTING_TASK_SYSTEM_CONFIG = {
  20. taskAtSameTime = 3, -- Quantas Tasks Ativas Ao Mesmo Tempo
  21. }
  22.  
  23. _MONSTERS_TASK_SYSTEM_CONFIG = {
  24. ["crocodile"] = {storage = 20001, countSto = 30001, count = 300, price = 0, repeated = 5, inDay = false,
  25. mlist = {"crocodile"},
  26. awards = {
  27. [1] = {id = 2476, multiply = 1},
  28. [2] = {id = "exp", multiply = 800}
  29. }
  30. },
  31. -- [[ SPACE ]] --
  32. ["tarantula"] = {storage = 20002, countSto = 30002, count = 300, price = 0, repeated = 5, inDay = false,
  33. mlist = {"tarantula"},
  34. awards = {
  35. [1] = {id = 2477, multiply = 1},
  36. [2] = {id = 5879, multiply = 5},
  37. [3] = {id = "exp", multiply = 1500}
  38. }
  39. },
  40.  
  41. -- [[ SPACE ]] --
  42. ["carniphila"] = {storage = 20003, countSto = 30003, count = 150, price = 0, repeated = 1, inDay = false,
  43. mlist = {"carniphila"},
  44. awards = {
  45. [1] = {id = 7886, multiply = 1},
  46. [2] = {id = 5015, multiply = 1},
  47. [3] = {id = "exp", multiply = 2500}
  48. }
  49. },
  50. -- [[ SPACE ]] --
  51. ["ice golem"] = {storage = 20004, countSto = 30004, count = 400, price = 0, repeated = 5, inDay = false,
  52. mlist = {"ice golem"},
  53. awards = {
  54. [1] = {id = 2160, multiply = 1},
  55. [2] = {id = 7290, multiply = 1},
  56. [3] = {id = "exp", multiply = 12000}
  57. }
  58. },
  59. -- [[ SPACE ]] --
  60. ["mutated rat"] = {storage = 20005, countSto = 30005, count = 500, price = 0, repeated = 5, inDay = false,
  61. mlist = {"mutated rat"},
  62. awards = {
  63. [1] = {id = 2438, multiply = 1},
  64. [2] = {id = 7884, multiply = 1},
  65. [3] = {id = "exp", multiply = 10000}
  66. }
  67. },
  68. -- [[ SPACE ]] --
  69. ["ancient scarab"] = {storage = 20006, countSto = 30006, count = 250, price = 0, repeated = 2, inDay = false,
  70. mlist = {"ancient scarab"},
  71. awards = {
  72. [1] = {id = 2160, multiply = 5},
  73. [2] = {id = "exp", multiply = 15000}
  74. }
  75. },
  76. -- [[ SPACE ]] --
  77. ["wailing widow"] = {storage = 20007, countSto = 30007, count = 500, price = 0, repeated = 1, inDay = false,
  78. mlist = {"wailing widow"},
  79. awards = {
  80. [1] = {id = 13307, multiply = 1},
  81. [2] = {id = "exp", multiply = 15000}
  82. }
  83. },
  84. -- [[ SPACE ]] --
  85. ["bonebeast"] = {storage = 20008, countSto = 30008, count = 500, price = 0, repeated = 1, inDay = false,
  86. mlist = {"bonebeast"},
  87. awards = {
  88. [1] = {id = 13291, multiply = 1},
  89. [2] = {id = "exp", multiply = 15000}
  90. }
  91. },
  92. -- [[ SPACE ]] --
  93. ["crystal spider"] = {storage = 20009, countSto = 30009, count = 300, price = 0, repeated = 5, inDay = false,
  94. mlist = {"crystal spider"},
  95. awards = {
  96. [1] = {id = 7437, multiply = 1},
  97. [2] = {id = "exp", multiply = 15000}
  98. }
  99. },
  100. -- [[ SPACE ]] --
  101. ["giant spider"] = {storage = 20010, countSto = 30010, count = 500, price = 0, repeated = 5, inDay = false,
  102. mlist = {"giant spider"},
  103. awards = {
  104. [1] = {id = 7416, multiply = 1},
  105. [2] = {id = 5879, multiply = 10},
  106. [3] = {id = "exp", multiply = 20000}
  107. }
  108. },
  109. -- [[ SPACE ]] --
  110. ["werewolf"] = {storage = 20011, countSto = 30011, count = 300, price = 0, repeated = 2, inDay = false,
  111. mlist = {"werewolf"},
  112. awards = {
  113. [1] = {id = 5897, multiply = 50},
  114. [2] = {id = 2160, multiply = 5},
  115. [3] = {id = "exp", multiply = 20000}
  116. }
  117. },
  118. -- [[ SPACE ]] --
  119. ["nightmare"] = {storage = 20012, countSto = 30012, count = 500, price = 0, repeated = 1, inDay = false,
  120. mlist = {"nightmare"},
  121. awards = {
  122. [1] = {id = 2195, multiply = 1},
  123. [2] = {id = 13830, multiply = 1},
  124. [3] = {id = "exp", multiply = 30000}
  125. }
  126. },
  127. -- [[ SPACE ]] --
  128. ["hellspawn"] = {storage = 20013, countSto = 30013, count = 600, price = 0, repeated = 2, inDay = false,
  129. mlist = {"hellspawn"},
  130. awards = {
  131. [1] = {id = 6500, multiply = 150},
  132. [2] = {id = 2160, multiply = 5},
  133. [3] = {id = "exp", multiply = 30000}
  134. }
  135. },
  136. -- [[ SPACE ]] --
  137. ["mutated bat"] = {storage = 20014, countSto = 30014, count = 400, price = 0, repeated = 5, inDay = false,
  138. mlist = {"mutated bat"},
  139. awards = {
  140. [1] = {id = 5894, multiply = 50},
  141. [2] = {id = "exp", multiply = 20000}
  142. }
  143. },
  144. -- [[ SPACE ]] --
  145. ["hydra"] = {storage = 20015, countSto = 30015, count = 600, price = 0, repeated = 5, inDay = false,
  146. mlist = {"hydra"},
  147. awards = {
  148. [1] = {id = 2160, multiply = 100},
  149. [2] = {id = "exp", multiply = 30000}
  150. }
  151. },
  152. -- [[ SPACE ]] --
  153. ["medusa"] = {storage = 20016, countSto = 30016, count = 500, price = 0, repeated = 1, inDay = false,
  154. mlist = {"medusa"},
  155. awards = {
  156. [1] = {id = 7887, multiply = 1},
  157. [2] = {id = 7885, multiply = 1},
  158. [3] = {id = 7884, multiply = 1},
  159. [4] = {id = 7886, multiply = 1},
  160. [5] = {id = "exp", multiply = 40000}
  161. }
  162. },
  163. -- [[ SPACE ]] --
  164. ["behemoth"] = {storage = 20017, countSto = 30017, count = 700, price = 0, repeated = 3, inDay = false,
  165. mlist = {"behemoth"},
  166. awards = {
  167. [1] = {id = 5930, multiply = 1},
  168. [2] = {id = 5893, multiply = 5},
  169. [3] = {id = "exp", multiply = 50000}
  170. }
  171. },
  172. -- [[ SPACE ]] --
  173. ["sea serpent"] = {storage = 20018, countSto = 30018, count = 900, price = 0, repeated = 1, inDay = false,
  174. mlist = {"sea serpent"},
  175. awards = {
  176. [1] = {id = 8887, multiply = 1},
  177. [2] = {id = "exp", multiply = 30000}
  178. }
  179. },
  180. -- [[ SPACE ]] --
  181. ["undead dragon"] = {storage = 20019, countSto = 30019, count = 400, price = 0, repeated = 1, inDay = false,
  182. mlist = {"undead dragon"},
  183. awards = {
  184. [1] = {id = 8885, multiply = 1},
  185. [2] = {id = "exp", multiply = 80000}
  186. }
  187. },
  188. -- [[ SPACE ]] --
  189. ["ghastly dragon"] = {storage = 20020, countSto = 30020, count = 500, price = 0, repeated = 1, inDay = false,
  190. mlist = {"ghastly dragon"},
  191. awards = {
  192. [1] = {id = 13938, multiply = 1},
  193. [2] = {id = "exp", multiply = 80000}
  194. }
  195. },
  196. -- [[ SPACE ]] --
  197. ["dragon lord"] = {storage = 20021, countSto = 30021, count = 1000, price = 0, repeated = 1, inDay = false,
  198. mlist = {"dragon lord"},
  199. awards = {
  200. [1] = {id = 5919, multiply = 1},
  201. [2] = {id = "exp", multiply = 100000}
  202. }
  203. },
  204. -- [[ SPACE ]] --
  205. ["demon"] = {storage = 20022, countSto = 30022, count = 666, price = 0, repeated = 1, inDay = false,
  206. mlist = {"demon"},
  207. awards = {
  208. [1] = {id = 2160, multiply = 10},
  209. [2] = {id = "exp", multiply = 500000}
  210. }
  211. },
  212.  
  213. -- [[ SPACE ]] --
  214. ["frost dragon"] = {storage = 20024, countSto = 30024, count = 1000, price = 0, repeated = 3, inDay = false,
  215. mlist = {"frost dragon"},
  216. awards = {
  217. [1] = {id = 2160, multiply = 10},
  218. [2] = {id = "exp", multiply = 200000}
  219. }
  220. },
  221. ["minotaur"] = {storage = 20025, countSto = 30025, count = 1000, price = 5000, repeated = 5, inDay = false,
  222. mlist = {"minotaur", "minotaur archer", "minotaur guard"},
  223. awards = {
  224. [1] = {id = 5804, multiply = 1},
  225. [2] = {id = "exp", multiply = 15000}
  226. }
  227. },
  228. -- [[ SPACE ]] --
  229. ["cyclops"] = {storage = 20026, countSto = 30026, count = 700, price = 7000, repeated = 3, inDay = false,
  230. mlist = {"cyclops", "cyclops drone", "cyclops smith"},
  231. awards = {
  232. [1] = {id = 2195, multiply = 1},
  233. [2] = {id = 2160, multiply = 5},
  234. [3] = {id = "exp", multiply = 15000}
  235. }
  236. },
  237. -- [[ SPACE ]] --
  238. ["orc"] = {storage = 20027, countSto = 30027, count = 440, price = 5000, repeated = 3, inDay = false,
  239. mlist = {"orc", "orc berserker", "orc leader", "orc warrior"},
  240. awards = {
  241. [1] = {id = 2195, multiply = 1},
  242. [2] = {id = 6561, multiply = 1},
  243. [3] = {id = 2160, multiply = 10},
  244. [4] = {id = "exp", multiply = 100000}
  245. }
  246. },
  247. }
  248.  
  249. -- [[ Storage: ativo (1) / repetição / Prazo ]] --
  250. function checkPlayerIsInTask(cid) -- RETURN: True if he can do some task // MonsterName if he can't
  251. getSto = doOrganizeTaskSto(_MONSTERS_TASK_SYSTEM_CONFIG)
  252. if isPlayer(cid) then
  253. pTaskTab = {}
  254. for a = getSto[1], getSto[#getSto] do
  255. if getPlayerStorageValue(cid, a) ~= -1 then
  256. onCheck = doCutTaskStorage(cid, a, "/")
  257. if #onCheck > 0 then
  258. active = tonumber(onCheck[1]:sub(2, 2))
  259. if active >= 1 then
  260. mName = whatTaskIsActive(cid, a)
  261. table.insert(pTaskTab, mName)
  262. end
  263. end
  264. end
  265. end
  266. return pTaskTab
  267. end
  268. return true
  269. end
  270.  
  271. function checkAlreadyDoingThisTask(cid, name, list) -- Return Monster Name if Can Do, or false if can't
  272. cfg = _MONSTERS_TASK_SYSTEM_CONFIG
  273. for i = 1, #list do
  274. getArray = cfg[list[i]].mlist
  275. if getArray then
  276. if isInArray(getArray, name) then
  277. return list[i]
  278. end
  279. end
  280. end
  281. return false
  282. end
  283.  
  284. function getInfoPlayerTask(cid, mName) -- Returns: [1] Repetition, [2] full date from Especific Task.
  285. local infoTab = {}
  286. getList = _MONSTERS_TASK_SYSTEM_CONFIG
  287. if isPlayer(cid) then
  288. getInfo = getList[mName:lower()]
  289. if getInfo then
  290. if getPlayerStorageValue(cid, getInfo.storage) ~= -1 then
  291. local onCut = doCutTaskStorage(cid, getInfo.storage, "/")
  292. if #onCut > 0 then
  293. for a = 2, 3 do
  294. table.insert(infoTab, tonumber(onCut[a]))
  295. end
  296. return infoTab
  297. else
  298. return true
  299. end
  300. else
  301. return false
  302. end
  303. end
  304. end
  305. end
  306.  
  307. function doCutTaskStorage(cid, storageKey, cutType) -- cutType [Ex: ","]
  308. local cutSto = {}
  309. local string = tostring(getPlayerStorageValue(cid, storageKey))
  310. local cutSto = string:explode(cutType)
  311. if #cutSto > 0 then
  312. for i = 1, #cutSto do
  313. table.insert(cutSto, cutSto[i])
  314. end
  315. return cutSto
  316. else
  317. return true
  318. end
  319. end
  320.  
  321. function whatTaskIsActive(cid, stoKey) -- Retorna Qual Task Ativa
  322. taskList = _MONSTERS_TASK_SYSTEM_CONFIG
  323. for index, result in pairs(taskList) do
  324. if result.storage == stoKey then
  325. return index
  326. end
  327. end
  328. end
  329.  
  330. function getAwardsList(cid, list) -- Retorna Lista de Premiação
  331. local awardList = ''
  332. get = list
  333. for a = 1, #list do
  334. if isNumber(list[a].id) then
  335. if list[a].multiply <= 1 then
  336. awardList = awardList.."{"..list[a].multiply.."x "..getItemNameById(list[a].id).."}, "
  337. else
  338. awardList = awardList.."{"..list[a].multiply.."x "..getItemPluralNameById(list[a].id).."}, "
  339. end
  340. else
  341. cawardList = awardList:sub(1, (#awardList-2))
  342. awardList = cawardList.." and {"..list[a].multiply.." experience points}"
  343. end
  344. end
  345. return awardList
  346. end
  347.  
  348. function doGiveTaskAwards(cid, list) -- Entrega Lista de Prêmios
  349. if isPlayer(cid) then
  350. for a = 1, #list do
  351. if isNumber(list[a].id) then
  352. doPlayerAddItem(cid, list[a].id, list[a].multiply)
  353. else
  354. doPlayerAddExp(cid, list[a].multiply)
  355. end
  356. end
  357. end
  358. return true
  359. end
  360.  
  361. function doGiveTaskMonsterList(cid, list) -- Retorna Lista de Task Ativas [Tabela Monster Names]
  362. if isPlayer(cid) then
  363. name = ""
  364. for a = 1, #list do
  365. if a == 1 then
  366. name = "{"..list[a].."}"
  367. elseif a > 1 and a < #list then
  368. name = ""..name..", {"..list[a].."}"
  369. else
  370. name = ""..name.." and {"..list[a].."}"
  371. end
  372. end
  373. end
  374. return name
  375. end
  376.  
  377. function doCloseTimedTask(cid, monster)
  378. getInfo = getInfoPlayerTask(cid, monster)
  379. taskList = _MONSTERS_TASK_SYSTEM_CONFIG
  380. getM = taskList[monster]
  381. if getM then
  382. if getInfo then
  383. repet = getInfo[1]
  384. data = getInfo[2]
  385. newValue = "&0/"..repet.."/"..data..""
  386. setPlayerStorageValue(cid, getM.storage, newValue)
  387. setPlayerStorageValue(cid, getM.countSto, 0)
  388. end
  389. end
  390. end
  391.  
  392. function doPlayerDonePersoTask(cid)
  393. taskList = checkPlayerIsInTask(cid)
  394. if #taskList > 0 then
  395. mList = _MONSTERS_TASK_SYSTEM_CONFIG
  396. for i = 1, #taskList do
  397. task = mList[taskList[i]]
  398. if task then
  399. killeds = getPlayerStorageValue(cid, task.countSto)
  400. if killeds == task.count then
  401. return taskList[i]
  402. end
  403. end
  404. end
  405. else
  406. return false
  407. end
  408. end
  409.  
  410. function doOrganizeTaskSto(taskList) -- Retorna Primeira e Última Storage de Todas Tasks
  411. local tabSto = {}
  412. taskList = _MONSTERS_TASK_SYSTEM_CONFIG
  413. for index, result in pairs(taskList) do
  414. if result.storage then
  415. table.insert(tabSto, result.storage)
  416. end
  417. end
  418. table.sort(tabSto, function(a, b) return a < b end)
  419. return tabSto
  420. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement