Advertisement
Guest User

RACING LUAAAA

a guest
Aug 20th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.63 KB | None | 0 0
  1. ---
  2. -- RACING 3VS3
  3. -- Escrito por Eshkation 23/06/2016
  4. -- the cake is not a lie
  5. ---
  6.  
  7. tfm.exec.disableAutoShaman()
  8. tfm.exec.disableAutoNewGame()
  9. tfm.exec.disableAutoTimeLeft()
  10.  
  11. local ADMINISTRADOR = "Eliterecon#0000" -- CHANGE TO YOUR NICKNAME, SO YOU WILL BE GAME ADMIN
  12. local WINS = 10 -- POINTS TO WIN THE GAME
  13. system.disableChatCommandDisplay("np", true)
  14.  
  15. --[[
  16. After running the script, use the command !team1 Players and !team2 Players to set both players in the specified team
  17. Then you just need to press GO!
  18. Type !np @mapcode to run the next map.
  19. Type !score team1/team2 number to change its score.
  20. ]]
  21.  
  22. local teams = {
  23. [1] = {},
  24. [2] = {},
  25. }
  26. local points = {
  27. [1] = 0,
  28. [2] = 0,
  29. }
  30. local isfirst = false
  31. local gameRunning = false
  32. local winTime = false
  33. local playersInGame = {}
  34. local maps = {
  35. 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
  36. }
  37. local colors = {
  38. [1] = "ff6347",
  39. [2] = "19b5fe"
  40. }
  41. local queue = {}
  42.  
  43. function newMap()
  44. local mapcode = maps[math.random(#maps)]
  45. if #queue > 0 then
  46. mapcode = queue[1]
  47. table.remove(queue, 1)
  48. end
  49. tfm.exec.newGame(mapcode)
  50. for player, data in pairs(tfm.get.room.playerList) do
  51. if not playersInGame[player] then
  52. tfm.exec.killPlayer(player)
  53. end
  54. end
  55. tfm.exec.setGameTime(60)
  56. end
  57.  
  58. function eventPlayerWon(player)
  59. if not isfirst then
  60. isfirst = true
  61. --tfm.exec.setGameTime(5)
  62. if table.contains(teams[1], player) then
  63. --tfm.exec.setGameTime(5)
  64. for i = 0, 3 do
  65. defaultEffect(9, {13}, math.random(800), math.random(400), 20)
  66. end
  67. points[1] = points[1]+1
  68. elseif table.contains(teams[2], player) then
  69. --tfm.exec.setGameTime(5)
  70. for i = 0, 3 do
  71. defaultEffect(9, {9}, math.random(800), math.random(400), 20)
  72. end
  73. points[2] = points[2]+1
  74. else
  75. isfirst = false
  76. end
  77. winner = false
  78. if points[1] >= WINS then
  79. winner = 1
  80. elseif points[2] >= WINS then
  81. winner = 2
  82. end
  83. if winner then
  84. gameRunning = false
  85. winTime = os.time()
  86. ui.addTextArea(20, string.format("<p align='center'><font size='37' color='#000000'>TEAM %s IS THE WINNER!", winner), nil, 0, 171, 800, 500, 0, 0, 0, true)
  87. ui.addTextArea(21, string.format("<p align='center'><font size='37' color='#000000'>TEAM %s IS THE WINNER!", winner), nil, 1, 170, 800, 500, 0, 0, 0, true)
  88. ui.addTextArea(22, string.format("<p align='center'><font size='37' color='#%s'>TEAM %s IS THE WINNER!", colors[winner], winner), nil, 1, 170, 800, 500, 0, 0, 0, true)
  89. end
  90. displayScore()
  91. end
  92. end
  93.  
  94. function eventLoop(elapsed, remain)
  95. if gameRunning then
  96. remain = remain/1000
  97. if remain < 0 then
  98. remain = 100
  99. newMap()
  100. end
  101. else
  102. if winTime then
  103. if winTime > os.time()-30000 then
  104. for i = 0, 2 do
  105. defaultEffect(9, {11, 9, 0, 13}, math.random(800), math.random(400), 80)
  106. end
  107. else
  108. winTime = false
  109. ui.removeTextArea(20)
  110. ui.removeTextArea(21)
  111. ui.removeTextArea(22)
  112. displayTeams()
  113. teams = {
  114. [1] = {},
  115. [2] = {},
  116. }
  117. points = {
  118. [1] = 0,
  119. [2] = 0,
  120. }
  121. playersInGame = {}
  122. end
  123. end
  124. end
  125. end
  126.  
  127. function eventChatCommand(player, command)
  128. if player:lower() == ADMINISTRADOR:lower() then
  129. args = string.split(command, " ")
  130. if args[1] == "team1" then
  131. table.remove(args, 1)
  132. teams[1] = {}
  133. points[1] = 0
  134. for index, player in pairs(args) do
  135. table.insert(teams[1], player)
  136. playersInGame[player] = true
  137. end
  138. displayTeams()
  139.  
  140. elseif args[1] == "team2" then
  141. table.remove(args, 1)
  142. teams[2] = {}
  143. points[2] = 0
  144. for index, player in pairs(args) do
  145. table.insert(teams[2], player)
  146. playersInGame[player] = true
  147. end
  148. displayTeams()
  149.  
  150. elseif args[1] == "score" then
  151. if args[2] and args[3] then
  152. local team = tonumber(args[2]:match("team(%d+)") or 0)
  153. if team > 0 and team < 3 then
  154. local newScore = tonumber(args[3]) or points[team]
  155. points[team] = newScore
  156. displayScore()
  157. end
  158. end
  159. elseif args[1] == "np" then
  160. if args[2] then
  161. table.insert(queue, args[2])
  162. end
  163. end
  164. end
  165. end
  166.  
  167. function eventNewGame()
  168. if gameRunning then
  169. isfirst = false
  170. for i, p in pairs(teams[1]) do
  171. tfm.exec.setNameColor(p, "0x"..colors[1])
  172. end
  173. for i, p in pairs(teams[2]) do
  174. tfm.exec.setNameColor(p, "0x"..colors[2])
  175. end
  176. displayScore()
  177. end
  178. end
  179.  
  180. function displayScore()
  181. ui.addTextArea(17, string.format("<p align='center'><font size='23' color='#000000'>%s x %s", points[1], points[2]), nil, 0, 21, 800, 30, 0, 0, 0, true)
  182. ui.addTextArea(18, string.format("<p align='center'><font size='23' color='#000000'>%s x %s", points[1], points[2]), nil, 1, 20, 800, 30, 0, 0, 0, true)
  183. ui.addTextArea(19, string.format("<p align='center'><font size='23'><font color='#%s'>%s<N> x <font color='#%s'>%s", colors[1], points[1], colors[2], points[2]), nil, 0, 20, 800, 30, 0, 0, 0, true)
  184. end
  185.  
  186. function displayTeams()
  187. ui.addTextArea(1, "", nil, 199, 69, 400, 260, 0x5A7A8B, 0x5A7A8B, 1, true)
  188. ui.addTextArea(2, "", nil, 201, 71, 400, 260, 0x0E1417, 0x0E1417, 1, true)
  189. ui.addTextArea(3, "", nil, 200, 70, 400, 260, 0x324650, 0x324650, 1, true)
  190. ui.addTextArea(4, "", nil, 209, 79, 142, 22, 0x324650, 0x5A7A8B, 1, true)
  191. ui.addTextArea(5, "<p align='center'><V>Team 1", nil, 210, 80, 140, 20, 0x324650, 0x324650, 1, true)
  192. ui.addTextArea(6, "", nil, 449, 79, 142, 22, 0x324650, 0x5A7A8B, 1, true)
  193. ui.addTextArea(7, "<p align='center'><V>Team 2", nil, 450, 80, 140, 20, 0x324650, 0x324650, 1, true)
  194. ui.addTextArea(8, "<p align='center'><font color='#5A7A8B'>|</font>", nil, 210, 102, 140, 200, 0, 0, 0, true)
  195. ui.addTextArea(9, "<p align='center'><font color='#5A7A8B'>|</font>", nil, 450, 102, 140, 200, 0, 0, 0, true)
  196. ui.addTextArea(10, "", nil, 209, 120, 140, 200, 0x5A7A8B, 0x5A7A8B, 1, true)
  197. ui.addTextArea(11, "<p align='center'><font color='#"..colors[1].."'>"..table.concat(teams[1], "\n"), nil, 210, 121, 138, 198, 0x324650, 0x324650, 1, true)
  198. ui.addTextArea(12, "", nil, 451, 120, 140, 200, 0x5A7A8B, 0x5A7A8B, 1, true)
  199. ui.addTextArea(13, "<p align='center'><font color='#"..colors[2].."'>"..table.concat(teams[2], "\n"), nil, 452, 121, 138, 198, 0x324650, 0x324650, 1, true)
  200. ui.addTextArea(14, "<p align='center'><font color='#5A7A8B'>____ ____</font>", nil, 330, 200, 140, 200, 0, 0, 0, true)
  201. ui.addTextArea(15, "", nil, 380, 202, 40, 20, 0x5A7A8B, 0x5A7A8B, 1, true)
  202. ui.addTextArea(16, "<p align='center'><V>VS", nil, 381, 203, 38, 18, 0x324650, 0x324650, 1, true)
  203. ui.addTextArea(16, "<p align='center'><V><a href='event:iniciarJogo'>GO", ADMINISTRADOR, 381, 203, 38, 18, 0x324650, 0x324650, 1, true)
  204. end
  205.  
  206. function eventTextAreaCallback(id, player, callback)
  207. if callback == 'iniciarJogo' then
  208. if #teams[2] > 0 and #teams[1] > 0 then
  209. gameRunning = true
  210. for i = 1, 16 do
  211. ui.removeTextArea(i)
  212. end
  213. defaultEffect(9, {9}, 400, 212, 80)
  214. newMap()
  215. end
  216. end
  217. end
  218.  
  219. function string.split(s, pattern, n)
  220. local st = {}
  221. for sb in string.gmatch(s, "[^"..pattern.."]+") do
  222. if not n or n > -1 then
  223. table.insert(st,sb)
  224. else
  225. st[#st] = st[#st]..pattern..sb
  226. end
  227. n = n and n-1 or false
  228. end
  229. return st
  230. end
  231.  
  232. function table.contains(tableT, element)
  233. for _, value in pairs(tableT) do
  234. if value == element then
  235. return true
  236. end
  237. end
  238. return false
  239. end
  240.  
  241. defaultEffect=function(id,p,x,y,rand) -- thanks for the function santah
  242. local minDist = 1
  243. local outerBorder = 20
  244. local maxDist = 30
  245. local totalParticles = rand and 40 or (id == -1 and 35 or 75)
  246. for i = 1, totalParticles do
  247. if rand then
  248. id = p[math.random(#p)]
  249. end
  250. local dist = math.min(math.random(minDist, maxDist), outerBorder)
  251. local angle = math.random(0, 360)
  252. local r = math.rad(angle)
  253. local dx = math.cos(r)
  254. local dy = math.sin(r)
  255. local vx = dist * dx / 10
  256. local vy = dist * dy / 10
  257. local ax = -vx / dist / 15
  258. local ay = (-vy / dist / 15) + 0.05
  259. if id == -1 then
  260. tfm.exec.displayParticle(9, x + dx, y + dy, vx, vy, ax, ay, nil)
  261. tfm.exec.displayParticle(1, x + dx, y + dy, vx, vy, ax, ay, nil)
  262. else
  263. tfm.exec.displayParticle(id, x + dx, y + dy, vx, vy, ax, ay, nil)
  264. end
  265. end
  266. end
  267.  
  268. displayTeams()
  269.  
  270. function eventPlayerDied()
  271. local alive = 0
  272. for k,v in pairs(tfm.get.room.playerList) do
  273. if not v.isDead then
  274. alive = alive+1
  275. end
  276. end
  277. if alive < 2 then
  278. --tfm.exec.setGameTime(5)
  279. end
  280. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement