Advertisement
Guest User

Untitled

a guest
May 29th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.85 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <mod name="Buffs" version="1.0" author="GarQet" contact="http://otland.net/members/garqet/" enabled="yes">
  3. <description>
  4. Add this to your login.lua in creaturescripts:
  5. registerCreatureEvent(cid, "Buffs_dead")
  6. registerCreatureEvent(cid, "Buffs_logout")
  7. registerCreatureEvent(cid, "Buffs_dmg")
  8. registerCreatureEvent(cid, "Buffs_login")
  9. </description>
  10. <config name="buffs"><![CDATA[
  11. config = {
  12. spells = {"utamo mage strong", "utamo sorc super strong", "utamo druid super strong", "utamo strong", "utamo super strong", "utamo mega strong", "utamo supro strong", "utamo knight strong", "utamo knight hyper strong", "utamo wizard strong", "utamo priest strong", "utamo archer strong", "utamo warrior strong", "utamo wizard vita strong", "utamo wizard power strong", "utamo priest vita strong", "utamo priest power strong", "utamo archer vita strong", "utamo archer power strong", "utamo warrior vita strong", "utamo warrior power strong"},
  13. storage = {27280, 27282, 27284, 27286, 27288, 27290, 27292, 27294, 27296, 27298, 27300, 27302, 27304, 27306, 27308, 27310, 27312, 27314, 27316, 27318, 27320},
  14. storage_block_1 = 27322,
  15. storage_block_2 = 27324,
  16. ["utamo mage strong"] = {
  17. cast_name = "utamo mage strong",
  18. manacost = 30000,
  19. vocation = {5, 6},
  20. level = 200000,
  21. time = 5,
  22. mana = TRUE,
  23. percent = 18
  24. },
  25. ["utamo sorc super strong"] = {
  26. cast_name = "utamo sorc super strong",
  27. manacost = 30000,
  28. vocation = {5},
  29. level = 300000,
  30. time = 5,
  31. mana = TRUE,
  32. percent = 22
  33. },
  34. ["utamo wizard strong"] = {
  35. cast_name = "utamo wizard strong",
  36. manacost = 30000,
  37. vocation = {5},
  38. level = 450000,
  39. time = 5,
  40. mana = TRUE,
  41. percent = 31
  42. },
  43. ["utamo wizard vita strong"] = {
  44. cast_name = "utamo wizard vita strong",
  45. manacost = 30000,
  46. vocation = {5},
  47. level = 650000,
  48. time = 5,
  49. mana = TRUE,
  50. percent = 40
  51. },
  52. ["utamo wizard power strong"] = {
  53. cast_name = "utamo wizard power strong",
  54. manacost = 3000,
  55. vocation = {5},
  56. level = 950000,
  57. time = 5,
  58. mana = TRUE,
  59. percent = 50
  60. },
  61. ["utamo druid super strong"] = {
  62. cast_name = "utamo druid super strong",
  63. manacost = 30000,
  64. vocation = {6},
  65. level = 300000,
  66. time = 5,
  67. mana = TRUE,
  68. percent = 22
  69. },
  70. ["utamo priest strong"] = {
  71. cast_name = "utamo priest strong",
  72. manacost = 30000,
  73. vocation = {6},
  74. level = 450000,
  75. time = 5,
  76. mana = TRUE,
  77. percent = 31
  78. },
  79. ["utamo priest vita strong"] = {
  80. cast_name = "utamo priest vita strong",
  81. manacost = 30000,
  82. vocation = {6},
  83. level = 650000,
  84. time = 5,
  85. mana = TRUE,
  86. percent = 41
  87. },
  88. ["utamo priest power strong"] = {
  89. cast_name = "utamo priest power strong",
  90. manacost = 30000,
  91. vocation = {6},
  92. level = 950000,
  93. time = 5,
  94. mana = TRUE,
  95. percent = 51
  96. },
  97. ["utamo strong"] = {
  98. cast_name = "utamo strong",
  99. manacost = 30000,
  100. vocation = {7},
  101. level = 10000,
  102. time = 10,
  103. mana = FALSE,
  104. percent = 80
  105. },
  106. ["utamo super strong"] = {
  107. cast_name = "utamo super strong",
  108. manacost = 80000,
  109. vocation = {7},
  110. level = 150000,
  111. time = 10,
  112. mana = FALSE,
  113. percent = 100
  114. },
  115. ["utamo mega strong"] = {
  116. cast_name = "utamo mega strong",
  117. manacost = 160000,
  118. vocation = {7},
  119. level = 250000,
  120. time = 10,
  121. mana = FALSE,
  122. percent = 125
  123. },
  124. ["utamo supro strong"] = {
  125. cast_name = "utamo supro strong",
  126. manacost = 160000,
  127. vocation = {7},
  128. level = 3000000,
  129. time = 10,
  130. mana = FALSE,
  131. percent = 135
  132. },
  133. ["utamo archer strong"] = {
  134. cast_name = "utamo archer strong",
  135. manacost = 160000,
  136. vocation = {7},
  137. level = 300000,
  138. time = 10,
  139. mana = FALSE,
  140. percent = 145
  141. },
  142. ["utamo archer vita strong"] = {
  143. cast_name = "utamo archer vita strong",
  144. manacost = 160000,
  145. vocation = {7},
  146. level = 450000,
  147. time = 10,
  148. mana = FALSE,
  149. percent = 153
  150. },
  151. ["utamo archer power strong"] = {
  152. cast_name = "utamo archer power strong",
  153. manacost = 160000,
  154. vocation = {7},
  155. level = 650000,
  156. time = 10,
  157. mana = FALSE,
  158. percent = 162
  159. },
  160.  
  161. ["utamo knight strong"] = {
  162. cast_name = "utamo knight strong",
  163. manacost = 30000,
  164. vocation = {8},
  165. level = 30000,
  166. time = 10,
  167. mana = FALSE,
  168. percent = 130
  169. },
  170. ["utamo knight hyper strong"] = {
  171. cast_name = "utamo knight hyper strong",
  172. manacost = 30000,
  173. vocation = {8},
  174. level = 300000,
  175. time = 10,
  176. mana = FALSE,
  177. percent = 140
  178. },
  179. ["utamo warrior strong"] = {
  180. cast_name = "utamo warrior strong",
  181. manacost = 30000,
  182. vocation = {8},
  183. level = 300000,
  184. time = 10,
  185. mana = FALSE,
  186. percent = 150
  187. },
  188. ["utamo warrior vita strong"] = {
  189. cast_name = "utamo warrior vita strong",
  190. manacost = 30000,
  191. vocation = {8},
  192. level = 450000,
  193. time = 10,
  194. mana = FALSE,
  195. percent = 160
  196. },
  197. ["utamo warrior power strong"] = {
  198. cast_name = "utamo warrior power strong",
  199. manacost = 30000,
  200. vocation = {8},
  201. level = 650000,
  202. time = 10,
  203. mana = FALSE,
  204. percent = 170
  205. },
  206.  
  207. talents = 4595,
  208. talents_hp = 25091,
  209. talents_mp = 25092,
  210. talents_dmg = 25093,
  211. rings = {7697, 2357, 10502, 6300},
  212. boots = {11117, 9933, 7892},
  213. [7697] = {
  214. percent_mana = 2,
  215. percent_hp = 2,
  216. storage_mana = 27400,
  217. storage_hp = 27402
  218. },
  219. [2357] = {
  220. percent_mana = 4,
  221. percent_hp = 4,
  222. storage_mana = 27404,
  223. storage_hp = 27406
  224. },
  225. [11117] = {
  226. percent_mana = 10,
  227. percent_hp = 10,
  228. storage_mana = 27408,
  229. storage_hp = 27410
  230. },
  231. [10502] = {
  232. percent_mana = 7,
  233. percent_hp = 7,
  234. storage_mana = 27412,
  235. storage_hp = 27414
  236. },
  237. [9933] = {
  238. percent_mana = 2,
  239. percent_hp = 2,
  240. storage_mana = 27416,
  241. storage_hp = 27418
  242. },
  243. [7892] = {
  244. percent_mana = 3,
  245. percent_hp = 3,
  246. storage_mana = 27420,
  247. storage_hp = 27422
  248. },
  249. storage_items = {27400, 27404, 27408, 27412, 27416, 27420},
  250. storage_IDs = {7697, 2357, 11117, 10502, 9933, 7892},
  251. additional_knight_hp = 1.81,
  252. additional_paladin_hp = 1.75
  253. }
  254. ]]></config>
  255. <talkaction words="utamo" event="script"><![CDATA[
  256. domodlib('buffs')
  257. local function removeBuff(x)
  258. if not isPlayer(x.cid) then
  259. return true
  260. end
  261. local time_2 = db.getResult("SELECT `time` FROM `buffs` WHERE `name` = '".. x.nick .."' LIMIT 1;")
  262. if(time_2:getID() == -1) then
  263. return true
  264. end
  265. local timek = time_2:getDataInt("time")
  266. time_2:free()
  267. if(x.tajm_2 ~= timek) then
  268. return true
  269. end
  270. if(x.tajm_2 - x.tajm >= -100) then
  271. if(x.manas == TRUE) then
  272. setCreatureMaxMana(x.cid, getCreatureMaxMana(x.cid) - getPlayerStorageValue(x.cid, x.storage_1 + 1))
  273. else
  274. setCreatureMaxHealth(x.cid, getCreatureMaxHealth(x.cid) - getPlayerStorageValue(x.cid, x.storage_1 + 1))
  275. end
  276. setPlayerStorageValue(x.cid, x.storage_1, -1)
  277. setPlayerStorageValue(x.cid, x.storage_1 + 1, -1)
  278. setPlayerStorageValue(x.cid, x.storage_2, -1)
  279. doSendAnimatedText(getCreaturePosition(x.cid), "BUFF ENDS", TEXTCOLOR_RED)
  280. doSendMagicEffect(getCreaturePosition(x.cid), CONST_ME_POFF)
  281. else
  282. return true
  283. end
  284. end
  285. function onSay(cid, words, param, channel)
  286. local tekst = string.lower(param)
  287. local params = split(tekst, ' ')
  288. local drugie = {"mage", "sorc", "druid", "strong", "super", "mega", "supro", "knight", "wizard", "priest", "archer", "warrior"}
  289. local trzecie = {"strong", "super", "hyper", "vita", "power"}
  290. local czwarte = {"strong"}
  291. if(table.contains(drugie, params[1]) == FALSE) then
  292. return false
  293. end
  294. if(table.contains(drugie, params[1]) == TRUE and table.contains(trzecie, params[2]) == FALSE and params[2]) then
  295. return false
  296. end
  297. if(table.contains(drugie, params[1]) == TRUE and table.contains(trzecie, params[2]) == TRUE and table.contains(czwarte, params[3]) == FALSE and params[3]) then
  298. return false
  299. end
  300. if(table.contains(drugie, params[1]) == TRUE and table.contains(trzecie, params[2]) == TRUE and table.contains(czwarte, params[3]) == TRUE and params[4]) then
  301. return false
  302. end
  303. local exhaust = {
  304. storage = 27420,
  305. duration = 1
  306. }
  307. if(os.time() - getPlayerStorageValue(cid, exhaust.storage)) < exhaust.duration then
  308. doPlayerSendCancel(cid, "You are exhausted.")
  309. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  310. return true
  311. end
  312. setPlayerStorageValue(cid, exhaust.storage, os.time())
  313. local nick = string.gsub(getCreatureName(cid), "'", "", 20)
  314. if(nick == getCreatureName(cid)) then
  315. nick = getCreatureName(cid)
  316. end
  317. if(table.contains(drugie, params[1]) == TRUE and not params[2]) then
  318. local czar = ""..words.." "..params[1]..""
  319. if(table.contains(config.spells, czar) == FALSE) then
  320. return false
  321. end
  322. if(getPlayerLevel(cid) < config[czar].level) then
  323. doPlayerSendCancel(cid, "Your level is too low.")
  324. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  325. return true
  326. end
  327. if(table.contains(config[czar].vocation, getPlayerVocation(cid)) == FALSE) then
  328. doPlayerSendCancel(cid, "You cannot cast this type of buff.")
  329. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  330. return true
  331. end
  332. local find = 0
  333. for i = 1, #config.spells do
  334. if config[czar].cast_name == config.spells[i] then
  335. find = i
  336. end
  337. end
  338. if(getPlayerStorageValue(cid, config.storage[find]) == 1) then
  339. if(config[czar].mana == TRUE) then
  340. setCreatureMaxMana(cid, getCreatureMaxMana(cid) - getPlayerStorageValue(cid, config.storage[find] + 1))
  341. else
  342. setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) - getPlayerStorageValue(cid, config.storage[find] + 1))
  343. end
  344. setPlayerStorageValue(cid, config.storage[find], -1)
  345. setPlayerStorageValue(cid, config.storage[find] + 1, -1)
  346. setPlayerStorageValue(cid, config.storage_block_1, -1)
  347. doPlayerSendCancel(cid, "You activated once again the same buff.")
  348. db.executeQuery("UPDATE `buffs` SET `time` = '".. os.time() + config[czar].time * 60 * 1000 .. "' WHERE `name` = '".. nick .."' LIMIT 1;")
  349. end
  350. if(getPlayerStorageValue(cid, config.storage_block_1) > 0) then
  351. doPlayerSendCancel(cid, "Other buff is activated on your character, please wait until ends.")
  352. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  353. return true
  354. end
  355. if(config[czar].mana == TRUE) then
  356. local percent = getPlayerStorageValue(cid, config.talents_mp)
  357. setPlayerStorageValue(cid, config.storage[find] + 1, getStandartMANA(cid) * ((percent + config[czar].percent) / 100))
  358. setCreatureMaxMana(cid, getCreatureMaxMana(cid) + (getStandartMANA(cid) * ((percent + config[czar].percent) / 100)))
  359. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_BLUE)
  360. setPlayerStorageValue(cid, config.storage_block_2, 1)
  361. doSendAnimatedText(getCreaturePosition(cid), "BUFF", TEXTCOLOR_LIGHTBLUE)
  362. addEvent(function() doSendAnimatedText(getCreaturePosition(cid), "ACTIVE", TEXTCOLOR_LIGHTBLUE) end, 100)
  363. else
  364. local percent = getPlayerStorageValue(cid, config.talents_hp)
  365. if isKnight(cid) then
  366. percent = percent * config.additional_knight_hp
  367. elseif isPaladin(cid) then
  368. percent = percent * config.additional_paladin_hp
  369. end
  370. setPlayerStorageValue(cid, config.storage[find] + 1, getStandartHP(cid) * ((percent + config[czar].percent) / 100))
  371. setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + (getStandartHP(cid) * ((percent + config[czar].percent) / 100)))
  372. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_RED)
  373. setPlayerStorageValue(cid, config.storage_block_2, 2)
  374. doSendAnimatedText(getCreaturePosition(cid), "BUFF", TEXTCOLOR_RED)
  375. addEvent(function() doSendAnimatedText(getCreaturePosition(cid), "ACTIVE", TEXTCOLOR_RED) end, 100)
  376. end
  377. -- doAddCondition(cid, combat)
  378. doCreatureSay(cid, config[czar].cast_name, TALKTYPE_ORANGE_1)
  379. setPlayerStorageValue(cid, config.storage_block_1, config.storage[find])
  380. setPlayerStorageValue(cid, config.storage[find], 1)
  381. db.executeQuery("UPDATE `buffs` SET `time` = '".. os.time() + config[czar].time * 60 * 1000 .. "' WHERE `name` = '".. nick .."' LIMIT 1;")
  382. local time_2 = db.getResult("SELECT `time` FROM `buffs` WHERE `name` = '".. nick .."' LIMIT 1;")
  383. if(time_2:getID() == -1) then
  384. return true
  385. end
  386. local timek = time_2:getDataInt("time")
  387. time_2:free()
  388. addEvent(removeBuff, config[czar].time * 60 * 1000, {cid = cid, timing = config[czar].time * 60 * 1000, manas = config[czar].mana, storage_1 = config.storage[find], storage_2 = config.storage_block_1, tajm = os.time(), tajm_2 = timek, nick = nick})
  389. elseif(table.contains(drugie, params[1]) == TRUE and table.contains(trzecie, params[2]) == TRUE and not params[3]) then
  390. local czar = ""..words.." "..params[1].." "..params[2]..""
  391. if(table.contains(config.spells, czar) == FALSE) then
  392. return false
  393. end
  394. if(getPlayerLevel(cid) < config[czar].level) then
  395. doPlayerSendCancel(cid, "Your level is too low.")
  396. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  397. return true
  398. end
  399. if(table.contains(config[czar].vocation, getPlayerVocation(cid)) == FALSE) then
  400. doPlayerSendCancel(cid, "You cannot cast this type of buff.")
  401. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  402. return true
  403. end
  404. local find = 0
  405. for i = 1, #config.spells do
  406. if config[czar].cast_name == config.spells[i] then
  407. find = i
  408. end
  409. end
  410. if(getPlayerStorageValue(cid, config.storage[find]) == 1) then
  411. if(config[czar].mana == TRUE) then
  412. setCreatureMaxMana(cid, getCreatureMaxMana(cid) - getPlayerStorageValue(cid, config.storage[find] + 1))
  413. else
  414. setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) - getPlayerStorageValue(cid, config.storage[find] + 1))
  415. end
  416. setPlayerStorageValue(cid, config.storage[find], -1)
  417. setPlayerStorageValue(cid, config.storage[find] + 1, -1)
  418. setPlayerStorageValue(cid, config.storage_block_1, -1)
  419. doPlayerSendCancel(cid, "You activated once again the same buff.")
  420. db.executeQuery("UPDATE `buffs` SET `time` = '".. os.time() + config[czar].time * 60 * 1000 .. "' WHERE `name` = '".. nick .."' LIMIT 1;")
  421. end
  422. if(getPlayerStorageValue(cid, config.storage_block_1) > 0) then
  423. doPlayerSendCancel(cid, "Other buff is activated on your character, please wait until ends.")
  424. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  425. return true
  426. end
  427. if(config[czar].mana == TRUE) then
  428. local percent = getPlayerStorageValue(cid, config.talents_mp)
  429. setPlayerStorageValue(cid, config.storage[find] + 1, getStandartMANA(cid) * ((percent + config[czar].percent) / 100))
  430. setCreatureMaxMana(cid, getCreatureMaxMana(cid) + (getStandartMANA(cid) * ((percent + config[czar].percent) / 100)))
  431. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_BLUE)
  432. setPlayerStorageValue(cid, config.storage_block_2, 1)
  433. doSendAnimatedText(getCreaturePosition(cid), "BUFF", TEXTCOLOR_LIGHTBLUE)
  434. addEvent(function() doSendAnimatedText(getCreaturePosition(cid), "ACTIVE", TEXTCOLOR_LIGHTBLUE) end, 100)
  435. else
  436. local percent = getPlayerStorageValue(cid, config.talents_hp)
  437. if isKnight(cid) then
  438. percent = percent * config.additional_knight_hp
  439. elseif isPaladin(cid) then
  440. percent = percent * config.additional_paladin_hp
  441. end
  442. setPlayerStorageValue(cid, config.storage[find] + 1, getStandartHP(cid) * ((percent + config[czar].percent) / 100))
  443. setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + (getStandartHP(cid) * ((percent + config[czar].percent) / 100)))
  444. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_RED)
  445. setPlayerStorageValue(cid, config.storage_block_2, 2)
  446. doSendAnimatedText(getCreaturePosition(cid), "BUFF", TEXTCOLOR_RED)
  447. addEvent(function() doSendAnimatedText(getCreaturePosition(cid), "ACTIVE", TEXTCOLOR_RED) end, 100)
  448. end
  449. -- doAddCondition(cid, combat)
  450. doCreatureSay(cid, config[czar].cast_name, TALKTYPE_ORANGE_1)
  451. setPlayerStorageValue(cid, config.storage_block_1, config.storage[find])
  452. setPlayerStorageValue(cid, config.storage[find], 1)
  453. db.executeQuery("UPDATE `buffs` SET `time` = '".. os.time() + config[czar].time * 60 * 1000 .. "' WHERE `name` = '".. nick .."' LIMIT 1;")
  454. local time_2 = db.getResult("SELECT `time` FROM `buffs` WHERE `name` = '".. nick .."' LIMIT 1;")
  455. if(time_2:getID() == -1) then
  456. return true
  457. end
  458. local timek = time_2:getDataInt("time")
  459. time_2:free()
  460. addEvent(removeBuff, config[czar].time * 60 * 1000, {cid = cid, timing = config[czar].time * 60 * 1000, manas = config[czar].mana, storage_1 = config.storage[find], storage_2 = config.storage_block_1, tajm = os.time(), tajm_2 = timek, nick = nick})
  461. elseif(table.contains(drugie, params[1]) == TRUE and table.contains(trzecie, params[2]) == TRUE and table.contains(czwarte, params[3]) == TRUE and not params[4]) then
  462. local czar = ""..words.." "..params[1].." "..params[2].." "..params[3]..""
  463. if(table.contains(config.spells, czar) == FALSE) then
  464. return false
  465. end
  466. if(getPlayerLevel(cid) < config[czar].level) then
  467. doPlayerSendCancel(cid, "Your level is too low.")
  468. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  469. return true
  470. end
  471. if(table.contains(config[czar].vocation, getPlayerVocation(cid)) == FALSE) then
  472. doPlayerSendCancel(cid, "You cannot cast this type of buff.")
  473. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  474. return true
  475. end
  476. local find = 0
  477. for i = 1, #config.spells do
  478. if config[czar].cast_name == config.spells[i] then
  479. find = i
  480. end
  481. end
  482. if(getPlayerStorageValue(cid, config.storage[find]) == 1) then
  483. if(config[czar].mana == TRUE) then
  484. setCreatureMaxMana(cid, getCreatureMaxMana(cid) - getPlayerStorageValue(cid, config.storage[find] + 1))
  485. else
  486. setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) - getPlayerStorageValue(cid, config.storage[find] + 1))
  487. end
  488. setPlayerStorageValue(cid, config.storage[find], -1)
  489. setPlayerStorageValue(cid, config.storage[find] + 1, -1)
  490. setPlayerStorageValue(cid, config.storage_block_1, -1)
  491. doPlayerSendCancel(cid, "You activated once again the same buff.")
  492. db.executeQuery("UPDATE `buffs` SET `time` = '".. os.time() + config[czar].time * 60 * 1000 .. "' WHERE `name` = '".. nick .."' LIMIT 1;")
  493. end
  494. if(getPlayerStorageValue(cid, config.storage_block_1) > 0) then
  495. doPlayerSendCancel(cid, "Other buff is activated on your character, please wait until ends.")
  496. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  497. return true
  498. end
  499. if(config[czar].mana == TRUE) then
  500. local percent = getPlayerStorageValue(cid, config.talents_mp)
  501. setPlayerStorageValue(cid, config.storage[find] + 1, getStandartMANA(cid) * ((percent + config[czar].percent) / 100))
  502. setCreatureMaxMana(cid, getCreatureMaxMana(cid) + (getStandartMANA(cid) * ((percent + config[czar].percent) / 100)))
  503. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_BLUE)
  504. setPlayerStorageValue(cid, config.storage_block_2, 1)
  505. doSendAnimatedText(getCreaturePosition(cid), "BUFF", TEXTCOLOR_LIGHTBLUE)
  506. addEvent(function() doSendAnimatedText(getCreaturePosition(cid), "ACTIVE", TEXTCOLOR_LIGHTBLUE) end, 100)
  507. else
  508. local percent = getPlayerStorageValue(cid, config.talents_hp)
  509. if isKnight(cid) then
  510. percent = percent * config.additional_knight_hp
  511. elseif isPaladin(cid) then
  512. percent = percent * config.additional_paladin_hp
  513. end
  514. setPlayerStorageValue(cid, config.storage[find] + 1, getStandartHP(cid) * ((percent + config[czar].percent) / 100))
  515. setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + (getStandartHP(cid) * ((percent + config[czar].percent) / 100)))
  516. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_RED)
  517. setPlayerStorageValue(cid, config.storage_block_2, 2)
  518. doSendAnimatedText(getCreaturePosition(cid), "BUFF", TEXTCOLOR_RED)
  519. addEvent(function() doSendAnimatedText(getCreaturePosition(cid), "ACTIVE", TEXTCOLOR_RED) end, 100)
  520. end
  521. -- doAddCondition(cid, combat)
  522. doCreatureSay(cid, config[czar].cast_name, TALKTYPE_ORANGE_1)
  523. setPlayerStorageValue(cid, config.storage_block_1, config.storage[find])
  524. setPlayerStorageValue(cid, config.storage[find], 1)
  525. db.executeQuery("UPDATE `buffs` SET `time` = '".. os.time() + config[czar].time * 60 * 1000 .. "' WHERE `name` = '".. nick .."' LIMIT 1;")
  526. local time_2 = db.getResult("SELECT `time` FROM `buffs` WHERE `name` = '".. nick .."' LIMIT 1;")
  527. if(time_2:getID() == -1) then
  528. return true
  529. end
  530. local timek = time_2:getDataInt("time")
  531. time_2:free()
  532. addEvent(removeBuff, config[czar].time * 60 * 1000, {cid = cid, timing = config[czar].time * 60 * 1000, manas = config[czar].mana, storage_1 = config.storage[find], storage_2 = config.storage_block_1, tajm = os.time(), tajm_2 = timek, nick = nick})
  533. return true
  534. end
  535. return true
  536. end
  537. ]]></talkaction>
  538. <event type="login" name="Buffs_login" event="script"><![CDATA[
  539. domodlib('buffs')
  540. function onLogin(cid)
  541. if(getPlayerLastLoginSaved(cid) <= 0) then
  542. setPlayerStorageValue(cid, config.talents_hp, 0)
  543. setPlayerStorageValue(cid, config.talents_mp, 0)
  544. setPlayerStorageValue(cid, config.talents_dmg, 0)
  545. setPlayerStorageValue(cid, config.talents, 0)
  546. end
  547. if(getPlayerStorageValue(cid, config.talents_hp) == -1) then
  548. setPlayerStorageValue(cid, config.talents_hp, 0)
  549. end
  550. if(getPlayerStorageValue(cid, config.talents_mp) == -1) then
  551. setPlayerStorageValue(cid, config.talents_mp, 0)
  552. end
  553. if(getPlayerStorageValue(cid, config.talents_dmg) == -1) then
  554. setPlayerStorageValue(cid, config.talents_dmg, 0)
  555. end
  556. if(getPlayerStorageValue(cid, config.talents) == -1) then
  557. setPlayerStorageValue(cid, config.talents, 0)
  558. end
  559. --local hp = getPlayerStorageValue(cid, config.talents_hp)
  560. --local mp = getPlayerStorageValue(cid, config.talents_mp)
  561. --local dmg = getPlayerStorageValue(cid, config.talents_dmg)
  562. --local note = getPlayerStorageValue(cid, config.talents)
  563. --local x = getPlayerLevel(cid)
  564. --local z = {}
  565. --for i = 1, 50 do
  566. --if x >= 50000 then
  567. --x = x - 50000
  568. --else
  569. --table.insert(z, i - 1)
  570. --end
  571. --end
  572. --local dodaj = 0
  573. --if(z[1] <= 9) then
  574. --dodaj = 2 * z[1]
  575. --else
  576. --dodaj = (2 * 9) + (z[1] - 9)
  577. --end
  578. --if(hp + mp + dmg + note) ~= dodaj then
  579. --setPlayerStorageValue(cid, config.talents_hp, 0)
  580. --setPlayerStorageValue(cid, config.talents_mp, 0)
  581. --setPlayerStorageValue(cid, config.talents_dmg, 0)
  582. --setPlayerStorageValue(cid, config.talents, dodaj)
  583. --end
  584. recalculateHPandMana(cid)
  585. local nick = string.gsub(getCreatureName(cid), "'", "", 20)
  586. if(nick == getCreatureName(cid)) then
  587. nick = getCreatureName(cid)
  588. end
  589. local res = db.getResult("SELECT `name` FROM `buffs` WHERE `name` = '".. nick .."' LIMIT 1;")
  590. if(res:getID() == -1) then
  591. db.executeQuery("INSERT INTO `buffs` (name) VALUES ('".. nick .."')")
  592. end
  593. return true
  594. end
  595. ]]></event>
  596. <event type="preparedeath" name="Buffs_dead" event="script"><![CDATA[
  597. domodlib('buffs')
  598. function onPrepareDeath(cid, deathList)
  599. if(not isPlayer(cid)) then
  600. return true
  601. end
  602. if(getPlayerStorageValue(cid, 49597) == 1) then
  603. return true
  604. end
  605. setPlayerStorageValue(cid, 27400, 0)
  606. for i = 1, 38 do
  607. setPlayerStorageValue(cid, (27400 + i), 0)
  608. end
  609. if(getPlayerStorageValue(cid, config.storage_block_1) > 0) then
  610. local find = getPlayerStorageValue(cid, config.storage_block_1)
  611. local find_2 = getPlayerStorageValue(cid, config.storage_block_1) + 1
  612. local what = getPlayerStorageValue(cid, config.storage_block_2)
  613. if(what == 1) then
  614. setCreatureMaxMana(cid, -(getPlayerStorageValue(cid, find_2)))
  615. setPlayerStorageValue(cid, find, -1)
  616. setPlayerStorageValue(cid, find_2, -1)
  617. setPlayerStorageValue(cid, config.storage_block_1, -1)
  618. setPlayerStorageValue(cid, config.storage_block_2, -1)
  619. elseif(what == 2) then
  620. setCreatureMaxHealth(cid, -(getPlayerStorageValue(cid, find_2)))
  621. setPlayerStorageValue(cid, find, -1)
  622. setPlayerStorageValue(cid, find_2, -1)
  623. setPlayerStorageValue(cid, config.storage_block_1, -1)
  624. setPlayerStorageValue(cid, config.storage_block_2, -1)
  625. end
  626. return true
  627. end
  628. return true
  629. end
  630. ]]></event>
  631. <event type="logout" name="Buffs_logout" event="script"><![CDATA[
  632. domodlib('buffs')
  633. function onLogout(cid)
  634. if(not isPlayer(cid)) then
  635. return true
  636. end
  637. setPlayerStorageValue(cid, 27400, 0)
  638. for i = 1, 38 do
  639. setPlayerStorageValue(cid, (27400 + i), 0)
  640. end
  641. if(getPlayerStorageValue(cid, config.storage_block_1) == nil or getPlayerStorageValue(cid, config.storage_block_1) == "nan") then
  642. setPlayerStorageValue(cid, config.storage_block_1, -1)
  643. end
  644. if(getPlayerStorageValue(cid, config.storage_block_1) >= 0) then
  645. local find = getPlayerStorageValue(cid, config.storage_block_1)
  646. local find_2 = getPlayerStorageValue(cid, config.storage_block_1) + 1
  647. local what = getPlayerStorageValue(cid, config.storage_block_2)
  648. if(what == 1) then
  649. setCreatureMaxMana(cid, -(getPlayerStorageValue(cid, find_2)))
  650. setPlayerStorageValue(cid, find, -1)
  651. setPlayerStorageValue(cid, find_2, -1)
  652. setPlayerStorageValue(cid, config.storage_block_1, -1)
  653. setPlayerStorageValue(cid, config.storage_block_2, -1)
  654. elseif(what == 2) then
  655. setCreatureMaxHealth(cid, -(getPlayerStorageValue(cid, find_2)))
  656. setPlayerStorageValue(cid, find, -1)
  657. setPlayerStorageValue(cid, find_2, -1)
  658. setPlayerStorageValue(cid, config.storage_block_1, -1)
  659. setPlayerStorageValue(cid, config.storage_block_2, -1)
  660. end
  661. return true
  662. end
  663. return true
  664. end
  665. ]]></event>
  666. <event type="statschange" name="Buffs_dmg" event="script"><![CDATA[
  667. domodlib('buffs')
  668. function onStatsChange(cid, attacker, type, combat, value)
  669. if isPlayer(attacker) and isCreature(cid) and not isPlayer(cid) then
  670. local tal = getPlayerStorageValue(attacker, config.talents_dmg)
  671. if tal < 1 then
  672. return true
  673. end
  674. local dmg = tal / 100
  675. local total = value * dmg
  676. local rest = 0
  677. local mana = 0
  678. if((type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and tal > 0 and value > 0) then
  679. doCreatureAddHealth(cid, -total)
  680. doSendAnimatedText(getCreaturePosition(cid), total, TEXTCOLOR_RED)
  681. return doPlayerSendTextMessage(attacker, 24, "You deal ".. total .." additional damage to ".. getCreatureName(cid) .." (talent points).") and true
  682. end
  683. elseif isPlayer(attacker) and isCreature(cid) and isPlayer(cid) then
  684. local tal = getPlayerStorageValue(attacker, config.talents_dmg)
  685. if tal < 1 then
  686. return true
  687. end
  688. local dmg = tal / 100
  689. local total = value * dmg
  690. local rest = 0
  691. local mana = 0
  692. if((type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and tal > 0 and value > 0) then
  693. if(getCreatureCondition(cid, CONDITION_MANASHIELD)) then
  694. if(total > getCreatureMana(cid)) then
  695. rest = total - getCreatureMana(cid)
  696. end
  697. mana = 1
  698. end
  699. if(type == STATSCHANGE_MANAGAIN or type == STATSCHANGE_HEALTHGAIN) then
  700. return true
  701. end
  702. if(mana == 1 and rest == 0) then
  703. doCreatureAddMana(cid, -total)
  704. elseif(mana == 1 and rest > 0) then
  705. doCreatureAddMana(cid, -(total - rest))
  706. doCreatureAddHealth(cid, -rest)
  707. doSendAnimatedText(getCreaturePosition(cid), rest, TEXTCOLOR_RED)
  708. else
  709. doCreatureAddHealth(cid, -total)
  710. doSendAnimatedText(getCreaturePosition(cid), total, TEXTCOLOR_RED)
  711. end
  712. return doPlayerSendTextMessage(attacker, 24, "You deal ".. total .." additional damage to ".. getCreatureName(cid) .." (talent points).") and true
  713. end
  714. end
  715. return true
  716. end
  717. ]]></event>
  718. <event type="combat" name="buffs_combat" event="script"><![CDATA[
  719. domodlib('buffs')
  720. function onCombat(cid, target)
  721. if not isPlayer(target) and isCreature(target) then
  722. registerCreatureEvent(target, "Buffs_dmg")
  723. end
  724. return true
  725. end
  726. ]]></event>
  727. <event type="attack" name="buffs_attack" event="script"><![CDATA[
  728. domodlib('buffs')
  729. function onAttack(cid, target)
  730. if not isPlayer(target) and isCreature(target) then
  731. registerCreatureEvent(target, "Buffs_dmg")
  732. end
  733. return true
  734. end
  735. ]]></event>
  736. <talkaction words="!wille" access="3" event="script"><![CDATA[
  737. domodlib('buffs')
  738. function onSay(cid, words, param, channel)
  739. if getPlayerGroupId(cid) > 3 then
  740. if(param == '') then
  741. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Missing param, write nick.")
  742. return true
  743. end
  744. local t = split(param, ',')
  745. local pid = getPlayerByNameWildcard(t[1])
  746. if(t[1]) then
  747. if(not pid) then
  748. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player '" .. t[1] .. "' not found.")
  749. return true
  750. end
  751. if(getCreatureName(pid) == getCreatureName(cid)) then
  752. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot use this command on yourself.")
  753. return true
  754. end
  755. end
  756. recalculateHPandMana(pid)
  757. doSendMagicEffect(getCreaturePosition(pid), CONST_ME_FIREWORK_RED)
  758. doCreatureSay(pid, "Recalculated!", 20)
  759. return true
  760. end
  761. return true
  762. end
  763. ]]></talkaction>
  764. <talkaction words="!buffs" event="script"><![CDATA[
  765. domodlib('buffs')
  766. function onSay(cid, words, param, channel)
  767. local text = "Buffs on Evolera.tk:\n"
  768. local a = ""
  769. local amount = 0
  770. for i = 1, #config.spells do
  771. a = config.spells[i]
  772. local b = 0
  773. if(getPlayerLevel(cid) >= config[a].level and table.contains(config[a].vocation, getPlayerVocation(cid)) == TRUE) then
  774. if(b == 0) then
  775. text = text .. "\nNow can use:\n"
  776. b = 1
  777. end
  778. text = text .. "* " .. config[a].cast_name .. " - " .. config[a].manacost .. " MP, " .. config[a].time .. " mins, + " .. config[a].percent .. "% of your current " .. (config[a].mana == TRUE and "MP" or "HP") .. "\n"
  779. amount = amount + 1
  780. end
  781. end
  782. if(amount > 0) then
  783. for i = 1, #config.spells do
  784. a = config.spells[i]
  785. local c = 0
  786. if(getPlayerLevel(cid) < config[a].level and table.contains(config[a].vocation, getPlayerVocation(cid)) == TRUE) then
  787. if(c == 0) then
  788. text = text .. "\nStill you can get:\n"
  789. c = 1
  790. end
  791. text = text .. "* " .. config[a].cast_name .. " - " .. config[a].manacost .. " MP, min. " .. config[a].level .. " level, " .. config[a].time .. " mins, + " .. config[a].percent .. "% of your current " .. (config[a].mana == TRUE and "MP" or "HP") .. "\n"
  792. end
  793. end
  794. elseif(amount == 0) then
  795. text = text .. "\n\nCurrently you cannot use any buff.\n\nAvailable buffs for your vocation:\n"
  796. for i = 1, #config.spells do
  797. a = config.spells[i]
  798. if(getPlayerLevel(cid) < config[a].level and table.contains(config[a].vocation, getPlayerVocation(cid)) == TRUE) then
  799. text = text .. "* " .. config[a].cast_name .. " - " .. config[a].manacost .. " MP, min. " .. config[a].level .. " level, " .. config[a].time .. " mins, + " .. config[a].percent .. "% of your current " .. (config[a].mana == TRUE and "MP" or "HP") .. "\n"
  800. end
  801. end
  802. end
  803. text = text .."\nAmount of additional percent depends of talent points MP/HP!"
  804. doShowTextDialog(cid, 2175, text)
  805. return true
  806. end
  807. ]]></talkaction>
  808. <globalevent name="checking" interval="1500" event="script"><![CDATA[
  809. domodlib('buffs')
  810. function onThink(interval, lastExecution, thinkInterval)
  811. local online = getPlayersOnline()
  812. local Online = {}
  813. local playersOnline = {}
  814. for _, kid in pairs(online) do
  815. if(isPlayer(kid)) then
  816. table.insert(Online, kid)
  817. end
  818. end
  819. if #Online > 0 then
  820. for _, cid in ipairs(getPlayersOnline()) do
  821. local wear = {}
  822. local items = {}
  823. local cur = {}
  824. if not isPlayer(cid) then
  825. return true
  826. end
  827. for i = 1, #config.storage_items do
  828. if getPlayerStorageValue(cid, config.storage_items[i]) == 1 then
  829. table.insert(wear, config.storage_items[i])
  830. table.insert(items, config.storage_IDs[i])
  831. else
  832. table.insert(wear, 0)
  833. table.insert(items, 0)
  834. end
  835. if getPlayerSlotItem(cid, CONST_SLOT_RING).itemid == config.rings[1] and i == 1 then
  836. table.insert(cur, getPlayerSlotItem(cid, CONST_SLOT_RING).itemid)
  837. elseif getPlayerSlotItem(cid, CONST_SLOT_RING).itemid ~= config.rings[1] and i == 1 then
  838. table.insert(cur, 0)
  839. end
  840. if getPlayerSlotItem(cid, CONST_SLOT_RING).itemid == config.rings[2] and i == 2 then
  841. table.insert(cur, getPlayerSlotItem(cid, CONST_SLOT_RING).itemid)
  842. elseif getPlayerSlotItem(cid, CONST_SLOT_RING).itemid ~= config.rings[2] and i == 2 then
  843. table.insert(cur, 0)
  844. end
  845. if getPlayerSlotItem(cid, CONST_SLOT_RING).itemid == config.rings[3] and i == 4 then
  846. table.insert(cur, getPlayerSlotItem(cid, CONST_SLOT_RING).itemid)
  847. elseif getPlayerSlotItem(cid, CONST_SLOT_RING).itemid ~= config.rings[3] and i == 4 then
  848. table.insert(cur, 0)
  849. end
  850. if getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid == config.boots[1] and i == 3 then
  851. table.insert(cur, getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid)
  852. elseif getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid ~= config.boots[1] and i == 3 then
  853. table.insert(cur, 0)
  854. end
  855. if getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid == config.boots[2] and i == 5 then
  856. table.insert(cur, getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid)
  857. elseif getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid ~= config.boots[2] and i == 5 then
  858. table.insert(cur, 0)
  859. end
  860. if getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid == config.boots[3] and i == 6 then
  861. table.insert(cur, getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid)
  862. elseif getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid ~= config.boots[3] and i == 6 then
  863. table.insert(cur, 0)
  864. end
  865. end
  866. local slot_2 = ""
  867. for a = 1, #wear do
  868. if a == 1 or a == 2 or a == 4 then
  869. slot_2 = CONST_SLOT_RING
  870. elseif a == 3 or a == 5 or a == 6 then
  871. slot_2 = CONST_SLOT_FEET
  872. end
  873. if wear[a] ~= 0 then
  874. if wear[a] > 0 and items[a] > 0 then
  875. if getPlayerSlotItem(cid, slot_2).itemid ~= items[a] then
  876. local item = items[a]
  877. setPlayerStorageValue(cid, config[item].storage_mana, 0)
  878. setPlayerStorageValue(cid, config[item].storage_hp, 0)
  879. setCreatureMaxMana(cid, getCreatureMaxMana(cid) - (getPlayerStorageValue(cid, config[item].storage_mana + 1)))
  880. setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) - (getPlayerStorageValue(cid, config[item].storage_hp + 1)))
  881. setPlayerStorageValue(cid, config[item].storage_mana + 1, 0)
  882. setPlayerStorageValue(cid, config[item].storage_hp + 1, 0)
  883. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  884. doSendAnimatedText(getCreaturePosition(cid), "EXTRAS", TEXTCOLOR_RED)
  885. addEvent(function() doSendAnimatedText(getCreaturePosition(cid), "DEACTIVE", TEXTCOLOR_RED) end, 300)
  886. table.remove(wear, a)
  887. table.insert(wear, a, 0)
  888. table.remove(items, a)
  889. table.insert(items, a, 0)
  890. table.remove(cur, a)
  891. table.insert(cur, a, 0)
  892. end
  893. end
  894. end
  895. end
  896. local slot = ""
  897. local c = ""
  898. for z = 1, #items do
  899. if items[z] ~= cur[z] then
  900. if z == 1 or z == 2 or z == 4 then
  901. slot = CONST_SLOT_RING
  902. c = config.rings
  903. elseif z == 3 or z == 5 or z == 6 then
  904. slot = CONST_SLOT_FEET
  905. c = config.boots
  906. end
  907. if table.contains(c, getPlayerSlotItem(cid, slot).itemid) == TRUE then
  908. local item = getPlayerSlotItem(cid, slot).itemid
  909. setCreatureMaxMana(cid, getCreatureMaxMana(cid) + (getStandartMANA(cid) * (config[item].percent_mana / 100)))
  910. setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + (getStandartHP(cid) * (config[item].percent_hp / 100)))
  911. setPlayerStorageValue(cid, config[item].storage_mana, 1)
  912. setPlayerStorageValue(cid, config[item].storage_hp, 1)
  913. setPlayerStorageValue(cid, config[item].storage_mana + 1, getStandartMANA(cid) * (config[item].percent_mana / 100))
  914. setPlayerStorageValue(cid, config[item].storage_hp + 1, getStandartHP(cid) * (config[item].percent_hp / 100))
  915. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_YELLOW)
  916. doSendAnimatedText(getCreaturePosition(cid), "EXTRAS", TEXTCOLOR_YELLOW)
  917. addEvent(function() doSendAnimatedText(getCreaturePosition(cid), "ACTIVE", TEXTCOLOR_YELLOW) end, 300)
  918. end
  919. end
  920. end
  921. end
  922. end
  923. return true
  924. end
  925. ]]></globalevent>
  926. </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement