Advertisement
Xlyjc

X1 com fly (Team)

Dec 26th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.31 KB | None | 0 0
  1. function eventNewPlayer(name)
  2. for i,key in ipairs({83,40,69}) do
  3. tfm.exec.bindKeyboard(name,key,true,true)
  4. end
  5. end
  6.  
  7. function eventKeyboard(name,key,down,x,y)
  8. if key==83 or key==40 or key==69 then
  9. tfm.exec.movePlayer(name,0,0,true,0,-50,true)
  10. end
  11. end
  12.  
  13. for name,player in pairs(tfm.get.room.playerList) do
  14. eventNewPlayer(name)
  15. end
  16.  
  17. print("Voe E ou seta para baixo by Xlyjc!")
  18. ui.addTextArea(0, "Enjoy by Xlyjc", nil, 690, 370, 100, 20, 0x000000, 0xff00dd, 1, true)
  19. tfm.exec.disableAutoShaman()
  20. tfm.exec.disableAutoNewGame()
  21. tfm.exec.disableAutoTimeLeft()
  22.  
  23. local ADMINISTRADOR = "Xlyjc" -- Coloque seu nick para ser admin
  24. local WINS = 10 -- Pontos para ganhar
  25. system.disableChatCommandDisplay("np", true)
  26.  
  27. --[[
  28. After running the script, use the command !team1 Players and !team2 Players to set both players in the specified team
  29. Then you just need to press GO!
  30. Type !np @mapcode to run the next map.
  31. Type !score team1/team2 number to change its score.
  32. ]]
  33.  
  34. local teams = {
  35. [1] = {},
  36. [2] = {},
  37. }
  38. local points = {
  39. [1] = 0,
  40. [2] = 0,
  41. }
  42. local isfirst = false
  43. local gameRunning = false
  44. local winTime = false
  45. local playersInGame = {}
  46. local maps = {
  47. 114122, 116630, 148424, 150692, 156510, 165843, 166705, 180191, 180274, 180619, 196433, 198715, 208058, 208162, 209708, 212542, 213697, 217900, 223986, 226883, 227851, 229830, 231905, 232451, 232791, 236146, 239826, 239880, 241211, 242708, 245223, 246790, 255542, 258717, 260377, 261720, 266930, 271523, 277731, 281730, 286333, 287268, 299002, 299971, 305677, 308694, 308992, 309029, 314159, 315801, 317754, 323085, 323366, 332210, 332290, 339896, 340069, 341239, 343971, 344865, 345257, 348801, 349140, 352381, 355957, 356982, 357328, 359521, 363638, 365464, 365652, 367520, 381569, 381669, 386029, 391693, 391831, 393851, 401778, 405295, 405955, 410813, 412657, 414460, 414899, 416015, 418293, 418658, 419374, 421717, 423672, 424795, 425030, 425600, 429822, 429897, 430145, 431142, 431887, 434887, 445167, 447556, 470727, 471053, 477370, 499687, 501711, 504409, 505109, 507325, 508106, 508796, 509082, 512927, 514982, 531569, 536235, 563484, 571512, 594883, 595447, 606723, 611320, 616433, 664949, 694900, 737841, 813156, 849224, 982242, 1015582, 1033170, 1051384, 1058681, 1142116, 1195842, 1208798, 1214182, 1216253, 1255148, 1311059, 1364063, 1375345, 1448760, 1506007, 1512355, 1538895, 1601492, 1608638, 1619934, 1654841, 1663380, 1663415, 1689382, 1702169, 1724289, 1749434, 1768347, 1787232, 1813728, 1851968, 1856349, 1862823, 1927270, 1951856, 1956002, 1964752, 2012147, 2030343, 2070768, 2134537, 2141379, 2150335, 2221510, 2245005, 2331474, 2369254, 2683170, 2726034, 2796001, 2813487, 2816067, 3008155, 3156569, 3213562, 3444803, 3518418, 3537419, 3548376, 3548406, 3572407, 3575034, 3575108, 3620542, 3638794, 3654416, 3669435, 3676555, 3680223, 3685382, 3688419, 3700684, 3705931, 3716560, 3821104, 3889414, 4000001, 4234556, 4645670, 4707191, 4815404, 4911122, 4915220, 4946442, 5000090, 5024682, 5030579, 5032745, 5272513, 5346212, 5349806, 5408572, 5452432, 5495901, 5557858, 5590554, 5591416, 5712914, 5805021, 5813480, 5813783, 5861874, 5886041, 5972342, 6069526, 6112855, 6114810, 6172897, 6226519, 6276662, 6300594
  48. }
  49. local colors = {
  50. [1] = "32FF00",
  51. [2] = "FFF500"
  52. }
  53. local queue = {}
  54.  
  55. function newMap()
  56. local mapcode = maps[math.random(#maps)]
  57. if #queue > 0 then
  58. mapcode = queue[1]
  59. table.remove(queue, 1)
  60. end
  61. tfm.exec.newGame(mapcode)
  62. for player, data in pairs(tfm.get.room.playerList) do
  63. if not playersInGame[player] then
  64. tfm.exec.killPlayer(player)
  65. end
  66. end
  67. tfm.exec.setGameTime(60)
  68. end
  69.  
  70. function eventPlayerWon(player)
  71. if not isfirst then
  72. isfirst = true
  73. tfm.exec.setGameTime(5)
  74. if table.contains(teams[1], player) then
  75. tfm.exec.setGameTime(5)
  76. for i = 0, 3 do
  77. defaultEffect(9, {13}, math.random(800), math.random(400), 20)
  78. end
  79. points[1] = points[1]+1
  80. elseif table.contains(teams[2], player) then
  81. tfm.exec.setGameTime(5)
  82. for i = 0, 3 do
  83. defaultEffect(9, {9}, math.random(800), math.random(400), 20)
  84. end
  85. points[2] = points[2]+1
  86. else
  87. isfirst = false
  88. end
  89. winner = false
  90. if points[1] >= WINS then
  91. winner = 1
  92. elseif points[2] >= WINS then
  93. winner = 2
  94. end
  95. if winner then
  96. gameRunning = false
  97. winTime = os.time()
  98. ui.addTextArea(20, string.format("<p align='center'><font size='37' color='#000000'>O time %s ganhou!", winner), nil, 0, 171, 800, 500, 0, 0, 0, true)
  99. ui.addTextArea(21, string.format("<p align='center'><font size='37' color='#FFFFFF'>O time %s ganhou!", winner), nil, 1, 170, 800, 500, 0, 0, 0, true)
  100. ui.addTextArea(22, string.format("<p align='center'><font size='37' color='#%s'>O time %s ganhou!", colors[winner], winner), nil, 1, 170, 800, 500, 0, 0, 0, true)
  101. end
  102. displayScore()
  103. end
  104. end
  105.  
  106. function eventLoop(elapsed, remain)
  107. if gameRunning then
  108. remain = remain/1000
  109. if remain < 0 then
  110. remain = 100
  111. newMap()
  112. end
  113. else
  114. if winTime then
  115. if winTime > os.time()-30000 then
  116. for i = 0, 2 do
  117. defaultEffect(9, {11, 9, 0, 13}, math.random(800), math.random(400), 80)
  118. end
  119. else
  120. winTime = false
  121. ui.removeTextArea(20)
  122. ui.removeTextArea(21)
  123. ui.removeTextArea(22)
  124. displayTeams()
  125. teams = {
  126. [1] = {},
  127. [2] = {},
  128. }
  129. points = {
  130. [1] = 0,
  131. [2] = 0,
  132. }
  133. playersInGame = {}
  134. end
  135. end
  136. end
  137. end
  138.  
  139. function eventChatCommand(player, command)
  140. if player:lower() == ADMINISTRADOR:lower() then
  141. args = string.split(command, " ")
  142. if args[1] == "time1" then
  143. table.remove(args, 1)
  144. teams[1] = {}
  145. points[1] = 0
  146. for index, player in pairs(args) do
  147. table.insert(teams[1], player)
  148. playersInGame[player] = true
  149. end
  150. displayTeams()
  151.  
  152. elseif args[1] == "time2" then
  153. table.remove(args, 1)
  154. teams[2] = {}
  155. points[2] = 0
  156. for index, player in pairs(args) do
  157. table.insert(teams[2], player)
  158. playersInGame[player] = true
  159. end
  160. displayTeams()
  161.  
  162. elseif args[1] == "score" then
  163. if args[2] and args[3] then
  164. local team = tonumber(args[2]:match("team(%d+)") or 0)
  165. if team > 0 and team < 3 then
  166. local newScore = tonumber(args[3]) or points[team]
  167. points[team] = newScore
  168. displayScore()
  169. end
  170. end
  171. elseif args[1] == "np" then
  172. if args[2] then
  173. table.insert(queue, args[2])
  174. end
  175. end
  176. end
  177. end
  178.  
  179. function eventNewGame()
  180. if gameRunning then
  181. isfirst = false
  182. for i, p in pairs(teams[1]) do
  183. tfm.exec.setNameColor(p, "0-"..colors[1])
  184. end
  185. for i, p in pairs(teams[2]) do
  186. tfm.exec.setNameColor(p, "0-"..colors[2])
  187. end
  188. displayScore()
  189. end
  190. end
  191.  
  192. function displayScore()
  193. ui.addTextArea(17, string.format("<p align='center'><font size='23' color='#0100FF'>%s Time1#-#Time2 %s", points[1], points[2]), nil, 0, 21, 800, 30, 0, 0, 0, true)
  194. ui.addTextArea(18, string.format("<p align='center'><font size='23' color='#0100FF'>%s Time1#-#Time2 %s", points[1], points[2]), nil, 1, 20, 800, 30, 0, 0, 0, true)
  195. ui.addTextArea(19, string.format("<p align='center'><font size='23'><font color='#%s'>%s<N> Time1#-#Time2 <font color='#%s'>%s", colors[1], points[1], colors[2], points[2]), nil, 0, 20, 800, 30, 0, 0, 0, true)
  196. end
  197.  
  198. function displayTeams()
  199. ui.addTextArea(1, "Time 1", nil, 186, 94, 104, 24, 0x000000, 0x0022ff, 1, true)
  200. ui.addTextArea(2, "Time 2", nil, 480, 94, 104, 24, 0x000000, 0xff0000, 1, true)
  201. ui.addTextArea(3, "", nil, 384, 86, 4, 260, 0x000000, 0x00ff44, 1, true)
  202. ui.addTextArea(4, "", nil, 188, 140, 166, 198, 0x000000, 0x0022ff, 1, true)
  203. ui.addTextArea(5, "", nil, 418, 142, 166, 198, 0x000000, 0xff0000, 1, true)
  204. ui.addTextArea(11, "<p align='center'><font color='#"..colors[1].."'>"..table.concat(teams[1], "\n"), nil, 188, 142, 162, 194, 0x000000, 0x000000, 1, true)
  205. ui.addTextArea(13, "<p align='center'><font color='#"..colors[2].."'>"..table.concat(teams[2], "\n"), nil, 418, 142, 166, 198,0x000000, 0x000000, 1, true)
  206. ui.addTextArea(16, "<p align='center'><V><a href='event:iniciarJogo'>GO", ADMINISTRADOR, 374, 206, 22, 20, 0x000000, 0x00ff26, 1, true)
  207. end
  208.  
  209. function eventTextAreaCallback(id, player, callback)
  210. if callback == 'iniciarJogo' then
  211. if #teams[2] > 0 and #teams[1] > 0 then
  212. gameRunning = true
  213. for i = 1, 16 do
  214. ui.removeTextArea(i)
  215. end
  216. defaultEffect(9, {9}, 400, 212, 80)
  217. newMap()
  218. end
  219. end
  220. end
  221.  
  222. function string.split(s, pattern, n)
  223. local st = {}
  224. for sb in string.gmatch(s, "[^"..pattern.."]+") do
  225. if not n or n > -1 then
  226. table.insert(st,sb)
  227. else
  228. st[#st] = st[#st]..pattern..sb
  229. end
  230. n = n and n-1 or false
  231. end
  232. return st
  233. end
  234.  
  235. function table.contains(tableT, element)
  236. for _, value in pairs(tableT) do
  237. if value == element then
  238. return true
  239. end
  240. end
  241. return false
  242. end
  243.  
  244. defaultEffect=function(id,p,x,y,rand) -- thanks for the function santah
  245. local minDist = 1
  246. local outerBorder = 20
  247. local maxDist = 30
  248. local totalParticles = rand and 40 or (id == -1 and 35 or 75)
  249. for i = 1, totalParticles do
  250. if rand then
  251. id = p[math.random(#p)]
  252. end
  253. local dist = math.min(math.random(minDist, maxDist), outerBorder)
  254. local angle = math.random(0, 360)
  255. local r = math.rad(angle)
  256. local dx = math.cos(r)
  257. local dy = math.sin(r)
  258. local vx = dist * dx / 10
  259. local vy = dist * dy / 10
  260. local ax = -vx / dist / 15
  261. local ay = (-vy / dist / 15) + 0.05
  262. if id == -1 then
  263. tfm.exec.displayParticle(9, x + dx, y + dy, vx, vy, ax, ay, nil)
  264. tfm.exec.displayParticle(1, x + dx, y + dy, vx, vy, ax, ay, nil)
  265. else
  266. tfm.exec.displayParticle(id, x + dx, y + dy, vx, vy, ax, ay, nil)
  267. end
  268. end
  269. end
  270.  
  271. displayTeams()
  272.  
  273. function eventPlayerDied()
  274. local alive = 0
  275. for k,v in pairs(tfm.get.room.playerList) do
  276. if not v.isDead then
  277. alive = alive+1
  278. end
  279. end
  280. if alive < 2 then
  281. tfm.exec.setGameTime(5)
  282. end
  283. end
  284.  
  285. tfm.exec.disableAutoShaman()
  286. tfm.exec.disableAutoNewGame()
  287. tfm.exec.disableAutoTimeLeft()
  288.  
  289. local ADMINISTRADOR = "Xlyjc" -- CHANGE TO YOUR NICKNAME, SO YOU WILL BE GAME ADMIN
  290. local WINS = 10 -- POINTS TO WIN THE GAME
  291. system.disableChatCommandDisplay("np", true)
  292.  
  293. --[[
  294. After running the script, use the command !team1 Players and !team2 Players to set both players in the specified team
  295. Then you just need to press GO!
  296. Type !np @mapcode to run the next map.
  297. Type !score team1/team2 number to change its score.
  298. ]]
  299.  
  300. local teams = {
  301. [1] = {},
  302. [2] = {},
  303. }
  304. local points = {
  305. [1] = 0,
  306. [2] = 0,
  307. }
  308. local isfirst = false
  309. local gameRunning = false
  310. local winTime = false
  311. local playersInGame = {}
  312. local maps = {
  313. 114122, 116630, 148424, 150692, 156510, 165843, 166705, 180191, 180274, 180619, 196433, 198715, 208058, 208162, 209708, 212542, 213697, 217900, 223986, 226883, 227851, 229830, 231905, 232451, 232791, 236146, 239826, 239880, 241211, 242708, 245223, 246790, 255542, 258717, 260377, 261720, 266930, 271523, 277731, 281730, 286333, 287268, 299002, 299971, 305677, 308694, 308992, 309029, 314159, 315801, 317754, 323085, 323366, 332210, 332290, 339896, 340069, 341239, 343971, 344865, 345257, 348801, 349140, 352381, 355957, 356982, 357328, 359521, 363638, 365464, 365652, 367520, 381569, 381669, 386029, 391693, 391831, 393851, 401778, 405295, 405955, 410813, 412657, 414460, 414899, 416015, 418293, 418658, 419374, 421717, 423672, 424795, 425030, 425600, 429822, 429897, 430145, 431142, 431887, 434887, 445167, 447556, 470727, 471053, 477370, 499687, 501711, 504409, 505109, 507325, 508106, 508796, 509082, 512927, 514982, 531569, 536235, 563484, 571512, 594883, 595447, 606723, 611320, 616433, 664949, 694900, 737841, 813156, 849224, 982242, 1015582, 1033170, 1051384, 1058681, 1142116, 1195842, 1208798, 1214182, 1216253, 1255148, 1311059, 1364063, 1375345, 1448760, 1506007, 1512355, 1538895, 1601492, 1608638, 1619934, 1654841, 1663380, 1663415, 1689382, 1702169, 1724289, 1749434, 1768347, 1787232, 1813728, 1851968, 1856349, 1862823, 1927270, 1951856, 1956002, 1964752, 2012147, 2030343, 2070768, 2134537, 2141379, 2150335, 2221510, 2245005, 2331474, 2369254, 2683170, 2726034, 2796001, 2813487, 2816067, 3008155, 3156569, 3213562, 3444803, 3518418, 3537419, 3548376, 3548406, 3572407, 3575034, 3575108, 3620542, 3638794, 3654416, 3669435, 3676555, 3680223, 3685382, 3688419, 3700684, 3705931, 3716560, 3821104, 3889414, 4000001, 4234556, 4645670, 4707191, 4815404, 4911122, 4915220, 4946442, 5000090, 5024682, 5030579, 5032745, 5272513, 5346212, 5349806, 5408572, 5452432, 5495901, 5557858, 5590554, 5591416, 5712914, 5805021, 5813480, 5813783, 5861874, 5886041, 5972342, 6069526, 6112855, 6114810, 6172897, 6226519, 6276662, 6300594
  314. }
  315. local colors = {
  316. [1] = "32FF00",
  317. [2] = "FFF500"
  318. }
  319. local queue = {}
  320.  
  321. function newMap()
  322. local mapcode = maps[math.random(#maps)]
  323. if #queue > 0 then
  324. mapcode = queue[1]
  325. table.remove(queue, 1)
  326. end
  327. tfm.exec.newGame(mapcode)
  328. for player, data in pairs(tfm.get.room.playerList) do
  329. if not playersInGame[player] then
  330. tfm.exec.killPlayer(player)
  331. end
  332. end
  333. tfm.exec.setGameTime(60)
  334. end
  335.  
  336. function eventPlayerWon(player)
  337. if not isfirst then
  338. isfirst = true
  339. tfm.exec.setGameTime(5)
  340. if table.contains(teams[1], player) then
  341. tfm.exec.setGameTime(5)
  342. for i = 0, 3 do
  343. defaultEffect(9, {13}, math.random(800), math.random(400), 20)
  344. end
  345. points[1] = points[1]+1
  346. elseif table.contains(teams[2], player) then
  347. tfm.exec.setGameTime(5)
  348. for i = 0, 3 do
  349. defaultEffect(9, {9}, math.random(800), math.random(400), 20)
  350. end
  351. points[2] = points[2]+1
  352. else
  353. isfirst = false
  354. end
  355. winner = false
  356. if points[1] >= WINS then
  357. winner = 1
  358. elseif points[2] >= WINS then
  359. winner = 2
  360. end
  361. if winner then
  362. gameRunning = false
  363. winTime = os.time()
  364. ui.addTextArea(20, string.format("<p align='center'><font size='37' color='#000000'>O time %s ganhou!", winner), nil, 0, 171, 800, 500, 0, 0, 0, true)
  365. ui.addTextArea(21, string.format("<p align='center'><font size='37' color='#FFFFFF'>O time %s ganhou!", winner), nil, 1, 170, 800, 500, 0, 0, 0, true)
  366. ui.addTextArea(22, string.format("<p align='center'><font size='37' color='#%s'>O time %s ganhou!", colors[winner], winner), nil, 1, 170, 800, 500, 0, 0, 0, true)
  367. end
  368. displayScore()
  369. end
  370. end
  371.  
  372. function eventLoop(elapsed, remain)
  373. if gameRunning then
  374. remain = remain/1000
  375. if remain < 0 then
  376. remain = 100
  377. newMap()
  378. end
  379. else
  380. if winTime then
  381. if winTime > os.time()-30000 then
  382. for i = 0, 2 do
  383. defaultEffect(9, {11, 9, 0, 13}, math.random(800), math.random(400), 80)
  384. end
  385. else
  386. winTime = false
  387. ui.removeTextArea(20)
  388. ui.removeTextArea(21)
  389. ui.removeTextArea(22)
  390. displayTeams()
  391. teams = {
  392. [1] = {},
  393. [2] = {},
  394. }
  395. points = {
  396. [1] = 0,
  397. [2] = 0,
  398. }
  399. playersInGame = {}
  400. end
  401. end
  402. end
  403. end
  404.  
  405. function eventChatCommand(player, command)
  406. if player:lower() == ADMINISTRADOR:lower() then
  407. args = string.split(command, " ")
  408. if args[1] == "team1" then
  409. table.remove(args, 1)
  410. teams[1] = {}
  411. points[1] = 0
  412. for index, player in pairs(args) do
  413. table.insert(teams[1], player)
  414. playersInGame[player] = true
  415. end
  416. displayTeams()
  417.  
  418. elseif args[1] == "team2" then
  419. table.remove(args, 1)
  420. teams[2] = {}
  421. points[2] = 0
  422. for index, player in pairs(args) do
  423. table.insert(teams[2], player)
  424. playersInGame[player] = true
  425. end
  426. displayTeams()
  427.  
  428. elseif args[1] == "score" then
  429. if args[2] and args[3] then
  430. local team = tonumber(args[2]:match("team(%d+)") or 0)
  431. if team > 0 and team < 3 then
  432. local newScore = tonumber(args[3]) or points[team]
  433. points[team] = newScore
  434. displayScore()
  435. end
  436. end
  437. elseif args[1] == "np" then
  438. if args[2] then
  439. table.insert(queue, args[2])
  440. end
  441. end
  442. end
  443. end
  444.  
  445. function eventNewGame()
  446. if gameRunning then
  447. isfirst = false
  448. for i, p in pairs(teams[1]) do
  449. tfm.exec.setNameColor(p, "0-"..colors[1])
  450. end
  451. for i, p in pairs(teams[2]) do
  452. tfm.exec.setNameColor(p, "0-"..colors[2])
  453. end
  454. displayScore()
  455. end
  456. end
  457.  
  458. function displayScore()
  459. ui.addTextArea(17, string.format("<p align='center'><font size='23' color='#0100FF'>%s Time1#-#Time2 %s", points[1], points[2]), nil, 0, 21, 800, 30, 0, 0, 0, true)
  460. ui.addTextArea(18, string.format("<p align='center'><font size='23' color='#0100FF'>%s Time1#-#Time2 %s", points[1], points[2]), nil, 1, 20, 800, 30, 0, 0, 0, true)
  461. ui.addTextArea(19, string.format("<p align='center'><font size='23'><font color='#%s'>%s<N> Time1#-#Time2 <font color='#%s'>%s", colors[1], points[1], colors[2], points[2]), nil, 0, 20, 800, 30, 0, 0, 0, true)
  462. end
  463.  
  464. function displayTeams()
  465. ui.addTextArea(1, "Time 1", nil, 186, 94, 104, 24, 0x000000, 0x0022ff, 1, true)
  466. ui.addTextArea(2, "Time 2", nil, 480, 94, 104, 24, 0x000000, 0xff0000, 1, true)
  467. ui.addTextArea(3, "", nil, 384, 86, 4, 260, 0x000000, 0x00ff44, 1, true)
  468. ui.addTextArea(4, "", nil, 188, 140, 166, 198, 0x000000, 0x0022ff, 1, true)
  469. ui.addTextArea(14, "Criador :", nil, 316, 96, 54, 20, 0x9900ff, 0x000000, 1, true)
  470. ui.addTextArea(15, "Xlyjc\n", nil, 402, 96, 54, 20, 0x9900ff, 0x000000, 1, true)
  471. ui.addTextArea(5, "", nil, 418, 142, 166, 198, 0x000000, 0xff0000, 1, true)
  472. ui.addTextArea(11, "<p align='center'><font color='#"..colors[1].."'>"..table.concat(teams[1], "\n"), nil, 188, 142, 162, 194, 0x000000, 0x000000, 1, true)
  473. ui.addTextArea(13, "<p align='center'><font color='#"..colors[2].."'>"..table.concat(teams[2], "\n"), nil, 418, 142, 166, 198,0x000000, 0x000000, 1, true)
  474. ui.addTextArea(16, "<p align='center'><V><a href='event:iniciarJogo'>GO", ADMINISTRADOR, 374, 206, 22, 20, 0x000000, 0x00ff26, 1, true)
  475. end
  476.  
  477. function eventTextAreaCallback(id, player, callback)
  478. if callback == 'iniciarJogo' then
  479. if #teams[2] > 0 and #teams[1] > 0 then
  480. gameRunning = true
  481. for i = 1, 16 do
  482. ui.removeTextArea(i)
  483. end
  484. defaultEffect(9, {9}, 400, 212, 80)
  485. newMap()
  486. end
  487. end
  488. end
  489.  
  490. function string.split(s, pattern, n)
  491. local st = {}
  492. for sb in string.gmatch(s, "[^"..pattern.."]+") do
  493. if not n or n > -1 then
  494. table.insert(st,sb)
  495. else
  496. st[#st] = st[#st]..pattern..sb
  497. end
  498. n = n and n-1 or false
  499. end
  500. return st
  501. end
  502.  
  503. function table.contains(tableT, element)
  504. for _, value in pairs(tableT) do
  505. if value == element then
  506. return true
  507. end
  508. end
  509. return false
  510. end
  511.  
  512. defaultEffect=function(id,p,x,y,rand) -- thanks for the function santah
  513. local minDist = 1
  514. local outerBorder = 20
  515. local maxDist = 30
  516. local totalParticles = rand and 40 or (id == -1 and 35 or 75)
  517. for i = 1, totalParticles do
  518. if rand then
  519. id = p[math.random(#p)]
  520. end
  521. local dist = math.min(math.random(minDist, maxDist), outerBorder)
  522. local angle = math.random(0, 360)
  523. local r = math.rad(angle)
  524. local dx = math.cos(r)
  525. local dy = math.sin(r)
  526. local vx = dist * dx / 10
  527. local vy = dist * dy / 10
  528. local ax = -vx / dist / 15
  529. local ay = (-vy / dist / 15) + 0.05
  530. if id == -1 then
  531. tfm.exec.displayParticle(9, x + dx, y + dy, vx, vy, ax, ay, nil)
  532. tfm.exec.displayParticle(1, x + dx, y + dy, vx, vy, ax, ay, nil)
  533. else
  534. tfm.exec.displayParticle(id, x + dx, y + dy, vx, vy, ax, ay, nil)
  535. end
  536. end
  537. end
  538.  
  539. displayTeams()
  540.  
  541. function eventPlayerDied()
  542. local alive = 0
  543. for k,v in pairs(tfm.get.room.playerList) do
  544. if not v.isDead then
  545. alive = alive+1
  546. end
  547. end
  548. if alive < 2 then
  549. tfm.exec.setGameTime(5)
  550. end
  551. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement