Guest User

Untitled

a guest
Dec 21st, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 83.85 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <mod name="Battle Boats" version="1.0" author="" contact="" enabled="yes">
  3. <description>
  4. Add this to lib/functions:
  5. czekaj = coroutine.yield
  6. function czekanie(c)
  7. if(coroutine.status(c) ~= 'dead') then
  8. local _, czas = coroutine.resume(c)
  9. addEvent(czekanie, czas, c)
  10. end
  11. end
  12. function zacznijCzekac(f)
  13. if(type(f) == 'function') then
  14. local c = coroutine.create(f)
  15. czekanie(c)
  16. end
  17. end
  18. function doPlayerRemoveAllStoragesFromBattleBoats(cid)
  19. setPlayerStorageValue(cid, 11610, -1)
  20. setPlayerStorageValue(cid, 11611, -1)
  21. setPlayerStorageValue(cid, 11612, -1)
  22. setPlayerStorageValue(cid, 11613, -1)
  23. setPlayerStorageValue(cid, 11614, -1)
  24. setPlayerStorageValue(cid, 11616, -1)
  25. setPlayerStorageValue(cid, 11618, -1)
  26. setPlayerStorageValue(cid, 11619, -1)
  27. setPlayerStorageValue(cid, 11620, -1)
  28. setPlayerStorageValue(cid, 11622, -1)
  29. end
  30. function doRemoveAllGlobStoragesFromBattleBoats()
  31. setGlobalStorageValue(11615, -1)
  32. setGlobalStorageValue(11617, -1)
  33. setGlobalStorageValue(11621, -1)
  34. setGlobalStorageValue(11622, -1)
  35. setGlobalStorageValue(11623, -1)
  36. end
  37. -------------------------------------------
  38. Add this to login.lua:
  39. registerCreatureEvent(cid, "BattleKill")
  40. -------------------------------------------
  41. [id] = {
  42. HERE YOU HAVE ALL ITEMS WHICH ARE NEEDED TO THIS EVENT
  43. }
  44. [amount] = {
  45. HERE YOU HAVE ALL AMOUNT OF ITEMS WHICH ARE NEEDED TO THIS EVENT
  46. }
  47. [timer] = {
  48. HERE YOU HAVE TIME AFTER THING WILL STARTS (IN SECONDS!)
  49. present = for how many seconds (now is 10sec) present will be places on random area
  50. dragons = for how many seconds (now is 1sec) dragon will be spawned
  51. startEvent = after how many seconds event will start (now is 60sec)
  52. blockitems = after how many seconds player be able to use for ex. bomb or ambush (now is 30sec)
  53. check = for how many seconds (now is 20sec) event will check ready players which are registred in event
  54. kickout = for how many seconds (now is 60sec) player will be kickout from the event if he didn't come to any of the free boats
  55. }
  56. [presents] = {
  57. HERE YOU MUST PAST POSITIONS WHERE PRESENT CAN FALL FROM THE SKY
  58. }
  59. [dragons] = {
  60. x = {
  61. HERE YOU MUST PAST POSITIONS "X" - AREA WHERE DRAGON WILL BE SPAWNED. THIS ARE WHERE PRESENT CAN BE CREATED.
  62. {1024, 1028},
  63. IT MEANS FROM X TO X, AND YOU MUST SET NOW IN POSITION "Y", HERE:
  64. {196, 200},
  65. }
  66. y = {
  67. HERE YOU MUST PAST POSITIONS "Y" - AREA WHERE DRAGON WILL BE SPAWNED. THIS ARE WHERE PRESENT CAN BE CREATED.
  68. {196, 200},
  69. IT MEANS FROM Y TO Y, AND YOU MUST SET NOW IN POSITION "X", HERE:
  70. {1024, 1028},
  71. }
  72. }
  73. start = STORAGE,
  74. plynie = STORAGE,
  75. strona = STORAGE,
  76. palenie = STORAGE,
  77. stop = STORAGE,
  78. smok = STORAGE,
  79. zapisany = STORAGE,
  80. playersCount = STORAGE,
  81. gotowy = STORAGE,
  82. gotowy_e = STORAGE,
  83. gotowy_w = STORAGE,
  84. blockbomb = STORAGE,
  85. zakonczone = STORAGE,
  86. wystartowal = STORAGE,
  87. startPosition = POSITION WHERE PLAYER WILL BE TELEPORTED AFTER JOINING TO THE EVENT,
  88. playersNeededToStartEvent = HOW MANY PLAYERS IS NEEDED TO START EVENT,
  89. max = MAX OF THE PLAYER WHICH CAN JOIN TO THE EVENT,
  90. przeszkoda = IF THE BOAT COLLIDER WITH THIS ID OF ITEMS WILL STARTS TO BURN,
  91. rewardsId = ITEMS OD IDS WHICH PLAYER CAN REACH AFTER WINNING EVENT,
  92. crystal_counts = IF REWARD = 2160 (CRYSTAL COINS) THEN HERE YOU MUST SET AMOUNT OF CC,
  93. speed = DON'T SET IT!,
  94. waters = ID OF WATERS WHERE PLAYER CAN USE BOMB OR AMBUSH
  95. </description>
  96. <config name="q"><![CDATA[
  97. q = {
  98. start = 11610,
  99. plynie = 11611,
  100. strona = 11612,
  101. palenie = 11613,
  102. stop = 11614,
  103. smok = 11615,
  104. zapisany = 11616,
  105. playersCount = 11617,
  106. gotowy = 11618,
  107. gotowy_e = 11619,
  108. gotowy_w = 11620,
  109. blockbomb = 11621,
  110. zakonczone = 11622,
  111. wystartowal = 11623,
  112. startPosition = {x = 1753, y = 1002, z = 7},
  113. playersNeededToStartEvent = 2,
  114. max = 10,
  115. przeszkoda = {3330, 3332, 3331, 3333, 7575, 7576, 7577, 7578, 7579, 7580, 7581, 3587, 3589, 3591, 3592, 3594, 3596},
  116. rewardsId = {2160, 2148, 2000, 2195},
  117. crystal_counts = 50,
  118. speed = 1000,
  119. waters = {4608, 4609, 4610, 4611, 4612, 4613, 7236, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825},
  120. i = {
  121. id = {
  122. present = 9074,
  123. backpack = 1988,
  124. bomb = 5468,
  125. ambush = 7496,
  126. aid_kit = 6105
  127. },
  128. amount = {
  129. bomb = 3,
  130. ambush = 2,
  131. aid_kit = 1
  132. },
  133. timer = {
  134. present = 20,
  135. dragons = 1,
  136. startEvent = 60,
  137. blockitems = 30,
  138. check = 20,
  139. kickout = 60
  140. },
  141. presents = {
  142. {x = 1731, y = 1015, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
  143. {x = 1725, y = 1004, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
  144. {x = 1721, y = 1000, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
  145. {x = 1741, y = 990, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
  146. {x = 1726, y = 979, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
  147. {x = 1718, y = 973, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
  148. {x = 1754, y = 973, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
  149. {x = 1738, y = 963, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
  150. {x = 1727, y = 943, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
  151. {x = 1751, y = 938, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
  152. {x = 1767, y = 954, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
  153. {x = 1768, y = 988, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
  154. {x = 1782, y = 988, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE},
  155. {x = 1776, y = 1017, z = 7, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE}
  156. },
  157. dragons = {
  158. x = {
  159. {1725, 1728},
  160. {1749, 1752},
  161. {1766, 1769},
  162. {1737, 1740},
  163. {1753, 1756},
  164. {1716, 1719},
  165. {1724, 1727},
  166. {1766, 1769},
  167. {1781, 1784},
  168. {1740, 1743},
  169. {1719, 1722},
  170. {1723, 1726},
  171. {1730, 1733},
  172. {1774, 1777}
  173. },
  174. y = {
  175. {941, 944},
  176. {936, 939},
  177. {952, 955},
  178. {961, 964},
  179. {971, 974},
  180. {972, 975},
  181. {978, 981},
  182. {986, 989},
  183. {987, 990},
  184. {989, 992},
  185. {999, 1002},
  186. {1003, 1006},
  187. {1014, 1017},
  188. {1011, 1014}
  189. },
  190. },
  191. }
  192. }
  193. ]]></config>
  194. <movevent type="StepIn" actionid="9049" event="script"><![CDATA[
  195. domodlib('q')
  196. function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
  197. if getPlayerStorageValue(cid, q.zapisany) == 1 then
  198. if getPlayerStorageValue(cid, q.gotowy_e) == 1 then
  199. doMoveCreature(cid, WEST)
  200. elseif getPlayerStorageValue(cid, q.gotowy_w) == 1 then
  201. doMoveCreature(cid, EAST)
  202. return true
  203. end
  204. return true
  205. end
  206. return true
  207. end
  208. ]]></movevent>
  209. <movevent type="StepIn" actionid="9050" event="script"><![CDATA[
  210. domodlib('q')
  211. function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
  212. if getPlayerStorageValue(cid, q.zapisany) == 1 then
  213. if getPlayerStorageValue(cid, q.zakonczone) == 1 then
  214. if isPlayer(getTopCreature({x = getCreaturePosition(cid).x + 1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}).uid) == false then
  215. if getPlayerSlotItem(cid, CONST_SLOT_HEAD).itemid ~= 0 then
  216. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from helmet place.")
  217. doTeleportThing(cid, fromPosition)
  218. elseif getPlayerSlotItem(cid, CONST_SLOT_NECKLACE).itemid ~= 0 then
  219. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from neclace place.")
  220. doTeleportThing(cid, fromPosition)
  221. elseif getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid ~= 0 then
  222. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from backpack place.")
  223. doTeleportThing(cid, fromPosition)
  224. elseif getPlayerSlotItem(cid, CONST_SLOT_ARMOR).itemid ~= 0 then
  225. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from armor place.")
  226. doTeleportThing(cid, fromPosition)
  227. elseif getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid ~= 0 then
  228. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from left hand.")
  229. doTeleportThing(cid, fromPosition)
  230. elseif getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid ~= 0 then
  231. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from right hand.")
  232. doTeleportThing(cid, fromPosition)
  233. elseif getPlayerSlotItem(cid, CONST_SLOT_LEGS).itemid ~= 0 then
  234. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from legs place.")
  235. doTeleportThing(cid, fromPosition)
  236. elseif getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid ~= 0 then
  237. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from feet place.")
  238. doTeleportThing(cid, fromPosition)
  239. elseif getPlayerSlotItem(cid, CONST_SLOT_RING).itemid ~= 0 then
  240. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from ring place.")
  241. doTeleportThing(cid, fromPosition)
  242. elseif getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid ~= 0 then
  243. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from ammo place.")
  244. doTeleportThing(cid, fromPosition)
  245. else
  246. doCleanTile({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
  247. doCleanTile({x = getCreaturePosition(cid).x + 1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
  248. doCleanTile({x = getCreaturePosition(cid).x + 2, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
  249. doCleanTile({x = getCreaturePosition(cid).x + 3, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
  250. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_WATERSPLASH)
  251. doMoveCreature(cid, EAST)
  252. doCreatureSetNoMove(cid, true)
  253. setPlayerStorageValue(cid, q.gotowy_e, 1)
  254. setPlayerStorageValue(cid, q.gotowy, 1)
  255. setGlobalStorageValue(q.gotowy, getGlobalStorageValue(q.gotowy)+1)
  256. doPlayerSendTextMessage(cid, 4, "Congratulations, you are ready to take part in Battle Boats.")
  257. doPlayerPopupFYI(cid, "[Battle Boats]\n- Your task is to avoid obstacles, dangerous dragons, killing peoples and marine surprises survive.\n\nCommands to use ship:\n!swim go - ship start swim,\n!swim stop - ship stop swim,\n!swim up - direction set to north,\n!swim down - direction set to south,\n!swim left - direction set to west,\n!swim right - direction set to east,\n!swim fast - your boat will swim faster,\n!swim slow - your boat will swim slower.") return true
  258. end
  259. else
  260. doPlayerSendTextMessage(cid, 4, "This boat is occupied by someone else.")
  261. doTeleportThing(cid, fromPosition)
  262. return true
  263. end
  264. else
  265. doPlayerSendTextMessage(cid, 4, "Prepare to send your full equipment to your deposit. After registration you will can boat ride.")
  266. doTeleportThing(cid, fromPosition)
  267. return true
  268. end
  269. else
  270. doPlayerSendTextMessage(cid, 4, "You didn't sign up for the competition, you are not allowed to move on!")
  271. doTeleportThing(cid, fromPosition)
  272. return true
  273. end
  274. end
  275. ]]></movevent>
  276. <movevent type="StepIn" actionid="9051" event="script"><![CDATA[
  277. domodlib('q')
  278. function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
  279. if getPlayerStorageValue(cid, q.zapisany) == 1 then
  280. if getPlayerStorageValue(cid, q.zakonczone) == 1 then
  281. if isPlayer(getTopCreature({x = getCreaturePosition(cid).x - 1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}).uid) == false then
  282. if getPlayerSlotItem(cid, CONST_SLOT_HEAD).itemid ~= 0 then
  283. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from helmet place.")
  284. doTeleportThing(cid, fromPosition)
  285. elseif getPlayerSlotItem(cid, CONST_SLOT_NECKLACE).itemid ~= 0 then
  286. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from neclace place.")
  287. doTeleportThing(cid, fromPosition)
  288. elseif getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid ~= 0 then
  289. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from backpack place.")
  290. doTeleportThing(cid, fromPosition)
  291. elseif getPlayerSlotItem(cid, CONST_SLOT_ARMOR).itemid ~= 0 then
  292. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from armor place.")
  293. doTeleportThing(cid, fromPosition)
  294. elseif getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid ~= 0 then
  295. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from left hand.")
  296. doTeleportThing(cid, fromPosition)
  297. elseif getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid ~= 0 then
  298. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from right hand.")
  299. doTeleportThing(cid, fromPosition)
  300. elseif getPlayerSlotItem(cid, CONST_SLOT_LEGS).itemid ~= 0 then
  301. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from legs place.")
  302. doTeleportThing(cid, fromPosition)
  303. elseif getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid ~= 0 then
  304. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from feet place.")
  305. doTeleportThing(cid, fromPosition)
  306. elseif getPlayerSlotItem(cid, CONST_SLOT_RING).itemid ~= 0 then
  307. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from ring place.")
  308. doTeleportThing(cid, fromPosition)
  309. elseif getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid ~= 0 then
  310. doPlayerSendTextMessage(cid, 4, "You can not have any object participating in the event, you must also remove the object from ammo place.")
  311. doTeleportThing(cid, fromPosition)
  312. else
  313. doCleanTile({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
  314. doCleanTile({x = getCreaturePosition(cid).x - 1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
  315. doCleanTile({x = getCreaturePosition(cid).x - 2, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
  316. doCleanTile({x = getCreaturePosition(cid).x - 3, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, false)
  317. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_WATERSPLASH)
  318. doPlayerSendTextMessage(cid, 4, "Congratulations, you are ready to take part in Battle Boats.")
  319. doMoveCreature(cid, WEST)
  320. doCreatureSetNoMove(cid, true)
  321. setPlayerStorageValue(cid, q.gotowy_w, 1)
  322. setPlayerStorageValue(cid, q.gotowy, 1)
  323. setGlobalStorageValue(q.gotowy, getGlobalStorageValue(q.gotowy)+1)
  324. doPlayerPopupFYI(cid, "[Battle Boats]\n- Your task is to avoid obstacles, dangerous dragons, killing peoples and marine surprises survive.\n\nCommands to use ship:\n!swim go - ship start swim,\n!swim stop - ship stop swim,\n!swim up - direction set to north,\n!swim down - direction set to south,\n!swim left - direction set to west,\n!swim right - direction set to east,\n!swim fast - your boat will swim faster,\n!swim slow - your boat will swim slower.")
  325. return true
  326. end
  327. else
  328. doPlayerSendTextMessage(cid, 4, "This boat is occupied by someone else.")
  329. doTeleportThing(cid, fromPosition)
  330. return true
  331. end
  332. else
  333. doPlayerSendTextMessage(cid, 4, "Prepare to send your full equipment to your deposit. After registration you will can boat ride.")
  334. doTeleportThing(cid, fromPosition)
  335. return true
  336. end
  337. else
  338. doPlayerSendTextMessage(cid, 4, "You didn't sign up for the competition, you are not allowed to move on!")
  339. doTeleportThing(cid, fromPosition)
  340. return true
  341. end
  342. end
  343. ]]></movevent>
  344. <action itemid="7496" event="script" allowfaruse="1"><![CDATA[
  345. domodlib('q')
  346. function onUse(cid, item, fromPosition, itemEx, toPosition)
  347. local exhaust = {
  348. storage = 7971,
  349. duration = 2
  350. }
  351. local l = {
  352. [NORTH] = {3587,3589,3591},
  353. [SOUTH] = {3591,3589,3587},
  354. [WEST] = {3592,3594,3596},
  355. [EAST] = {3596,3594,3592}
  356. }
  357. if(not isInArray(q.waters, itemEx.itemid)) then
  358. doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
  359. return true
  360. end
  361. if(getPlayerStorageValue(cid, q.start) ~= 1) then
  362. doPlayerSendCancel(cid, "You cannot use this object.")
  363. return true
  364. end
  365. if(os.time() - getPlayerStorageValue(cid, exhaust.storage)) < exhaust.duration then
  366. doPlayerSendCancel(cid, "You are exhausted.")
  367. return true
  368. end
  369. if getGlobalStorageValue(q.blockbomb) == -1 then
  370. doPlayerSendCancel(cid, "You cannot use this object.")
  371. elseif getGlobalStorageValue(q.blockbomb) >= 1 then
  372. doPlayerSendCancel(cid, "You cannot use that object for another " .. getGlobalStorageValue(q.blockbomb) .. " seconds.")
  373. return true
  374. end
  375. if getGlobalStorageValue(q.blockbomb) == 0 then
  376. exhaustion.set(cid, exhaust.storage, exhaust.duration)
  377. zacznijCzekac(function()
  378. doRemoveItem(item.uid, 1)
  379. doSendDistanceShoot({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, toPosition, 35)
  380. doSendAnimatedText(toPosition, "3", TEXTCOLOR_LIGHTBLUE)
  381. doSendMagicEffect(toPosition, CONST_ME_WATERSPLASH)
  382. czekaj(1000)
  383. doSendAnimatedText(toPosition, "2", TEXTCOLOR_LIGHTBLUE)
  384. doSendMagicEffect(toPosition, CONST_ME_WATERSPLASH)
  385. czekaj(1000)
  386. doSendAnimatedText(toPosition, "1", TEXTCOLOR_LIGHTBLUE)
  387. doSendMagicEffect(toPosition, CONST_ME_WATERSPLASH)
  388. czekaj(1000)
  389. local szansa = math.random(1, 50)
  390. local odglos = {"GRRROAR!", "Zchhhhhh!", "Grooaaaaar", "Aaa... CHOO!", "You... will be.... eaten!!"}
  391. local losowy = math.random(1, table.maxn(odglos))
  392. doCreatureSay(cid, odglos[losowy], TALKTYPE_MONSTER, false, 0, toPosition)
  393. doSendMagicEffect(toPosition, CONST_ME_WATERCREATURE)
  394. local list = getSpectators(toPosition, 1, 1, false) or {}
  395. if #list > 0 then
  396. for _, creature in pairs(list) do
  397. if isPlayer(creature) and getPlayerStorageValue(creature, q.zapisany) == 1 and (getPlayerStorageValue(creature, q.gotowy_e) == 1 or getPlayerStorageValue(creature, q.gotowy_w) == 1) then
  398. if(szansa < 26) then
  399. setGlobalStorageValue(q.playersCount, getGlobalStorageValue(q.playersCount)-1)
  400. doSendMagicEffect(getCreaturePosition(creature), 53)
  401. doCreatureAddHealth(creature, (-getCreatureMaxHealth(creature))+1)
  402. addEvent(function()
  403. doCreatureAddHealth(creature, getCreatureMaxHealth(creature))
  404. stopEvent(plyn)
  405. if getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
  406. for n = 1, 3 do
  407. local i = n - 2
  408. doRemoveItem(getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y+i, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  409. end
  410. elseif getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
  411. for n = 1, 3 do
  412. local i = n - 2
  413. doRemoveItem(getThingFromPos({x = getCreaturePosition(creature).x+i, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  414. end
  415. elseif getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
  416. for n = 1, 3 do
  417. local i = n - 2
  418. doRemoveItem(getThingFromPos({x = getCreaturePosition(creature).x-i, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  419. end
  420. elseif getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
  421. for n = 1, 3 do
  422. local i = n - 2
  423. doRemoveItem(getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y-i, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  424. end
  425. end
  426. doTeleportThing(creature, getTownTemplePosition(getPlayerTown(creature)), false)
  427. doSendMagicEffect(getPlayerPosition(creature), CONST_ME_TELEPORT)
  428. if getPlayerSlotItem(creature, CONST_SLOT_BACKPACK).itemid ~= 0 then
  429. doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_BACKPACK).itemid, 1)
  430. end
  431. if getPlayerSlotItem(creature, CONST_SLOT_LEFT).itemid ~= 0 then
  432. doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_LEFT).itemid, 1)
  433. end
  434. if getPlayerSlotItem(creature, CONST_SLOT_RIGHT).itemid ~= 0 then
  435. doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_RIGHT).itemid, 1)
  436. end
  437. if getPlayerSlotItem(creature, CONST_SLOT_AMMO).itemid ~= 0 then
  438. doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_AMMO).itemid, 1)
  439. end
  440. doPlayerRemoveAllStoragesFromBattleBoats(creature)
  441. doPlayerSendTextMessage(creature, 4, "Thanks for using Battle Boats. This time you didn't successfully complete the voyage.")
  442. doBroadcastMessage("".. getCreatureName(creature) .." has been eaten by Water Dragon, he end his voyage.", 22)
  443. end, 1000)
  444. elseif(szansa >= 25) then
  445. doSendMagicEffect(getCreaturePosition(creature), 53)
  446. doPlayerSendTextMessage(creature, 4, "It's unbelievable, you have managed to survive the start of the sea monster!")
  447. end
  448. elseif isMonster(creature) then
  449. doRemoveCreature(creature)
  450. end
  451. end
  452. end
  453. end)
  454. end
  455. return true
  456. end
  457. ]]></action>
  458. <action itemid="5468" event="script" allowfaruse="1"><![CDATA[
  459. domodlib('q')
  460. function onUse(cid, item, fromPosition, itemEx, toPosition)
  461. local exhaust = {
  462. storage = 7972,
  463. duration = 2
  464. }
  465. local uderzenie = {1, 2, 3}
  466. local random = math.random(1, table.maxn(uderzenie))
  467. local pozycja1 = {x = toPosition.x, y = toPosition.y-1, z = toPosition.z}
  468. local pozycja2 = {x = toPosition.x, y = toPosition.y+1, z = toPosition.z}
  469. local pozycja3 = {x = toPosition.x-1, y = toPosition.y, z = toPosition.z}
  470. local pozycja4 = {x = toPosition.x+1, y = toPosition.y, z = toPosition.z}
  471.  
  472. if(not isInArray(q.waters, itemEx.itemid)) then
  473. doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
  474. return true
  475. end
  476. if(getPlayerStorageValue(cid, q.start) ~= 1) then
  477. doPlayerSendCancel(cid, "You cannot use this object.")
  478. return true
  479. end
  480. if(os.time() - getPlayerStorageValue(cid, exhaust.storage)) < exhaust.duration then
  481. doPlayerSendCancel(cid, "You are exhausted.")
  482. return true
  483. end
  484. if getGlobalStorageValue(q.blockbomb) == -1 then
  485. doPlayerSendCancel(cid, "You cannot use this object.")
  486. elseif getGlobalStorageValue(q.blockbomb) >= 1 then
  487. doPlayerSendCancel(cid, "You cannot use that object for another " .. getGlobalStorageValue(q.blockbomb) .. " seconds.")
  488. return true
  489. end
  490. if getGlobalStorageValue(q.blockbomb) == 0 then
  491. exhaustion.set(cid, exhaust.storage, exhaust.duration)
  492. doSendDistanceShoot({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, toPosition, CONST_ANI_FIRE)
  493. if(isPlayer(getTopCreature(toPosition).uid) or isPlayer(getTopCreature(pozycja1).uid) or isPlayer(getTopCreature(pozycja2).uid) or isPlayer(getTopCreature(pozycja4).uid) or isPlayer(getTopCreature(pozycja3).uid) and uderzenie[random] == 1) then
  494. doSendMagicEffect(toPosition, CONST_ME_EXPLOSIONHIT)
  495. doSendMagicEffect(pozycja1, CONST_ME_EXPLOSIONHIT)
  496. doSendMagicEffect(pozycja2, CONST_ME_EXPLOSIONHIT)
  497. doSendMagicEffect(pozycja4, CONST_ME_EXPLOSIONHIT)
  498. doSendMagicEffect(pozycja3, CONST_ME_EXPLOSIONHIT)
  499. doCreatureSay(cid, "BOOM!", TALKTYPE_ORANGE_2, false, nil, toPosition)
  500. if isPlayer(getTopCreature(toPosition).uid) then
  501. local obrazenia1a = (getCreatureMaxHealth(getTopCreature(toPosition).uid)/5)
  502. doCreatureAddHealth(getTopCreature(toPosition).uid, (-getCreatureMaxHealth(getTopCreature(toPosition).uid)/5))
  503. doPlayerSendCancel(cid, "You hit into opponent and you deal him only " .. obrazenia1a .. " damage.")
  504. elseif isPlayer(getTopCreature(pozycja1).uid) then
  505. local obrazenia1b = (getCreatureMaxHealth(getTopCreature(pozycja1).uid)/5)
  506. doCreatureAddHealth(getTopCreature(pozycja1).uid, (-getCreatureMaxHealth(getTopCreature(pozycja1).uid)/5))
  507. doPlayerSendCancel(cid, "You hit into opponent and you deal him only " .. obrazenia1b .. " damage.")
  508. elseif isPlayer(getTopCreature(pozycja2).uid) then
  509. local obrazenia1c = (getCreatureMaxHealth(getTopCreature(pozycja2).uid)/5)
  510. doCreatureAddHealth(getTopCreature(pozycja2).uid, (-getCreatureMaxHealth(getTopCreature(pozycja2).uid)/5))
  511. doPlayerSendCancel(cid, "You hit into opponent and you deal him only " .. obrazenia1c .. " damage.")
  512. elseif isPlayer(getTopCreature(pozycja4).uid) then
  513. local obrazenia1d = (getCreatureMaxHealth(getTopCreature(pozycja4).uid)/5)
  514. doCreatureAddHealth(getTopCreature(pozycja4).uid, (-getCreatureMaxHealth(getTopCreature(pozycja4).uid)/5))
  515. doPlayerSendCancel(cid, "You hit into opponent and you deal him only " .. obrazenia1d .. " damage.")
  516. elseif isPlayer(getTopCreature(pozycja3).uid) then
  517. local obrazenia1e = (getCreatureMaxHealth(getTopCreature(pozycja3).uid)/5)
  518. doCreatureAddHealth(getTopCreature(pozycja3).uid, (-getCreatureMaxHealth(getTopCreature(pozycja3).uid)/5))
  519. doPlayerSendCancel(cid, "You hit into opponent and you deal him only " .. obrazenia1e .. " damage.")
  520. end
  521. doRemoveItem(item.uid, 1)
  522. elseif(isPlayer(getTopCreature(toPosition).uid) or isPlayer(getTopCreature(pozycja1).uid) or isPlayer(getTopCreature(pozycja2).uid) or isPlayer(getTopCreature(pozycja4).uid) or isPlayer(getTopCreature(pozycja3).uid) and uderzenie[random] == 2) then
  523. doSendMagicEffect(toPosition, CONST_ME_HITBYFIRE)
  524. doSendMagicEffect(pozycja1, CONST_ME_HITBYFIRE)
  525. doSendMagicEffect(pozycja2, CONST_ME_HITBYFIRE)
  526. doSendMagicEffect(pozycja4, CONST_ME_HITBYFIRE)
  527. doSendMagicEffect(pozycja3, CONST_ME_HITBYFIRE)
  528. doCreatureSay(cid, "BOOM!", TALKTYPE_ORANGE_2, false, nil, toPosition)
  529. if isPlayer(getTopCreature(toPosition).uid) then
  530. local obrazenia2a = (getCreatureMaxHealth(getTopCreature(toPosition).uid)/4)
  531. doCreatureAddHealth(getTopCreature(toPosition).uid, (-getCreatureMaxHealth(getTopCreature(toPosition).uid)/4))
  532. doPlayerSendCancel(cid, "You hit into opponent and you deal him " .. obrazenia2a .. " damage.")
  533. elseif isPlayer(getTopCreature(pozycja1).uid) then
  534. local obrazenia2c = (getCreatureMaxHealth(getTopCreature(pozycja1).uid)/4)
  535. doCreatureAddHealth(getTopCreature(pozycja1).uid, (-getCreatureMaxHealth(getTopCreature(pozycja1).uid)/4))
  536. doPlayerSendCancel(cid, "You hit into opponent and you deal him " .. obrazenia2b .. " damage.")
  537. elseif isPlayer(getTopCreature(pozycja2).uid) then
  538. local obrazenia2b = (getCreatureMaxHealth(getTopCreature(pozycja2).uid)/4)
  539. doCreatureAddHealth(getTopCreature(pozycja2).uid, (-getCreatureMaxHealth(getTopCreature(pozycja2).uid)/4))
  540. doPlayerSendCancel(cid, "You hit into opponent and you deal him " .. obrazenia2c .. " damage.")
  541. elseif isPlayer(getTopCreature(pozycja4).uid) then
  542. local obrazenia2d = (getCreatureMaxHealth(getTopCreature(pozycja4).uid)/4)
  543. doCreatureAddHealth(getTopCreature(pozycja4).uid, (-getCreatureMaxHealth(getTopCreature(pozycja4).uid)/4))
  544. doPlayerSendCancel(cid, "You hit into opponent and you deal him " .. obrazenia2d .. " damage.")
  545. elseif isPlayer(getTopCreature(pozycja3).uid) then
  546. local obrazenia2e = (getCreatureMaxHealth(getTopCreature(pozycja3).uid)/4)
  547. doCreatureAddHealth(getTopCreature(pozycja3).uid, (-getCreatureMaxHealth(getTopCreature(pozycja3).uid)/4))
  548. doPlayerSendCancel(cid, "You hit into opponent and you deal him " .. obrazenia2e .. " damage.")
  549. end
  550. doRemoveItem(item.uid, 1)
  551. elseif(isPlayer(getTopCreature(toPosition).uid) or isPlayer(getTopCreature(pozycja1).uid) or isPlayer(getTopCreature(pozycja2).uid) or isPlayer(getTopCreature(pozycja4).uid) or isPlayer(getTopCreature(pozycja3).uid) and uderzenie[random] == 3) then
  552. doSendMagicEffect(toPosition, CONST_ME_FIREAREA)
  553. doSendMagicEffect(pozycja1, CONST_ME_FIREAREA)
  554. doSendMagicEffect(pozycja2, CONST_ME_FIREAREA)
  555. doSendMagicEffect(pozycja4, CONST_ME_FIREAREA)
  556. doSendMagicEffect(pozycja3, CONST_ME_FIREAREA)
  557. doCreatureSay(cid, "BOOM!", TALKTYPE_ORANGE_2, false, nil, toPosition)
  558. if isPlayer(getTopCreature(toPosition).uid) then
  559. local obrazenia3a = (getCreatureMaxHealth(getTopCreature(toPosition).uid)/3)
  560. doCreatureAddHealth(getTopCreature(toPosition).uid, (-getCreatureMaxHealth(getTopCreature(toPosition).uid)/3))
  561. doPlayerSendCancel(cid, "You hit into opponent and you deal him up to " .. obrazenia3a .. " damage!")
  562. elseif isPlayer(getTopCreature(pozycja1).uid) then
  563. local obrazenia3b = (getCreatureMaxHealth(getTopCreature(pozycja1).uid)/3)
  564. doCreatureAddHealth(getTopCreature(pozycja1).uid, (-getCreatureMaxHealth(getTopCreature(pozycja1).uid)/3))
  565. doPlayerSendCancel(cid, "You hit into opponent and you deal him up to " .. obrazenia3b .. " damage!")
  566. elseif isPlayer(getTopCreature(pozycja2).uid) then
  567. local obrazenia3c = (getCreatureMaxHealth(getTopCreature(pozycja2).uid)/3)
  568. doCreatureAddHealth(getTopCreature(pozycja2).uid, (-getCreatureMaxHealth(getTopCreature(pozycja2).uid)/3))
  569. doPlayerSendCancel(cid, "You hit into opponent and you deal him up to " .. obrazenia3c .. " damage!")
  570. elseif isPlayer(getTopCreature(pozycja4).uid) then
  571. local obrazenia3d = (getCreatureMaxHealth(getTopCreature(pozycja4).uid)/3)
  572. doCreatureAddHealth(getTopCreature(pozycja4).uid, (-getCreatureMaxHealth(getTopCreature(pozycja4).uid)/3))
  573. doPlayerSendCancel(cid, "You hit into opponent and you deal him up to " .. obrazenia3d .. " damage!")
  574. elseif isPlayer(getTopCreature(pozycja3).uid) then
  575. local obrazenia3e = (getCreatureMaxHealth(getTopCreature(pozycja3).uid)/3)
  576. doCreatureAddHealth(getTopCreature(pozycja3).uid, (-getCreatureMaxHealth(getTopCreature(pozycja3).uid)/3))
  577. doPlayerSendCancel(cid, "You hit into opponent and you deal him up to " .. obrazenia3e .. " damage!")
  578. end
  579. doRemoveItem(item.uid, 1)
  580. else
  581. doPlayerSendCancel(cid, "Your bomb has been destroyed in water cause you failed with locate purpose.")
  582. doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY)
  583. doSendMagicEffect(pozycja1, CONST_ME_LOSEENERGY)
  584. doSendMagicEffect(pozycja2, CONST_ME_LOSEENERGY)
  585. doSendMagicEffect(pozycja4, CONST_ME_LOSEENERGY)
  586. doSendMagicEffect(pozycja3, CONST_ME_LOSEENERGY)
  587. local gdzie = {x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 255}
  588. doCreateItem(7109, 1, gdzie)
  589. doRemoveItem(item.uid, 1)
  590. addEvent(function()
  591. doRemoveItem(getTileItemById(gdzie, 7109).uid, 1)
  592. end, 2500)
  593. return true
  594. end
  595. end
  596. return true
  597. end
  598. ]]></action>
  599. <action itemid="9074" event="script"><![CDATA[
  600. domodlib('q')
  601. function onUse(cid, item, fromPosition, itemEx, toPosition)
  602. local items = {q.i.id[3], q.i.id[4], q.i.id[5], 0}
  603. local amount = {1, 2}
  604. local random_item = items[math.random(1, #items)]
  605. local item_name = getItemNameById(random_item)
  606. local random_amount = amount[math.random(1, #amount)]
  607. if(random_item == 0) then
  608. doCreatureAddHealth(cid, -(math.random(20,100)))
  609. doSendMagicEffect(pozycja1, CONST_ME_EXPLOSIONHIT)
  610. doPlayerSendTextMessage(cid, 4, "It was a trap! Present box gave you fire!")
  611. else
  612. doPlayerAddItem(cid, random_item, random_amount)
  613. doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
  614. doPlayerSendTextMessage(cid, 4, "Present box gave you ".. random_amount .."x of ".. item_name ..".")
  615. end
  616. return true
  617. end
  618. ]]></action>
  619. <action itemid="6105" event="script"><![CDATA[
  620. domodlib('q')
  621. function onUse(cid, item, fromPosition, itemEx, toPosition)
  622. local exhaust = {
  623. storage = 7973,
  624. duration = 2
  625. }
  626. if(getPlayerStorageValue(cid, q.start) ~= 1) then
  627. doPlayerSendCancel(cid, "You cannot use this object.")
  628. return true
  629. end
  630. if getGlobalStorageValue(q.blockbomb) == -1 then
  631. doPlayerSendCancel(cid, "You cannot use this object.")
  632. elseif getGlobalStorageValue(q.blockbomb) >= 1 then
  633. doPlayerSendCancel(cid, "You cannot use that object for another " .. getGlobalStorageValue(q.blockbomb) .. " seconds.")
  634. return true
  635. end
  636. if getGlobalStorageValue(q.blockbomb) == 0 then
  637. if(getPlayerStorageValue(cid, q.start) == 1) then
  638. if(os.time() - getPlayerStorageValue(cid, exhaust.storage)) >= exhaust.duration then
  639. exhaustion.set(cid, exhaust.storage, exhaust.duration)
  640. if getCreatureHealth(cid) == getCreatureMaxHealth(cid) and getPlayerStorageValue(cid, q.palenie) == -1 then
  641. doPlayerSendCancel(cid, "You don't need first aid kits.")
  642. elseif getCreatureHealth(cid) ~= getCreatureMaxHealth(cid) and getPlayerStorageValue(cid, q.palenie) == -1 then
  643. doCreatureAddHealth(cid, (getCreatureMaxHealth(cid)/2))
  644. doPlayerSendCancel(cid, "You have healed your character, +50% of the maximum life.")
  645. doRemoveItem(item.uid, 1)
  646. elseif getCreatureHealth(cid) == getCreatureMaxHealth(cid) and getPlayerStorageValue(cid, q.palenie) > -1 then
  647. setPlayerStorageValue(cid, q.palenie, -1)
  648. doPlayerSendCancel(cid, "Your boat has been repaired, now is fully operational.")
  649. doRemoveItem(item.uid, 1)
  650. elseif getCreatureHealth(cid) ~= getCreatureMaxHealth(cid) and getPlayerStorageValue(cid, q.palenie) > -1 then
  651. setPlayerStorageValue(cid, q.palenie, tonumber(getPlayerStorageValue(cid, q.palenie))-1)
  652. doCreatureAddHealth(cid, (getCreatureMaxHealth(cid)/3))
  653. doPlayerSendCancel(cid, "You have healed your character, +33% of the maximum life and your boat has been repaired, now is almost fully operational.")
  654. doRemoveItem(item.uid, 1)
  655. return true
  656. end
  657. else
  658. doPlayerSendCancel(cid, "You are exhausted.")
  659. return true
  660. end
  661. else
  662. doPlayerSendCancel(cid, "You cannot use this object.")
  663. return true
  664. end
  665. end
  666. return true
  667. end
  668. ]]></action>
  669. <globalevent name="BattleBoatsStart" interval="3000" event="script"><![CDATA[
  670. domodlib('q')
  671. function onThink(interval, lastExecution, thinkInterval)
  672. if getGlobalStorageValue(q.start) == 1 then
  673. for _, pid in ipairs(getPlayersOnline()) do
  674. if getPlayerStorageValue(pid, q.gotowy) == 1 then
  675. doSendAnimatedText(getCreaturePosition(pid), "I'M READY", TEXTCOLOR_LIGHTBLUE)
  676. end
  677. end
  678. return true
  679. end
  680. return true
  681. end
  682. ]]></globalevent>
  683. <talkaction words="!boat" event="script"><![CDATA[
  684. domodlib('q')
  685. function onSay(cid, words, param, channel)
  686. if getGlobalStorageValue(q.start) == 1 and getGlobalStorageValue(q.zakonczone) ~= 1 then
  687. if getPlayerStorageValue(cid, q.zapisany) == -1 then
  688. if getTilePzInfo(getPlayerPosition(cid)) == true then
  689. if getGlobalStorageValue(q.playersCount) < q.max then
  690. setGlobalStorageValue(q.playersCount, getGlobalStorageValue(q.playersCount)+1)
  691. if getGlobalStorageValue(q.playersCount) == q.max then
  692. doPlayerSendCancel(cid, "Amount of participants is full.")
  693. else
  694. doBroadcastMessage("" .. getPlayerName(cid) .. " has been joined to Battle Boats! Actually we have: " .. getGlobalStorageValue(q.playersCount) .. " players!", 19)
  695. end
  696. setPlayerStorageValue(cid, q.zapisany, 1)
  697. doTeleportThing(cid, q.startPosition)
  698. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
  699. else
  700. doPlayerSendCancel(cid, "Battle Boats is full.")
  701. return true
  702. end
  703. else
  704. doPlayerSendCancel(cid, "You must be in protection zone to participate in the event.")
  705. return true
  706. end
  707. else
  708. doPlayerSendCancel(cid, "You are already registered in this event.")
  709. return true
  710. end
  711. else
  712. doPlayerSendCancel(cid, "At the moment there are no records for this event.")
  713. return true
  714. end
  715. return true
  716. end
  717. ]]></talkaction>
  718. <talkaction words="!start_boat" event="script"><![CDATA[
  719. domodlib('q')
  720. function checkAgain()
  721. if getGlobalStorageValue(q.playersCount) < q.playersNeededToStartEvent and getGlobalStorageValue(q.wystartowal) == -1 then
  722. doBroadcastMessage("[Battle Boats]\nEvent won't start bacause too few people were willing to participate!")
  723. doRemoveAllGlobStoragesFromBattleBoats()
  724. for _, pid in ipairs(getPlayersOnline()) do
  725. if(getPlayerStorageValue(pid, q.zapisany) == 1) then
  726. if getPlayerStorageValue(pid, q.playerCount) > 0 then
  727. doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), false)
  728. doSendMagicEffect(getPlayerPosition(pid), CONST_ME_TELEPORT)
  729. doPlayerRemoveAllStoragesFromBattleBoats(pid)
  730. end
  731. end
  732. end
  733. end
  734. return true
  735. end
  736. function startEventBoats(cid)
  737. if getGlobalStorageValue(q.playersCount) >= q.playersNeededToStartEvent and getGlobalStorageValue(q.wystartowal) == -1 then
  738. addEvent(check, q.i.timer.check * 1000, cid)
  739. doBroadcastMessage("[Battle Boats]\nRegistration is completed! Preparations for the event!", 22)
  740. setGlobalStorageValue(q.zakonczone, 1)
  741. for _, pid in ipairs(getPlayersOnline()) do
  742. if(getPlayerStorageValue(pid, q.zapisany) == 1) then
  743. setPlayerStorageValue(pid, q.zakonczone, 1)
  744. local parcel = doPlayerAddItem(pid, 2595, 1)
  745. doAddContainerItem(parcel, 2599, 1)
  746. doPlayerSendTextMessage(pid, 4, "You have received parcel, pack your all equipment (including BP) to it and send it to your city. Then go over to one of 11 boats.")
  747. addEvent(function(pid)
  748. if isPlayer(pid) and getPlayerStorageValue(pid, q.zapisany) == 1 and getPlayerStorageValue(pid, q.gotowy_e) ~= 1 and getPlayerStorageValue(pid, q.gotowy_w) ~= 1 then
  749. doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), false)
  750. doSendMagicEffect(getPlayerPosition(pid), CONST_ME_TELEPORT)
  751. doPlayerSendTextMessage(pid, 4, "You has been kick out form the event cause waiting time has passed for you.")
  752. doPlayerRemoveAllStoragesFromBattleBoats(pid)
  753. setGlobalStorageValue(q.playersCount, getGlobalStorageValue(q.playersCount)-1)
  754. end
  755. addEvent(checkAgain, q.i.timer.kickout * 1000)
  756. end, q.i.timer.kickout * 1000, pid)
  757. end
  758. end
  759. elseif getGlobalStorageValue(q.playersCount) < q.playersNeededToStartEvent and getGlobalStorageValue(q.wystartowal) == -1 then
  760. doBroadcastMessage("[Battle Boats]\nEvent won't start bacause too few people were willing to participate!")
  761. doRemoveAllGlobStoragesFromBattleBoats()
  762. for _, pid in ipairs(getPlayersOnline()) do
  763. if getPlayerStorageValue(pid, q.playerCount) > 0 then
  764. doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), false)
  765. doSendMagicEffect(getPlayerPosition(pid), CONST_ME_TELEPORT)
  766. doPlayerRemoveAllStoragesFromBattleBoats(pid)
  767. end
  768. end
  769. end
  770. return true
  771. end
  772. function check(cid)
  773. local l = {
  774. [NORTH] = {3587,3589,3591},
  775. [SOUTH] = {3591,3589,3587},
  776. [WEST] = {3592,3594,3596},
  777. [EAST] = {3596,3594,3592}
  778. }
  779. zacznijCzekac(function()
  780. if getGlobalStorageValue(q.gotowy) < getGlobalStorageValue(q.playersCount) then
  781. for _, pid in ipairs(getPlayersOnline()) do
  782. if getPlayerStorageValue(pid, q.gotowy) == 1 then
  783. doPlayerSendTextMessage(pid, 4, "Event will start for few seconds, we are waiting for all participants (" .. getGlobalStorageValue(q.gotowy) .. "/".. getGlobalStorageValue(q.playersCount) ..").")
  784. end
  785. end
  786. addEvent(check, q.i.timer.check * 1000, cid)
  787. elseif getGlobalStorageValue(q.gotowy) >= getGlobalStorageValue(q.playersCount) then
  788. setGlobalStorageValue(q.blockbomb, 30)
  789. setGlobalStorageValue(q.wystartowal, 1)
  790. zacznijCzekac(function()
  791. for i = 1, q.i.timer.blockitems do
  792. if getGlobalStorageValue(q.blockbomb) > 0 then
  793. setGlobalStorageValue(q.blockbomb, getGlobalStorageValue(q.blockbomb)-1)
  794. elseif getGlobalStorageValue(q.blockbomb) == 0 then
  795. return true
  796. end
  797. czekaj(1000)
  798. end
  799. end)
  800. for _, pid in ipairs(getPlayersOnline()) do
  801. if getPlayerStorageValue(pid, q.zapisany) == 1 then
  802. if getPlayerStorageValue(pid, q.gotowy_e) == 1 then
  803. local poz = getCreaturePosition(pid)
  804. local bp = doPlayerAddItem(pid, q.i.id.backpack, 1)
  805. doAddContainerItem(bp, q.i.id.bomb, q.i.amount.bomb)
  806. doAddContainerItem(bp, q.i.id.ambush, q.i.amount.ambush)
  807. doAddContainerItem(bp, q.i.id.aid_kit, q.i.amount.aid_kit)
  808. doPlayerSendTextMessage(pid, 4, "Event will start for 5 seconds, system automatically takes you to the arena.")
  809. local exhaust = createConditionObject(CONDITION_EXHAUST)
  810. setConditionParam(exhaust, CONDITION_PARAM_TICKS, -1)
  811. doAddCondition(pid, exhaust)
  812. doMoveCreature(pid, EAST)
  813. doMoveCreature(pid, SOUTH)
  814. doCreatureSetLookDirection(pid, 1)
  815. setPlayerStorageValue(pid, q.gotowy, 0)
  816. czekaj(5000)
  817. for n = 1, 3 do
  818. local i = n - 2
  819. doRemoveItem(getThingFromPos({x = getCreaturePosition(pid).x-i, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  820. doCreatureSetLookDirection(pid, 1)
  821. end
  822. doTeleportThing(pid, {x = poz.x + 6, y = poz.y + 1, z = poz.z})
  823. for n = 1, 3 do
  824. local i = n - 2
  825. doCreateItem(l[EAST][n], 1, {x = getCreaturePosition(pid).x-i, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z})
  826. doCreatureSetLookDirection(pid, 1)
  827. end
  828. doCreatureSay(pid, "Good luck!", TALKTYPE_ORANGE_1)
  829. setPlayerStorageValue(pid, q.start, 1)
  830. setPlayerStorageValue(pid, q.strona, 1)
  831. doPlayerSendTextMessage(pid, 4, "Good luck! Event finally started!\n30 seconds of protection!")
  832. elseif getPlayerStorageValue(pid, q.gotowy_w) == 1 then
  833. local poz = getCreaturePosition(pid)
  834. local bp = doPlayerAddItem(pid, q.i.id.backpack, 1)
  835. doAddContainerItem(bp, q.i.id.bomb, q.i.amount.bomb)
  836. doAddContainerItem(bp, q.i.id.ambush, q.i.amount.ambush)
  837. doAddContainerItem(bp, q.i.id.aid_kit, q.i.amount.aid_kit)
  838. doPlayerSendTextMessage(pid, 4, "Event will start for 5 seconds, system automatically takes you to the arena.")
  839. local exhaust = createConditionObject(CONDITION_EXHAUST)
  840. setConditionParam(exhaust, CONDITION_PARAM_TICKS, -1)
  841. doAddCondition(pid, exhaust)
  842. doMoveCreature(pid, WEST)
  843. doMoveCreature(pid, SOUTH)
  844. doCreatureSetLookDirection(pid, 3)
  845. setPlayerStorageValue(pid, q.gotowy, 0)
  846. czekaj(5000)
  847. for n = 1, 3 do
  848. local i = n - 2
  849. doRemoveItem(getThingFromPos({x = getCreaturePosition(pid).x-i, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  850. doCreatureSetLookDirection(pid, 3)
  851. end
  852. doTeleportThing(pid, {x = poz.x - 7, y = poz.y + 1, z = poz.z})
  853. for n = 1, 3 do
  854. local i = n - 2
  855. doCreateItem(l[EAST][n], 1, {x = getCreaturePosition(pid).x-i, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z})
  856. doCreatureSetLookDirection(pid, 3)
  857. end
  858. doCreatureSay(pid, "Good luck!", TALKTYPE_ORANGE_1)
  859. setPlayerStorageValue(pid, q.start, 1)
  860. setPlayerStorageValue(pid, q.strona, 2)
  861. doPlayerSendTextMessage(pid, 4, "Good luck! Event finally started!\n30 seconds of protection!")
  862. end
  863. end
  864. end
  865. addEvent(postawPrezent, q.i.timer.present * 1000)
  866. addEvent(sprawdzIlosc, 1000)
  867. addEvent(doBroadcastMessage, 11000, "[Battle Boats]\nThe event has been started! Enjoy and have fun!", 22)
  868. return true
  869. end
  870. end)
  871. return true
  872. end
  873. function sprawdzIlosc()
  874. local l = {
  875. [NORTH] = {3587,3589,3591},
  876. [SOUTH] = {3591,3589,3587},
  877. [WEST] = {3592,3594,3596},
  878. [EAST] = {3596,3594,3592}
  879. }
  880. if getGlobalStorageValue(q.wystartowal) == 1 then
  881. if getGlobalStorageValue(q.playersCount) == 1 then
  882. addEvent(function()
  883. for _, pid in ipairs(getPlayersOnline()) do
  884. if isPlayer(pid) and getPlayerStorageValue(pid, q.zapisany) == 1 and (getPlayerStorageValue(pid, q.gotowy_e) == 1 or getPlayerStorageValue(pid, q.gotowy_w) == 1) then
  885. if getThingFromPos({x = getCreaturePosition(pid).x, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
  886. for n = 1, 3 do
  887. local i = n - 2
  888. doRemoveItem(getThingFromPos({x = getCreaturePosition(pid).x, y = getCreaturePosition(pid).y+i, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  889. end
  890. elseif getThingFromPos({x = getCreaturePosition(pid).x, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
  891. for n = 1, 3 do
  892. local i = n - 2
  893. doRemoveItem(getThingFromPos({x = getCreaturePosition(pid).x+i, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  894. end
  895. elseif getThingFromPos({x = getCreaturePosition(pid).x, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
  896. for n = 1, 3 do
  897. local i = n - 2
  898. doRemoveItem(getThingFromPos({x = getCreaturePosition(pid).x-i, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  899. end
  900. elseif getThingFromPos({x = getCreaturePosition(pid).x, y = getCreaturePosition(pid).y, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
  901. for n = 1, 3 do
  902. local i = n - 2
  903. doRemoveItem(getThingFromPos({x = getCreaturePosition(pid).x, y = getCreaturePosition(pid).y-i, z = getCreaturePosition(pid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  904. end
  905. end
  906. doPlayerRemoveAllStoragesFromBattleBoats(pid)
  907. doPlayerSendTextMessage(pid, 4, "Thanks for using Battle Boats. You have won Battle Boats.")
  908. doBroadcastMessage("Congratulations! ".. getCreatureName(pid) .." won Battle Boats!", 22)
  909. doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), false)
  910. doSendMagicEffect(getPlayerPosition(pid), CONST_ME_TELEPORT)
  911. if getPlayerSlotItem(pid, CONST_SLOT_BACKPACK).itemid ~= 0 then
  912. doPlayerRemoveItem(pid, getPlayerSlotItem(pid, CONST_SLOT_BACKPACK).itemid, 1)
  913. end
  914. if getPlayerSlotItem(pid, CONST_SLOT_LEFT).itemid ~= 0 then
  915. doPlayerRemoveItem(pid, getPlayerSlotItem(pid, CONST_SLOT_LEFT).itemid, 1)
  916. end
  917. if getPlayerSlotItem(pid, CONST_SLOT_RIGHT).itemid ~= 0 then
  918. doPlayerRemoveItem(pid, getPlayerSlotItem(pid, CONST_SLOT_RIGHT).itemid, 1)
  919. end
  920. if getPlayerSlotItem(pid, CONST_SLOT_AMMO).itemid ~= 0 then
  921. doPlayerRemoveItem(pid, getPlayerSlotItem(pid, CONST_SLOT_AMMO).itemid, 1)
  922. end
  923. doRemoveAllGlobStoragesFromBattleBoats()
  924. local random_item = q.rewardsId[math.random(1, #q.rewardsId)]
  925. local item_name = getItemNameById(random_item)
  926. if(random_item == 2160) then
  927. doPlayerAddItem(pid, random_item, q.crystal_counts)
  928. doPlayerSendTextMessage(pid, 4, "Congratulations! You won Battle Boats! Your reward is: ".. q.crystal_counts .." ".. item_name .."s!")
  929. else
  930. doPlayerAddItem(pid, random_item, 1)
  931. doPlayerSendTextMessage(pid, 4, "Congratulations! You won Battle Boats! Your reward is: ".. item_name .."!")
  932. end
  933. return true
  934. end
  935. end
  936. end, 2000)
  937. elseif getGlobalStorageValue(q.playersCount) == 0 then
  938. doBroadcastMessage("Battle Boats has been end!")
  939. doRemoveAllGlobStoragesFromBattleBoats()
  940. else
  941. addEvent(sprawdzIlosc, 1000)
  942. return true
  943. end
  944. end
  945. end
  946. function postawPrezent()
  947. local random = math.random(1, table.maxn(q.i.presents))
  948. if getGlobalStorageValue(q.playersCount) > 1 and getGlobalStorageValue(q.wystartowal) == 1 then
  949. doSendDistanceShoot({x = q.i.presents[random].x - 7, y = q.i.presents[random].y - 5, z = q.i.presents[random].z}, q.i.presents[random], 35)
  950. addEvent(function()
  951. doSendMagicEffect(q.i.presents[random], CONST_ME_WATERSPLASH)
  952. doCreateItem(q.i.id.present, 1, q.i.presents[random])
  953. end, 150)
  954. for _, pid in ipairs(getPlayersOnline()) do
  955. if getPlayerStorageValue(pid, start) == 1 then
  956. doPlayerSendTextMessage(pid, 4, "Suprise package fell from the sky on a nearby Island, watch out for dragons flying alongside a package!")
  957. end
  958. end
  959. addEvent(postawPrezent, q.i.timer.present * 1000)
  960. return true
  961. end
  962. end
  963. function onSay(cid, words, param, channel)
  964. doBroadcastMessage("We invite everyone to attend the Battle Boats! Event will start for ".. q.i.timer.startEvent/60 .." minutes! If you are willing to participate, type the command !boat", 22)
  965. setGlobalStorageValue(q.playersCount, 0)
  966. setGlobalStorageValue(q.gotowy, 0)
  967. setGlobalStorageValue(q.start, 1)
  968. addEvent(startEventBoats, q.i.timer.startEvent * 1000, cid)
  969. return true
  970. end
  971. ]]></talkaction>
  972. <talkaction words="!swim" event="script"><![CDATA[
  973. domodlib('q')
  974. local l = {
  975. [NORTH] = {3587,3589,3591},
  976. [SOUTH] = {3591,3589,3587},
  977. [WEST] = {3592,3594,3596},
  978. [EAST] = {3596,3594,3592}
  979. }
  980. function smoki()
  981. local rand = math.random(1, #q.i.dragons.x)
  982. local pos = {x = math.random(q.i.dragons.x[rand][1], q.i.dragons.x[rand][2]), y = math.random(q.i.dragons.y[rand][1], q.i.dragons.y[rand][2]), z = 7, stackpos = 253}
  983. local szansa = math.random(1, 75)
  984. doSendMagicEffect(pos, CONST_ME_WATERCREATURE)
  985. local list = getSpectators(pos, 1, 1, false) or {}
  986. if #list > 0 then
  987. for _, creature in pairs(list) do
  988. if isPlayer(creature) then
  989. if(szansa < 26) then
  990. setGlobalStorageValue(smok, 0)
  991. doSendMagicEffect(getCreaturePosition(creature), 53)
  992. doCreatureAddHealth(creature, -getCreatureMaxHealth(creature))
  993. addEvent(function()
  994. doCreatureAddHealth(creature, getCreatureMaxHealth(creature))
  995. stopEvent(plyn)
  996. if getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == l[NORTH][2] then
  997. for n = 1, 3 do
  998. local i = n - 2
  999. local kawalek = {x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y-i, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
  1000. local ppos = {x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y-i, z = getCreaturePosition(creature).z, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}
  1001. local lodz = getThingFromPos(kawalek)
  1002. doRemoveItem(lodz.uid, 1)
  1003. end
  1004. elseif getThingFromPos({x = getCreaturePosition(creature).x, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == l[EAST][2] then
  1005. for n = 1, 3 do
  1006. local i = n - 2
  1007. local kawalek = {x = getCreaturePosition(creature).x+i, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
  1008. local ppos = {x = getCreaturePosition(creature).x+i, y = getCreaturePosition(creature).y, z = getCreaturePosition(creature).z, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}
  1009. local lodz = getThingFromPos(kawalek)
  1010. doRemoveItem(lodz.uid, 1)
  1011. end
  1012. end
  1013. doTeleportThing(creature, getTownTemplePosition(getPlayerTown(creature)), false)
  1014. doSendMagicEffect(getPlayerPosition(creature), CONST_ME_TELEPORT)
  1015. if getPlayerSlotItem(creature, CONST_SLOT_BACKPACK).itemid ~= 0 then
  1016. doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_BACKPACK).itemid, 1)
  1017. end
  1018. if getPlayerSlotItem(creature, CONST_SLOT_LEFT).itemid ~= 0 then
  1019. doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_LEFT).itemid, 1)
  1020. end
  1021. if getPlayerSlotItem(creature, CONST_SLOT_RIGHT).itemid ~= 0 then
  1022. doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_RIGHT).itemid, 1)
  1023. end
  1024. if getPlayerSlotItem(creature, CONST_SLOT_AMMO).itemid ~= 0 then
  1025. doPlayerRemoveItem(creature, getPlayerSlotItem(creature, CONST_SLOT_AMMO).itemid, 1)
  1026. end
  1027. doPlayerRemoveAllStoragesFromBattleBoats(creature)
  1028. doPlayerSendTextMessage(creature, 4, "Thanks for using Battle Boats. This time you didn't successfully complete the voyage.")
  1029. doBroadcastMessage("".. getCreatureName(creature) .." has been eaten by Water Dragon, he end his voyage.", 22)
  1030. end, 1000)
  1031. elseif(szansa >= 25) then
  1032. doSendMagicEffect(getCreaturePosition(creature), 53)
  1033. doPlayerSendTextMessage(creature, 4, "It's unbelievable, you have managed to survive the start of the sea monster!")
  1034. end
  1035. elseif isMonster(creature) then
  1036. doRemoveCreature(creature)
  1037. end
  1038. end
  1039. end
  1040. addEvent(smoki, q.i.timer.dragons * 1000)
  1041. return true
  1042. end
  1043.  
  1044. function palenie(cid)
  1045. if(getPlayerStorageValue(cid, q.palenie) == -1 or getPlayerStorageValue(cid, q.palenie) == 0) then
  1046. setPlayerStorageValue(cid, q.palenie, tonumber(getPlayerStorageValue(cid, q.palenie))+1)
  1047. doPlayerSendCancel(cid, "You hit into the obstacle, your boat began to burn, you will be putting out the flames for 5 seconds.")
  1048. doCreatureAddHealth(cid, (-getCreatureMaxHealth(cid)/3))
  1049. if getPlayerStorageValue(cid, q.strona) == 3 then
  1050. doCreateItem(1487, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
  1051. doCreateItem(1489, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
  1052. doCreateItem(1488, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+1, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
  1053. elseif getPlayerStorageValue(cid, q.strona) == 4 then
  1054. doCreateItem(1487, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+1, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
  1055. doCreateItem(1489, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
  1056. doCreateItem(1488, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
  1057. elseif getPlayerStorageValue(cid, q.strona) == 1 then
  1058. doCreateItem(1487, 1, {x = getCreaturePosition(cid).x+1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
  1059. doCreateItem(1489, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
  1060. doCreateItem(1488, 1, {x = getCreaturePosition(cid).x-1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
  1061. elseif getPlayerStorageValue(cid, q.strona) == 2 then
  1062. doCreateItem(1487, 1, {x = getCreaturePosition(cid).x-1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
  1063. doCreateItem(1489, 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
  1064. doCreateItem(1488, 1, {x = getCreaturePosition(cid).x+1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_SECOND_ITEM_ABOVE_GROUNDTILE})
  1065. end
  1066. setPlayerStorageValue(cid, q.stop, 1)
  1067. addEvent(function()
  1068. doRemoveItem(getTileItemById(getCreaturePosition(cid), 1489).uid, 1)
  1069. if getPlayerStorageValue(cid, q.strona) == 3 then
  1070. doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+1, z = getCreaturePosition(cid).z}, 1488).uid, 1)
  1071. doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z}, 1487).uid, 1)
  1072. elseif getPlayerStorageValue(cid, q.strona) == 4 then
  1073. doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+1, z = getCreaturePosition(cid).z}, 1487).uid, 1)
  1074. doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z}, 1488).uid, 1)
  1075. elseif getPlayerStorageValue(cid, q.strona) == 1 then
  1076. doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x+1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, 1487).uid, 1)
  1077. doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x-1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, 1488).uid, 1)
  1078. elseif getPlayerStorageValue(cid, q.strona) == 2 then
  1079. doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x+1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, 1488).uid, 1)
  1080. doRemoveItem(getTileItemById({x = getCreaturePosition(cid).x-1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, 1487).uid, 1)
  1081. end
  1082. setPlayerStorageValue(cid, q.stop, 0)
  1083. end, 5000)
  1084. elseif(getPlayerStorageValue(cid, q.palenie) == 1) then
  1085. doPlayerSendCancel(cid, "You hit into the obstacle, your boat will not survive the collision. You have finished yours voyage.")
  1086. doCreatureAddHealth(cid, (-getCreatureMaxHealth(cid)/3)+1)
  1087. for i = 1, 3 do
  1088. local kierunki = {EAST, WEST, NORTH, SOUTH}
  1089. local kier = getPlayerStorageValue(cid, q.strona)
  1090. local kierunek = kier > 0 and kierunki[kier]
  1091. if not isInArray({1, 2, 3, 4}, kier) then
  1092. stopEvent(palenie)
  1093. else
  1094. if kierunek == n then
  1095. kierunek = s
  1096. elseif kierunek == s then
  1097. kierunek = n
  1098. elseif kierunek == e then
  1099. kierunek = w
  1100. elseif kierunek == w then
  1101. kierunek = e
  1102. end
  1103. end
  1104. local plus =
  1105. {
  1106. x1 = {0, 1, 0, -1},
  1107. x3 = {0, -1, 0, 1},
  1108. y1 = {-1, 0, 1, 0},
  1109. y3 = {1, 0, -1, 0}
  1110. }
  1111. local czesci = {
  1112. {x = getCreaturePosition(cid).x+plus.x1[kierunek+1], y = getCreaturePosition(cid).y+plus.y1[kierunek+1], z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
  1113. {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
  1114. {x = getCreaturePosition(cid).x+plus.x3[kierunek+1], y = getCreaturePosition(cid).y+plus.y3[kierunek+1], z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
  1115. }
  1116. lodz = getThingFromPos(czesci[i])
  1117. doRemoveItem(lodz.uid, 1)
  1118. end
  1119. doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
  1120. doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
  1121. if getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid ~= 0 then
  1122. doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid, 1)
  1123. end
  1124. if getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid ~= 0 then
  1125. doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid, 1)
  1126. end
  1127. if getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid ~= 0 then
  1128. doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid, 1)
  1129. end
  1130. if getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid ~= 0 then
  1131. doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid, 1)
  1132. end
  1133. doPlayerRemoveAllStoragesFromBattleBoats(cid)
  1134. doPlayerSendTextMessage(cid, 4, "Thanks for using Battle Boats. This time you didn't successfully complete the voyage.")
  1135. doBroadcastMessage("".. getCreatureName(cid) .." has broke his boat and he end his voyage.", 22)
  1136. return true
  1137. end
  1138. return true
  1139. end
  1140.  
  1141. function plyn(cid)
  1142. if(getGlobalStorageValue(smok) ~= 1) then
  1143. addEvent(smoki, 1000)
  1144. setGlobalStorageValue(smok, 1)
  1145. end
  1146. if getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == l[NORTH][1] then
  1147. if(getPlayerStorageValue(cid, q.strona) == 3) then
  1148. if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-2, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
  1149. for n = 1, 3 do
  1150. local i = n - 2
  1151. doSendMagicEffect({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
  1152. end
  1153. stopEvent(plyn)
  1154. setPlayerStorageValue(cid, q.plynie, 0)
  1155. addEvent(palenie, 1, cid)
  1156. return true
  1157. end
  1158. elseif(getPlayerStorageValue(cid, q.strona) == 4) then
  1159. if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+2, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
  1160. for n = 1, 3 do
  1161. local i = n - 2
  1162. doSendMagicEffect({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
  1163. end
  1164. stopEvent(plyn)
  1165. setPlayerStorageValue(cid, q.plynie, 0)
  1166. addEvent(palenie, 1, cid)
  1167. return true
  1168. end
  1169. end
  1170. else
  1171. if(getPlayerStorageValue(cid, q.strona) == 1) then
  1172. if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x+2, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
  1173. for n = 1, 3 do
  1174. local i = n - 2
  1175. doSendMagicEffect({x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
  1176. end
  1177. stopEvent(plyn)
  1178. setPlayerStorageValue(cid, q.plynie, 0)
  1179. addEvent(palenie, 1, cid)
  1180. return true
  1181. end
  1182. elseif(getPlayerStorageValue(cid, q.strona) == 2) then
  1183. if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x-2, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
  1184. for n = 1, 3 do
  1185. local i = n - 2
  1186. doSendMagicEffect({x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
  1187. end
  1188. stopEvent(plyn)
  1189. setPlayerStorageValue(cid, q.plynie, 0)
  1190. addEvent(palenie, 1, cid)
  1191. return true
  1192. end
  1193. end
  1194. end
  1195. local plus =
  1196. {
  1197. x = {0, 1, 0, -1},
  1198. y = {-1, 0, 1, 0},
  1199. x1 = {0, 1, 0, -1},
  1200. x3 = {0, -1, 0, 1},
  1201. x4 = {0, -2, 0, 2},
  1202. y1 = {-1, 0, 1, 0},
  1203. y2 = {0, 0, 0, 0},
  1204. y3 = {1, 0, -1, 0},
  1205. y4 = {2, 0, -2, 0}
  1206. }
  1207. local kierunki = {EAST, WEST, NORTH, SOUTH}
  1208. local kier = getPlayerStorageValue(cid, q.strona)
  1209. local kierunek = kier > 0 and kierunki[kier]
  1210. if not isInArray({1, 2, 3, 4}, kier) then
  1211. stopEvent(plyn)
  1212. else
  1213. if kierunek == n then
  1214. kierunek = s
  1215. elseif kierunek == s then
  1216. kierunek = n
  1217. elseif kierunek == e then
  1218. kierunek = w
  1219. elseif kierunek == w then
  1220. kierunek = e
  1221. end
  1222. local czesci = {
  1223. {x = getCreaturePosition(cid).x+plus.x1[kierunek+1], y = getCreaturePosition(cid).y+plus.y1[kierunek+1], z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
  1224. {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
  1225. {x = getCreaturePosition(cid).x+plus.x3[kierunek+1], y = getCreaturePosition(cid).y+plus.y3[kierunek+1], z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
  1226. }
  1227. local npos = {
  1228. {x = getCreaturePosition(cid).x+plus.x[kierunek+1]+plus.x1[kierunek+1], y = getCreaturePosition(cid).y+plus.y[kierunek+1]+plus.y1[kierunek+1], z = getCreaturePosition(cid).z},
  1229. {x = getCreaturePosition(cid).x+plus.x[kierunek+1], y = getCreaturePosition(cid).y+plus.y[kierunek+1], z = getCreaturePosition(cid).z},
  1230. {x = getCreaturePosition(cid).x+plus.x[kierunek+1]+plus.x3[kierunek+1], y = getCreaturePosition(cid).y+plus.y[kierunek+1]+plus.y3[kierunek+1], z = getCreaturePosition(cid).z}
  1231. }
  1232. for i = 1, 3 do
  1233. lodz = getThingFromPos(czesci[i])
  1234. doRemoveItem(lodz.uid, 1)
  1235. doCreateItem(l[kierunek][i], 1, npos[i])
  1236. while getThingFromPos({x = czesci[i].x, y = czesci[i].y, z = czesci[i].z, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}).itemid > 0 do
  1237. doTeleportThing(getThingFromPos({x = czesci[i].x, y = czesci[i].y, z = czesci[i].z, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}).uid, npos[i])
  1238. end
  1239. end
  1240. doSendMagicEffect({x = getCreaturePosition(cid).x+plus.x4[kierunek+1], y = getCreaturePosition(cid).y+plus.y4[kierunek+1], z = getCreaturePosition(cid).z}, CONST_ME_POFF)
  1241. return {x = getCreaturePosition(cid).x+plus.x[kierunek+1], y = getCreaturePosition(cid).y+plus.y[kierunek+1], z = getCreaturePosition(cid).z}
  1242. end
  1243. return true
  1244. end
  1245.  
  1246. function onSay(cid, words, param, channel)
  1247. if(param == '') then
  1248. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Available commands: go, stop, right, left, up, down, fast, slow.")
  1249. return true
  1250. end
  1251. if(param == ('go' or 'stop' or 'up' or 'down' or 'left' or 'right' or 'fast' or 'slow')) then
  1252. if(getPlayerStorageValue(cid, q.start) ~= 1) then
  1253. return false
  1254. end
  1255. end
  1256. if(getPlayerStorageValue(cid, q.start) ~= 1) then
  1257. doPlayerSendCancel(cid, "You cannot use this command not participating in the game.")
  1258. return false
  1259. end
  1260. if(getPlayerStorageValue(cid, q.stop) == 1) then
  1261. doPlayerSendCancel(cid, "You cannot do nothing while your ship is on fire.")
  1262. return true
  1263. end
  1264. if(param == 'stop') then
  1265. if(getPlayerStorageValue(cid, q.plynie) == 1) then
  1266. stopEvent(plyn)
  1267. doPlayerSendCancel(cid, "You stopped your boat.")
  1268. setPlayerStorageValue(cid, q.plynie, -1)
  1269. elseif(getPlayerStorageValue(cid, q.plynie) ~= 1) then
  1270. doPlayerSendCancel(cid, "Your boat is not moving.")
  1271. end
  1272. return true
  1273. end
  1274. if(param == 'fast') then
  1275. if(getPlayerStorageValue(cid, q.plynie) == 1) then
  1276. q.speed = 500
  1277. doPlayerSendCancel(cid, "Your boat began to flow faster.")
  1278. elseif(getPlayerStorageValue(cid, q.plynie) ~= 1) then
  1279. doPlayerSendCancel(cid, "Your boat is not moving.")
  1280. end
  1281. return true
  1282. end
  1283. if(param == 'slow') then
  1284. if(getPlayerStorageValue(cid, q.plynie) == 1) then
  1285. q.speed = 1000
  1286. doPlayerSendCancel(cid, "Your boat began to flow slower.")
  1287. elseif(getPlayerStorageValue(cid, q.plynie) ~= 1) then
  1288. doPlayerSendCancel(cid, "Your boat is not moving.")
  1289. end
  1290. return true
  1291. end
  1292. if(param == 'go') then
  1293. if(getPlayerStorageValue(cid, q.plynie) == 1) then
  1294. doPlayerSendCancel(cid, "Currently, your boat is in motion.")
  1295. elseif(getPlayerStorageValue(cid, q.plynie) ~= 1) and (getPlayerStorageValue(cid, q.strona) > 0) then
  1296. setPlayerStorageValue(cid, q.plynie, 1)
  1297. zacznijCzekac(function()
  1298. while (getPlayerStorageValue(cid, q.plynie) == 1) do
  1299. addEvent(plyn, 1, cid)
  1300. czekaj(q.speed)
  1301. end
  1302. end)
  1303. doPlayerSendCancel(cid, "Your boat was launched.")
  1304. elseif(getPlayerStorageValue(cid, q.plynie) ~= 1) and (getPlayerStorageValue(cid, q.strona) <= 0) then
  1305. doPlayerSendCancel(cid, "You cannot start, firstly u must set direction where u want to go.")
  1306. end
  1307. return true
  1308. end
  1309. if(param == 'right') then
  1310. if getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
  1311. if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x+1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
  1312. for n = 1, 3 do
  1313. local i = n - 2
  1314. doSendMagicEffect({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
  1315. end
  1316. stopEvent(plyn)
  1317. setPlayerStorageValue(cid, q.plynie, 0)
  1318. addEvent(palenie, 1, cid)
  1319. return true
  1320. end
  1321. for n = 1, 3 do
  1322. local i = n - 2
  1323. doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  1324. doCreateItem(l[EAST][n], 1, {x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z})
  1325. doCreatureSetLookDirection(cid, 1)
  1326. end
  1327. setPlayerStorageValue(cid, q.strona, 1)
  1328. else
  1329. doPlayerSendCancel(cid, "This is impossible in reality...")
  1330. end
  1331. return true
  1332. end
  1333. if(param == 'left') then
  1334. if getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
  1335. if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x-1, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
  1336. for n = 1, 3 do
  1337. local i = n - 2
  1338. doSendMagicEffect({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
  1339. end
  1340. stopEvent(plyn)
  1341. setPlayerStorageValue(cid, q.plynie, 0)
  1342. addEvent(palenie, 1, cid)
  1343. return true
  1344. end
  1345. for n = 1, 3 do
  1346. local i = n - 2
  1347. doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  1348. doCreateItem(l[WEST][n], 1, {x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z})
  1349. doCreatureSetLookDirection(cid, 3)
  1350. end
  1351. setPlayerStorageValue(cid, q.strona, 2)
  1352. else
  1353. doPlayerSendCancel(cid, "This is impossible in reality...")
  1354. end
  1355. return true
  1356. end
  1357. if(param == 'up') then
  1358. if getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
  1359. if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
  1360. for n = 1, 3 do
  1361. local i = n - 2
  1362. doSendMagicEffect({x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
  1363. end
  1364. stopEvent(plyn)
  1365. setPlayerStorageValue(cid, q.plynie, 0)
  1366. addEvent(palenie, 1, cid)
  1367. return true
  1368. end
  1369. for n = 1, 3 do
  1370. local i = n - 2
  1371. doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  1372. doCreateItem(l[NORTH][n], 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z})
  1373. doCreatureSetLookDirection(cid, 0)
  1374. end
  1375. setPlayerStorageValue(cid, q.strona, 3)
  1376. else
  1377. doPlayerSendCancel(cid, "This is impossible in reality...")
  1378. end
  1379. return true
  1380. end
  1381. if(param == 'down') then
  1382. if getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
  1383. if isInArray(q.przeszkoda, getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+1, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid) then
  1384. for n = 1, 3 do
  1385. local i = n - 2
  1386. doSendMagicEffect({x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z}, CONST_ME_POFF)
  1387. end
  1388. stopEvent(plyn)
  1389. setPlayerStorageValue(cid, q.plynie, 0)
  1390. addEvent(palenie, 1, cid)
  1391. return true
  1392. end
  1393. for n = 1, 3 do
  1394. local i = n - 2
  1395. doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  1396. doCreateItem(l[SOUTH][n], 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z})
  1397. doCreatureSetLookDirection(cid, 2)
  1398. end
  1399. setPlayerStorageValue(cid, q.strona, 4)
  1400. else
  1401. doPlayerSendCancel(cid, "This is impossible in reality...")
  1402. end
  1403. return true
  1404. end
  1405. return true
  1406. end
  1407. ]]></talkaction>
  1408. <event type="kill" name="BattleKill" event="script"><![CDATA[
  1409. domodlib('re')
  1410. function onKill(cid, target, lastHit)
  1411. local l = {
  1412. [NORTH] = {3587,3589,3591},
  1413. [SOUTH] = {3591,3589,3587},
  1414. [WEST] = {3592,3594,3596},
  1415. [EAST] = {3596,3594,3592}
  1416. }
  1417. if not(isPlayer(target)) or not(isPlayer(cid)) then
  1418. return true
  1419. end
  1420. if getPlayerStorageValue(cid, q.zapisany) == 1 or getPlayerStorageValue(cid, q.gotowy) == 1 then
  1421. if getGlobalStorageValue(q.start) == 1 then
  1422. setGlobalStorageValue(q.playersCount, getGlobalStorageValue(q.playersCount)-1)
  1423. if getGlobalStorageValue(q.playersCount) > 1 then
  1424. if getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
  1425. for n = 1, 3 do
  1426. local i = n - 2
  1427. doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  1428. doCreateItem(l[WEST][n], 1, {x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z})
  1429. end
  1430. elseif getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
  1431. for n = 1, 3 do
  1432. local i = n - 2
  1433. doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  1434. doCreateItem(l[NORTH][n], 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z})
  1435. end
  1436. elseif getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
  1437. for n = 1, 3 do
  1438. local i = n - 2
  1439. doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  1440. doCreateItem(l[SOUTH][n], 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z})
  1441. end
  1442. elseif getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
  1443. for n = 1, 3 do
  1444. local i = n - 2
  1445. doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  1446. doCreateItem(l[EAST][n], 1, {x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z})
  1447. end
  1448. end
  1449. doPlayerRemoveAllStoragesFromBattleBoats(cid)
  1450. if getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid ~= 0 then
  1451. doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid, 1)
  1452. end
  1453. if getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid ~= 0 then
  1454. doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid, 1)
  1455. end
  1456. if getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid ~= 0 then
  1457. doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid, 1)
  1458. end
  1459. if getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid ~= 0 then
  1460. doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid, 1)
  1461. end
  1462. doPlayerSendTextMessage(cid, 4, "Thanks for using Battle Boats. This time you didn't successfully complete the voyage.")
  1463. doBroadcastMessage("".. getCreatureName(cid) .." has been killed by ".. getCreatureName(target) ..".", 22)
  1464. doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
  1465. doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
  1466. elseif getGlobalStorageValue(q.playersCount) == 1 then
  1467. if getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
  1468. for n = 1, 3 do
  1469. local i = n - 2
  1470. doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  1471. doCreateItem(l[WEST][n], 1, {x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z})
  1472. end
  1473. elseif getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
  1474. for n = 1, 3 do
  1475. local i = n - 2
  1476. doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x+i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  1477. doCreateItem(l[NORTH][n], 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y+i, z = getCreaturePosition(cid).z})
  1478. end
  1479. elseif getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[EAST][2] or l[WEST][2]) then
  1480. for n = 1, 3 do
  1481. local i = n - 2
  1482. doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  1483. doCreateItem(l[SOUTH][n], 1, {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z})
  1484. end
  1485. elseif getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).itemid == (l[NORTH][2] or l[SOUTH][2]) then
  1486. for n = 1, 3 do
  1487. local i = n - 2
  1488. doRemoveItem(getThingFromPos({x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-i, z = getCreaturePosition(cid).z, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}).uid, 1)
  1489. doCreateItem(l[EAST][n], 1, {x = getCreaturePosition(cid).x-i, y = getCreaturePosition(cid).y, z = getCreaturePosition(cid).z})
  1490. end
  1491. end
  1492. doPlayerRemoveAllStoragesFromBattleBoats(cid)
  1493. doPlayerSendTextMessage(cid, 4, "Thanks for using Battle Boats. This time you didn't successfully complete the voyage.")
  1494. doBroadcastMessage("".. getCreatureName(cid) .." has been killed by ".. getCreatureName(target) ..".", 22)
  1495. doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
  1496. doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
  1497. if getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid ~= 0 then
  1498. doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid, 1)
  1499. end
  1500. if getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid ~= 0 then
  1501. doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid, 1)
  1502. end
  1503. if getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid ~= 0 then
  1504. doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid, 1)
  1505. end
  1506. if getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid ~= 0 then
  1507. doPlayerRemoveItem(cid, getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid, 1)
  1508. end
  1509. doRemoveAllGlobStoragesFromBattleBoats()
  1510. local random_item = q.rewardsId[math.random(1, #q.rewardsId)]
  1511. local item_name = getItemNameById(random_item)
  1512. if(random_item == 2160) then
  1513. doPlayerAddItem(cid, random_item, q.crystal_counts)
  1514. doPlayerSendTextMessage(cid, 4, "Congratulations! You won Battle Boats! Your reward is: ".. q.crystal_counts .." ".. item_name .."s!")
  1515. else
  1516. doPlayerAddItem(cid, random_item, 1)
  1517. doPlayerSendTextMessage(cid, 4, "Congratulations! You won Battle Boats! Your reward is: ".. item_name .."!")
  1518. end
  1519. return true
  1520. end
  1521. end
  1522. return true
  1523. end
  1524. return true
  1525. end
  1526. ]]></event>
  1527. </mod>
Advertisement
Add Comment
Please, Sign In to add comment