Advertisement
Guest User

Untitled

a guest
Aug 12th, 2015
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.34 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <mod name="Kienzan event" version="1.1" author="Rulexz" contact="thiagorulexz@gmail.com" enabled="yes">
  3. <description>
  4. This should teleport all players to a new random town in intervals and add them into a team.
  5. </description>
  6. <config name="config"><![CDATA[
  7. t = {
  8. main = {
  9. tfs_version = "0.3", --0.3 or 0.4
  10. positions = {
  11. paintball_spawn_area = {
  12. top_left = {x = 1215, y = 2088, z = 4}, --Top left pos of spawning area
  13. bottom_right = {x = 1254, y = 2116, z = 7}--bottom right pos of spawning area
  14. },
  15. waiting_room_area = {
  16. top_left = {x = 970, y = 1040, z = 7}, --Top left pos of the waiting room
  17. bottom_right = {x = 975, y = 1046, z = 7}--bottom right pos of the waiting room
  18. },
  19. tp_to_paintball = {x = 306, y = 827, z = 15}, --pos where the tp will be created
  20. event_ending_pos = {x = 301, y = 841, z = 15} --pos players will be sent after event ending
  21. },
  22. storages = {
  23. exhaust = 2455,
  24. is_in_event = 2460,
  25. score = 2465
  26. },
  27. misc = {
  28. status = 'on'
  29. },
  30. messages = {
  31. event_started = "o evento Kienzan Foi iniciado!",--Message that will be broadcasted after the event has started
  32. event_ended = "o evento Kienzan Acabou!" --same but when event ends
  33. },
  34. event_config = {
  35. event_duration = 10, --minutes, 0 if it's an always-open event
  36. infinite_ammo = false,
  37. winner_gets_item = true,
  38. prize_item_id = 3051,
  39. decrease_score_on_death = true,
  40. points_per_kill = 1,
  41. randomize_player_start_pos = true,
  42. ammo_per_point = 5,
  43. reset_bullets_on_death = true,
  44. min_bullets_on_spawn = 30,
  45. start_automatically = false,
  46. use_waiting_room = false,
  47. waiting_time = 0 --minutes
  48. }
  49. },
  50. onShoot = {
  51. storages = {
  52. ammo = 2400
  53. },
  54. misc = {
  55. walls_id = {1115,1111,1112,5258,1385,1113},
  56. bullets_exhaust = 500, --in ms
  57. bullet_speed = 150
  58. },
  59. vars = {
  60. shootdir = 0
  61. }
  62. }
  63. }
  64. ]]></config>
  65. <movevent type="StepIn" actionid ="2880" event="script"><![CDATA[
  66. domodlib('config')
  67. function onStepIn(cid, item, pos)
  68. local t_l = t.main.positions.paintball_spawn_area.top_left
  69. local b_r = t.main.positions.paintball_spawn_area.bottom_right
  70. doTeleportThing(cid, {x=math.random(t_l.x,b_r.x), y=math.random(t_l.y, b_r.y), z=math.random(t_l.z, b_r.z)})
  71. doPlayerSetStorageValue(cid, t.main.storages.is_in_event,1)
  72. doPlayerSetStorageValue(cid, t.onShoot.storages.ammo, t.main.event_config.min_bullets_on_spawn)
  73. doPlayerSetStorageValue(cid, t.main.storages.score, 0)
  74. doPlayerSendTextMessage(cid,27,"Bem Vindo Ao Evento Kienzan, Estes são os commandos:\n!kienzan bullet --Para Soltar o Poder.\n!kienzan ammo --This will give you "..t.main.event_config.ammo_per_point.." bullets and take 1 point from your current score (you need at least 1 point to use this command).\n!kienzan info --This will show you your current score and ammo, it'll also show the current high score of the event.\nIt is strongly recommended that you bind these commands to your hotkeys.")
  75. end
  76. ]]></movevent>
  77. <globalevent name="StartPaintBall" interval="3600" event="script"><![CDATA[
  78. domodlib('config')
  79. function onThink(interval, lastExecution, thinkInterval)
  80. if t.main.event_config.start_automatically then
  81. doBroadcastMessage(t.main.messages.event_started, MESSAGE_STATUS_WARNING)
  82. if t.main.event_config.use_waiting_room then
  83. addEvent(moveToEvent, t.main.event_config.waiting_time*1000*60)
  84. doCreateTeleport(1387,t.main.positions.waiting_room_area.top_left, t.main.positions.tp_to_paintball)
  85. else
  86. if t.main.tfs_version == "0.3" then
  87. doItemSetAttribute(doCreateItem(1387, t.main.positions.tp_to_paintball), "aid", 2880)
  88. else
  89. doSetItemActionId(doCreateItem(1387, t.main.positions.tp_to_paintball),2880)
  90. end
  91. if(t.main.event_config.event_duration > 0) then
  92. addEvent(endPaintball, t.main.event_config.event_duration*1000*60)
  93. end
  94. end
  95. end
  96. return true
  97. end
  98.  
  99. function endPaintball()
  100. local score = {}
  101. if not t.main.event_config.use_waiting_room then
  102. doRemoveItem(getTileItemById(t.main.positions.tp_to_paintball,1387).uid)
  103. end
  104. for _, pid in ipairs(getPlayersOnline()) do
  105. if getPlayerStorageValue(pid, t.main.storages.is_in_event) > 0 then
  106. table.insert(score, {getCreatureName(pid), getPlayerStorageValue(pid, t.main.storages.score)})
  107. doPlayerSetStorageValue(pid, t.main.storages.is_in_event, 0)
  108. doPlayerSetStorageValue(pid, t.main.storages.score, 0)
  109. doPlayerSetStorageValue(pid, t.onShoot.storages.ammo, 0)
  110. doTeleportThing(pid, t.main.positions.event_ending_pos)
  111. end
  112. end
  113. table.sort(score, function(a, b) return a[2] > b[2] end)
  114. if table.getn(score) > 0 then
  115. if t.main.event_config.winner_gets_item then
  116. for _, pid in ipairs(getPlayersOnline()) do
  117. if getCreatureName(pid) == score[1][1] then
  118. doPlayerAddItem(pid, t.main.event_config.prize_item_id)
  119. break
  120. end
  121. end
  122. end
  123. doBroadcastMessage("Paintball event has ended, "..score[1][1].." won paintball event with "..score[1][2].." points", MESSAGE_STATUS_WARNING)
  124. end
  125. end
  126. local t_l = t.main.positions.paintball_spawn_area.top_left
  127. local b_r = t.main.positions.paintball_spawn_area.bottom_right
  128. function moveToEvent()
  129. for _, pid in ipairs(getPlayersOnline()) do
  130. if isInRange(getCreaturePosition(pid), t.main.positions.waiting_room_area.top_left, t.main.positions.waiting_room_area.bottom_right) then
  131. doTeleportThing(pid, {x=math.random(t_l.x,b_r.x), y=math.random(t_l.y, b_r.y), z=math.random(t_l.z, b_r.z)})
  132. doPlayerSetStorageValue(pid, t.main.storages.is_in_event,1)
  133. doPlayerSetStorageValue(pid, t.onShoot.storages.ammo, t.main.event_config.min_bullets_on_spawn)
  134. doPlayerSetStorageValue(pid, t.main.storages.score, 0)
  135. doPlayerSendTextMessage(cid,27,"Bem Vindo Ao Evento Kienzan, Estes são os commandos:\n!kienzan bullet --Para Soltar o Poder.\n!kienzan ammo --This will give you "..t.main.event_config.ammo_per_point.." bullets and take 1 point from your current score (you need at least 1 point to use this command).\n!kienzan info --This will show you your current score and ammo, it'll also show the current high score of the event.\nIt is strongly recommended that you bind these commands to your hotkeys.")
  136. end
  137. end
  138. doRemoveItem(getTileItemById(t.main.positions.tp_to_paintball,1387).uid)
  139. addEvent(endPaintball, t.main.event_config.event_duration*1000*60)
  140. end
  141. ]]></globalevent>
  142. <talkaction words="!kienzan" event="script"><![CDATA[
  143. domodlib('config')
  144. function onSay(cid, words, param, channel)
  145. local k = string.explode(param, ",")
  146. if(k[1] ~= nil) then
  147. if(string.upper(k[1]) == 'END') and getPlayerGroupId(cid) >= 3 then
  148. endPaintball()
  149. end
  150. if(string.upper(k[1]) == 'START') and getPlayerGroupId(cid) >= 3 then
  151. doBroadcastMessage(t.main.messages.event_started, MESSAGE_STATUS_WARNING)
  152. if t.main.event_config.use_waiting_room then
  153. addEvent(moveToEvent, t.main.event_config.waiting_time*1000*60)
  154. doCreateTeleport(1387,t.main.positions.waiting_room_area.top_left, t.main.positions.tp_to_paintball)
  155. else
  156. if t.main.tfs_version == "0.3" then
  157. doItemSetAttribute(doCreateItem(1387, t.main.positions.tp_to_paintball), "aid", 2880)
  158. else
  159. doSetItemActionId(doCreateItem(1387, t.main.positions.tp_to_paintball),2880)
  160. end
  161. if(t.main.event_config.event_duration > 0) then
  162. addEvent(endPaintball, t.main.event_config.event_duration*1000*60)
  163. end
  164. end
  165. end
  166. if(string.upper(k[1]) == 'INFO') then
  167. local score = {}
  168. local output = "You have " .. getPlayerStorageValue(cid, t.main.storages.score) .. " points.\nYou have "..getPlayerStorageValue(cid, t.onShoot.storages.ammo).." ammo left.\n------------------\nThe current high score in paintball is:\n"
  169. for _, pid in ipairs(getPlayersOnline()) do
  170. if getPlayerStorageValue(pid, t.main.storages.is_in_event) then
  171. table.insert(score, {getCreatureName(pid), getPlayerStorageValue(pid, t.main.storages.score)})
  172. end
  173. end
  174. local lx = table.getn(score)
  175. if(lx > 3) then lx = 3 end
  176. table.sort(score, function(a, b) return a[2] > b[2] end)
  177. for k = 1,lx do
  178. output = output .. k..". "..score[k][1] .." [".. score[k][2] .."].\n"
  179. end
  180. doPlayerPopupFYI(cid, output)
  181. end
  182. if (string.upper(k[1]) == 'AMMO') then
  183. if(t.main.event_config.infinite_ammo) then
  184. doPlayerSendTextMessage(cid, 27, "Ammo is infinite, there's no need to buy more.")
  185. else
  186. if getPlayerStorageValue(cid, t.main.storages.score) > 0 then
  187. doPlayerSetStorageValue(cid, t.main.storages.score, getPlayerStorageValue(cid, t.main.storages.score)-1)
  188. doPlayerSetStorageValue(cid, t.onShoot.storages.ammo, getPlayerStorageValue(cid,t.onShoot.storages.ammo)+t.main.event_config.ammo_per_point)
  189. doPlayerSendTextMessage(cid, 27, "You have received " .. t.main.event_config.ammo_per_point .. " bullets and you have lost 1 score point.")
  190. doSendMagicEffect(getCreaturePosition(cid),4)
  191. else
  192. doPlayerSendTextMessage(cid, 27, "You do not have enough score points to buy ammo, you need ".. 1-(getPlayerStorageValue(cid, t.main.storages.score)).. " more.")
  193. end
  194. end
  195. end
  196. if (string.upper(k[1]) == 'BULLET') then
  197. if(getPlayerStorageValue(cid, t.main.storages.is_in_event) == 1) then
  198. if getPlayerStorageValue(cid, t.main.storages.exhaust) <= 1 then
  199. if(getPlayerStorageValue(cid, t.onShoot.storages.ammo) > 0) then
  200. if t.main.misc.status == 'on' then
  201. if(t.main.event_config.infinite_ammo == false) then
  202. doPlayerSetStorageValue(cid, t.onShoot.storages.ammo, getPlayerStorageValue(cid, t.onShoot.storages.ammo)-1)
  203. end
  204. doPlayerSetStorageValue(cid, t.main.storages.exhaust, 2)
  205. lineAnimation(getPlayerLookDirection(cid),getCreaturePosition(cid),12,cid,1,0,1,0,0,0,1,0)
  206. addEvent(doPlayerSetStorageValue,t.onShoot.misc.bullets_exhaust, cid, t.main.storages.exhaust,1)
  207. else
  208. return false
  209. end
  210. else
  211. doPlayerSendCancel(cid, "You're out of ammo, exchange ammo for points with !shoot ammo or get killed for a recharge.")
  212. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  213. end
  214. else
  215. doPlayerSendCancel(cid, "Gun is on cooldown")
  216. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  217. end
  218. else
  219. doPlayerSendCancel(cid, "You need to be in the event.")
  220. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  221. end
  222. end
  223. end
  224. return true
  225. end
  226.  
  227.  
  228. function lineAnimation(lookDir,playerPos,effect,cid,fvar,fpos,ffound,fposV,fcheck,fvcid,floopCounter,fvpid, name)
  229. local var = fvar
  230. local pos = fpos
  231. local found = ffound
  232. local posV = fposV
  233. local check = fcheck
  234. local vcid = fvcid
  235. local loopCounter = floopCounter
  236. local vpid = fvpid
  237. local storage = t.main.storages.exhaust
  238. if var < 2 then
  239. vcid = cid
  240. end
  241. pos = playerPos
  242. if not isInWallArray(convert(lookDir,pos)) then--isInWallArray({x=convert(lookDir,pos).x, y=convert(lookDir,pos).y,z=convert(lookDir,pos).z}) then --isInArray(t.onShoot.misc.walls_id, getThingfromPos({x=convert(lookDir,pos).x, y=convert(lookDir,pos).y,z=convert(lookDir,pos).z, stackpos=0}).itemid) then
  243. doSendDistanceShoot(pos, convert(lookDir,pos),effect)
  244. pos = convert(lookDir,pos)
  245. var=var+1
  246. posV = convertV(lookDir,playerPos)
  247. for _, pid in ipairs(getPlayersOnline()) do
  248. if (getCreaturePosition(pid).x == pos.x and getCreaturePosition(pid).y == pos.y and getCreaturePosition(pid).z == pos.z) then
  249. --if loopCounter > 2 then
  250. vpid = pid
  251. --end
  252. if (vpid ~= vcid) then
  253. if var > 2 then
  254. if (getCreaturePosition(pid).x == posV.x and getCreaturePosition(pid).y == posV.y and getCreaturePosition(pid).z == posV.z) then
  255. killPlayer(pid,pos,getCreatureName(vcid))
  256. if (lookDir == 0) or (lookDir == 2) then
  257. var = 6
  258. else
  259. var = 8
  260. end
  261. end
  262. end
  263. killPlayer(pid,pos,vcid)
  264. if (lookDir == 0) or (lookDir == 2) then
  265. var = 6
  266. else
  267. var = 8
  268. end
  269. end
  270. end
  271. loopCounter = loopCounter +1
  272. end
  273. if (lookDir == 0) or (lookDir == 2) then
  274. if var ~= 6 then
  275. addEvent(lineAnimation, t.onShoot.misc.bullet_speed, lookDir,pos,effect,nil,var,pos,found,posV,check,vcid,loopCounter,vpid)
  276. else
  277. var = 1
  278. end
  279. else
  280. if var ~= 8 then
  281. addEvent(lineAnimation, t.onShoot.misc.bullet_speed, lookDir,pos,effect,nil,var,pos,found,posV,check,vcid,loopCounter,vpid)
  282. else
  283. var = 1
  284. end
  285. end
  286. else
  287. doSendMagicEffect(convert(lookDir,pos),2)
  288. var = 1
  289. end
  290. end
  291.  
  292. local ret = {}
  293. function convert(lookDir,pos)
  294. local positions = {
  295. [0] = {x = pos.x, y = pos.y-1, z = pos.z},
  296. [1] = {x = pos.x+1, y = pos.y, z = pos.z},
  297. [2] = {x = pos.x, y = pos.y+1, z = pos.z},
  298. [3] = {x = pos.x-1, y = pos.y, z = pos.z}
  299. }
  300. ret = positions[lookDir]
  301. return ret
  302. end
  303.  
  304.  
  305. local ret = {}
  306. function convertV(lookDir,pos)
  307. local positions = {
  308. [0] = {x = pos.x, y = pos.y+1, z = pos.z},
  309. [1] = {x = pos.x-1, y = pos.y, z = pos.z},
  310. [2] = {x = pos.x, y = pos.y-1, z = pos.z},
  311. [3] = {x = pos.x+1, y = pos.y, z = pos.z}
  312. }
  313. ret = positions[lookDir]
  314. return ret
  315. end
  316.  
  317. function killPlayer(cid,pos, killer)
  318. local t_l = t.main.positions.paintball_spawn_area.top_left
  319. local b_r = t.main.positions.paintball_spawn_area.bottom_right
  320. doTeleportThing(cid, {x=math.random(t_l.x,b_r.x), y=math.random(t_l.y, b_r.y), z=math.random(t_l.z, b_r.z)})
  321. doSendMagicEffect(pos,2)
  322. doPlayerSendTextMessage(cid, 27, "You've been killed by "..getCreatureName(killer)..".")
  323. doPlayerSetStorageValue(killer, t.main.storages.score, getPlayerStorageValue(killer, t.main.storages.score)+t.main.event_config.points_per_kill)
  324. doPlayerSendTextMessage(killer, 27, "You've killed "..getCreatureName(cid)..".")
  325. doBroadcastMessage("[Event] Paintball: "..getCreatureName(killer).." has killed "..getCreatureName(cid)..".", MESSAGE_STATUS_WARNING)
  326. if t.main.event_config.decrease_score_on_death then
  327. doPlayerSetStorageValue(cid, t.main.storages.score, getPlayerStorageValue(cid, t.main.storages.score)-1)
  328. end
  329. if t.main.event_config.reset_bullets_on_death then
  330. doPlayerSetStorageValue(cid, t.onShoot.storages.ammo, t.main.event_config.min_bullets_on_spawn)
  331. end
  332. end
  333.  
  334. function isInWallArray(pos)
  335. for k = 0, table.getn(t.onShoot.misc.walls_id) do
  336. if getTileItemById(pos, t.onShoot.misc.walls_id[k]).itemid == t.onShoot.misc.walls_id[k] then --this doesn't even make sense but tried other ways and it gave errors, so meh 2lazy2search
  337. return true
  338. end
  339. end
  340. return false
  341. end
  342. function endPaintball()
  343. local score = {}
  344. if not t.main.event_config.use_waiting_room then
  345. doRemoveItem(getTileItemById(t.main.positions.tp_to_paintball,1387).uid)
  346. end
  347. for _, pid in ipairs(getPlayersOnline()) do
  348. if getPlayerStorageValue(pid, t.main.storages.is_in_event) > 0 then
  349. table.insert(score, {getCreatureName(pid), getPlayerStorageValue(pid, t.main.storages.score)})
  350. doPlayerSetStorageValue(pid, t.main.storages.is_in_event, 0)
  351. doPlayerSetStorageValue(pid, t.main.storages.score, 0)
  352. doPlayerSetStorageValue(pid, t.onShoot.storages.ammo, 0)
  353. doTeleportThing(pid, t.main.positions.event_ending_pos)
  354. end
  355. end
  356. table.sort(score, function(a, b) return a[2] > b[2] end)
  357. if table.getn(score) > 0 then
  358. if t.main.event_config.winner_gets_item then
  359. for _, pid in ipairs(getPlayersOnline()) do
  360. if getCreatureName(pid) == score[1][1] then
  361. doPlayerAddItem(pid, t.main.event_config.prize_item_id)
  362. break
  363. end
  364. end
  365. end
  366. doBroadcastMessage("o evento Kienzan se encerrou, "..score[1][1].." ganhou o evento com "..score[1][2].." pontos", MESSAGE_STATUS_WARNING)
  367. end
  368. end
  369. local t_l = t.main.positions.paintball_spawn_area.top_left
  370. local b_r = t.main.positions.paintball_spawn_area.bottom_right
  371. function moveToEvent()
  372. for _, pid in ipairs(getPlayersOnline()) do
  373. if isInRange(getCreaturePosition(pid), t.main.positions.waiting_room_area.top_left, t.main.positions.waiting_room_area.bottom_right) then
  374. doTeleportThing(pid, {x=math.random(t_l.x,b_r.x), y=math.random(t_l.y, b_r.y), z=math.random(t_l.z, b_r.z)})
  375. doPlayerSetStorageValue(pid, t.main.storages.is_in_event,1)
  376. doPlayerSetStorageValue(pid, t.onShoot.storages.ammo, t.main.event_config.min_bullets_on_spawn)
  377. doPlayerSetStorageValue(pid, t.main.storages.score, 0)
  378. doPlayerSendTextMessage(cid,27,"Bem Vindo Ao Evento Kienzan, Estes são os commandos:\n!kienzan bullet --Para Soltar o Poder.\n!kienzan ammo --This will give you "..t.main.event_config.ammo_per_point.." bullets and take 1 point from your current score (you need at least 1 point to use this command).\n!kienzan info --This will show you your current score and ammo, it'll also show the current high score of the event.\nIt is strongly recommended that you bind these commands to your hotkeys.")
  379. end
  380. end
  381. doRemoveItem(getTileItemById(t.main.positions.tp_to_paintball,1387).uid)
  382. addEvent(endPaintball, t.main.event_config.event_duration*1000*60)
  383. end
  384. ]]></talkaction>
  385. </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement