Advertisement
alditojeje

Untitled

Apr 1st, 2020
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.03 KB | None | 0 0
  1.  
  2. tfm.exec.disableAutoScore(true)
  3. tfm.exec.disableAutoShaman(true)
  4. tfm.exec.disableAutoTimeLeft(true)
  5. tfm.exec.disableAutoNewGame(true)
  6. tfm.exec.disableAfkDeath(true)
  7. tfm.exec.disablePhysicalConsumables(true)
  8.  
  9. local removerText = {}
  10. local jugadorCantidad = {}
  11. local lugares = {}
  12. tiempoJugado = 0
  13. local playerInfo = {verTimes = {}, alreadyRespawn = {}}
  14. local juego_activo = false
  15. local teams = {Team1 = {}, Team2 = {}}
  16. local puntos = {team1 = 0, team2 = 0}
  17. local respawnPlayer = {}
  18. local times = {}
  19. local bestTimes = {}
  20. local ez_maps = {
  21. 113156, 124000, 149422, 149451, 150651, 150664, 151655, 152260, 152733,
  22. 153996, 155480, 155606, 155611, 155628, 155765, 156720, 157203, 157805,
  23. 157960, 158345, 158417, 158909, 159187, 159298, 159932, 160841, 161023,
  24. 161434, 162482, 163159, 163172, 163506, 163531, 163596, 164544, 164916,
  25. 165186, 166032, 177652, 166056, 166271, 166333, 166361, 166430, 166805,
  26. 167075, 167903, 168204, 167903, 168754, 169059, 169076, 169110, 169139,
  27. 171148, 171480, 171482, 171776, 172501, 172512, 172520, 172547, 172605,
  28. 172621, 172951, 172976, 173623, 173816, 174223, 175204, 175280, 176253,
  29. 176507, 176710, 176729, 179005, 179488, 179492, 179807, 180801, 182370,
  30. 182769, 183139, 183141, 184648, 184817, 184868, 185289, 185428, 185529,
  31. 185529, 185873, 185887, 186066, 189819, 190646, 190996, 191177, 191203,
  32. 191205, 191443, 191642, 192158, 192255, 192959, 193662, 195116, 195672,
  33. 197229, 198988, 199210, 199710, 199826, 201000, 202574, 203664, 204488,
  34. 204647, 205240, 205506, 206396, 208056, 208373, 232675, 208653, 208940,
  35. 209848, 213752, 213755, 213874, 214631, 214755, 216173, 217261, 220352,
  36. 222377, 222910, 223947, 2795201, 225744, 226266, 227093, 230588, 231137,
  37. 231921, 232469, 232678, 235037, 236768, 237091, 242291, 250153, 254785,
  38. 257218, 257324, 257715, 258192258908, 259319, 261298, 261814, 263819,
  39. 263926, 264091, 268915, 270143, 270924, 271193, 271411, 159145, 272402,
  40. 272518, 272689, 277427, 277513, 514311, 277824, 279337, 281948, 282584,
  41. 284134, 286254, 289865, 2574744, 295465, 295630, 295932, 297442, 299942,
  42. 299983, 301610, 302080, 303151, 303939, 304861, 305567, 305614, 305820,
  43. 306365, 306384, 313216, 314743, 315666, 315800, 316012, 318129, 319443,
  44. 320483, 320626, 322582, 327354, 329318, 329571, 330933, 330967, 331344,
  45. 331988, 332130, 332906, 333002, 336305, 337644, 342035, 343456, 354984,
  46. 361500, 365061, 368839, 372419, 392240, 393426, 394132, 395216, 395310,
  47. 395961, 397467, 397469, 399364, 401630, 403755, 403940, 408577, 408643,
  48. 410040, 410045, 412467, 412913, 419335, 419369, 419635, 420877, 422981,
  49. 423311, 424604, 424685, 424900, 425884, 431433, 431749, 432501, 435812,
  50. 438333, 438364, 439092, 444589, 447805, 449496, 454049, 455271, 457726,
  51. 458528, 460961, 467137, 476706, 478236, 492222, 492399, 496610, 496886,
  52. 497965, 499986, 500690, 500748, 500894, 504485, 505619, 506032, 506613,
  53. 506940, 510996, 511136, 512887, 523270, 528032, 531084, 541223, 541693,
  54. 541729, 543010, 551317, 556841, 380516, 557066, 560583, 562897, 563436,
  55. 564198, 568122, 571683, 586901, 592189, 593164, 593431, 593530, 596239,
  56. 605255, 608368, 618999, 684566, 692650, 692740, 783547, 801683, 815336,
  57. 834297, 842019, 842167, 868262, 898934, 912356, 919484, 976944, 1000006,
  58. 1004622, 1014313, 1018394, 1157281, 1162831, 1164086, 1242584, 1255359,
  59. 536905, 1265789, 1266330, 1383297, 1384078, 1413528, 1427980, 1435902,
  60. 1494499, 1503203, 1526894, 1531604, 1540221, 1580356, 1580835, 1593066,
  61. 1595965, 1615753, 1615949, 1647131, 1678634, 1722755, 1733211, 1788490,
  62. 1807217, 1809410, 2040569, 2130169, 2311703, 2423300, 256899, 2520540,
  63. 2636519, 2738370, 2794566, 2989803, 3136410, 3199998, 3242049, 3908151,
  64. 4067327, 4445580, 330841, 2176211, 373105, 375455, 376704, 378704, 2252731,
  65. 1646448, 4488666, 698992, 3888888, 4627777, 528782, 192519, 159691, 158053,
  66. 3907267, 3848147, 2692883, 5517891, 7016000, 215933, 343875, 507884, 597348,
  67. 720672, 1951944, 2850177, 2918822, 3043779, 3076903, 3200001, 3483300,
  68. 3527399, 3937567, 4854539, 1893451, 5534007 ,394125,3734989,3734996,3734998,3866660,320607,3089270,170483,1852910,2998268,658960,293306,157098,178297,328351,182681,176614,229802,233971,237188,239698,242351,245908,247311,252142,255561,255776,256886,258801,259029,261784,262533,263730,265652,267589,267973,268668,268882,270650,273903,275897,277641,279502,292809,7023000,294249,295620,296518,297465}
  69. local med_maps = {
  70. 6892200, 6000050, 157004, 158345, 158417, 163094, 7288650, 3473925, 192560,
  71. 216171, 2795201, 263819, 4617716, 590775, 306655, 307324, 327743, 2914456,
  72. 372255, 391924, 392240, 397478, 3133917, 2932238, 438364, 482791, 500000,
  73. 522719, 552986, 557074, 560583, 587501, 2242899, 612415, 721319, 722837,
  74. 562897, 563436, 564198, 568122, 571683, 574183, 575497, 584783, 560526,
  75. 729863, 374995, 758595, 881158, 886744, 970919, 1046877, 1066607, 1130256,
  76. 1156092, 1226207, 1301649, 1303323, 1323048, 1333846, 1384078, 1410539,
  77. 1620703, 1955745, 1989803, 1990413, 2024960, 2178800, 2329940, 2416969,
  78. 2469365, 2788517, 2846829, 3038589, 3668888, 3690269, 3988424, 549666,
  79. 4114521, 1523082, 5960814, 1256085, 6137767, 4890068, 557132, 357892,
  80. 273373, 225484, 5000126, 6533602, 6574593, 293559, 6696038, 6600067,
  81. 4763378, 1601992, 4770120, 6774534, 4877895, 425533, 556973, 4769901,
  82. 406154, 6642996, 6675248, 223174, 6999009, 4895345, 655207, 823329, 2082776,
  83. 2309030, 2963166, 2999994, 3828508, 3976977, 4107909, 4632975, 5092739,
  84. 6593495, 6727980, 2803483, 4237910, 4538472, 3521460, 2128560, 3493490,
  85. 4362335, 2294519, 6000033, 6284671, 7196861, 7261219, 6640663, 7306627,
  86. 7324922, 6000044, 7110102, 7370291, 6931020, 7290999, 7000002, 7512725,
  87. 7598733, 6462982,3707630,1737800,3734988,3734990,3747520,3750360,3759157,3767893,3779861,3850000,3799357,6722315,3815568,3826546,3849999,3860578,3866663,3920916,355336,5263927,3958217,5342889,3964892,3969628,6304911,3976766,3999991,3999992,3999997,4000007,4000008,4000009,4027263,4241333,4039451,4058168,4093488,7024409,4121359,4333895,5132197,4317592,5134116,7091488,1972688,4337732,1568331,4295473,4234558,7005221,4249695,4413656,3820501,3999979,3939000,4484685,6609034,6022675,4644584,4311255,4697673,4000000,3295954,4365527,4313858,3530999,2758747,4594304,322649,3999110,3838020,1923584,3846632,4720851,3734984,1551020,621850,4506542,4948659,315283,3311534,4822672,6621953,6827739,5008365,5505990,5931069,187478,4000662,2395201,2941840,4948551,3142783,4220381,5473125,2605186,5616777,5761507,4398794,5914063,5706542,5340984,6546598,6045500,293658,4117513,5356911,5284625,6079100,5998000,5758150,5720741,3985463,4660408,3500000,5444444,3984871,219956,6289411,330827,366260,4000010,6041917,7134487,7319472,5933637,6450492,238951,248650,249003,250664,277665,282332,
  88. }
  89. local hard_maps = {
  90. 329200, 2417098, 654894, 1111252, 2514792, 4224188, 290824, 5994088, 2659411,2633917,1603275,1914925,4051345,3895460,4245029,
  91. }
  92. local ultra_maps = {}
  93. local time_map = 363 -- (segundos)
  94. c_ez = 2
  95. c_m = 0
  96. c_h = 0
  97. c_u = 0
  98. local puesto_1 = false
  99. local puesto_2 = false
  100. local puesto_3 = false
  101. local admin = {
  102. ["Blood#3565"] = true,
  103. ["Misterthepro#0000"] = true,
  104. ["Edudekarly#3398"] = true,
  105. ["His#0439"] = true
  106. }
  107.  
  108. local recordsActivos = {}
  109. local mapActual = ""
  110.  
  111. local mejorTiempo = " "
  112. local last_map = false
  113. local time_lobby = 666
  114. local firstMap = true
  115. local estado
  116. local new_map = false
  117. local dificultadMap = ""
  118. local cantidad_f = {}
  119. local name_cant = {}
  120.  
  121. newMap = function ()
  122. puesto_1 = false
  123. puesto_2 = false
  124. puesto_3 = false
  125.  
  126. primero = ""
  127. segundo = ""
  128. tercero = ""
  129.  
  130. for i = 31, 40 do
  131. ui.removeTextArea(i, nil)
  132. end
  133.  
  134. if c_ez == 0 and c_m == 0 and c_h == 0 and c_u == 0 then
  135. addpoints_time(times)
  136.  
  137. if #times >= 1 then
  138. table.insert(bestTimes, {
  139. mapa = times[1].mapa,
  140. time = times[1].time,
  141. name = times[1].name
  142. })
  143. end
  144. last_map = true
  145. end
  146.  
  147. if last_map then
  148. tfm.exec.newGame(7692692)
  149. time_map = 1234567
  150. cantidades_mapa()
  151. cantidades_finales(name_cant)
  152. tfm.exec.setGameTime(time_map)
  153. estadisticasFinales()
  154. -- puntuacion_final()
  155. juego_activo = false
  156.  
  157. elseif not map_bc_actual then
  158. mejorTiempo = " "
  159. times = {}
  160. str = "\n<textformat tabstops='[70, 170, 300]'>"
  161. lugares = {}
  162.  
  163. juego_activo = true
  164. map_bc_actual = true
  165.  
  166. math.randomseed(os.time())
  167. if c_ez ~= 0 then
  168. estado = 1
  169. local map = ez_maps[math.random(#ez_maps)]
  170. tfm.exec.newGame(map)
  171. -- tfm.exec.newGame('#13')
  172. c_ez = c_ez - 1
  173. dificultadMap = "<font color='#00C17C'>Fácil</font>"
  174. elseif c_m ~= 0 then
  175. estado = 2
  176. local map = med_maps[math.random(#med_maps)]
  177. tfm.exec.newGame(map)
  178. c_m = c_m - 1
  179. dificultadMap = "<font color='#EBC244'>Medio</font>"
  180. elseif c_h ~= 0 then
  181. estado = 3
  182. local map = hard_maps[math.random(#hard_maps)]
  183. tfm.exec.newGame(map)
  184. dificultadMap = "<font color='#F93018'>Difícil</font>"
  185. -- print(time_map) --
  186. c_h = c_h - 1
  187.  
  188. elseif c_u ~= 0 then
  189. estado = 4
  190. local map = ultra_maps[math.random(#ultra_maps)]
  191. tfm.exec.newGame(map)
  192. dificultadMap = "<font color='#F93018'>Ultra</font>"
  193. c_u = c_u - 1
  194. -- else
  195. end
  196. for p, v in pairs(tfm.get.room.playerList) do
  197. if jugador_activo(p, lista_A) == false and
  198. jugador_activo(p, lista_B) == false then
  199. tfm.exec.killPlayer(p)
  200. end
  201. end
  202.  
  203. else
  204. juego_activo = true
  205. tfm.exec.newGame(7692692)
  206. -- tfm.exec.setGameTime(7)
  207. map_bc_actual = false
  208.  
  209. addpoints_time(times)
  210.  
  211. recordsLobby()
  212. if #times >= 1 then
  213. table.insert(bestTimes, {
  214. mapa = times[1].mapa,
  215. time = times[1].time,
  216. name = times[1].name
  217. })
  218. end
  219. end
  220. end
  221.  
  222. --function puntuacion_final()
  223.  
  224. --end
  225.  
  226.  
  227. estadisticasFinales = function()
  228.  
  229. -- equipo ganador --
  230. equipoGanador = ""
  231. if puntos.team1 > puntos.team2 then
  232. equipoGanador = "<font color = '#CB546B'>Team Red Wins</font>"
  233. elseif puntos.team1 < puntos.team2 then
  234. equipoGanador = "<font color = '#2F7FCC'>Team Blue Wins</font>"
  235. else
  236. equipoGanador = "<font color='#00C17C'>Empate jajaencerio</font>"
  237. end
  238. -- fin equipo ganador
  239.  
  240. -- mejores tiempos --
  241. mejoresTiempos = "\n<textformat tabstops='[75, 280]'>"
  242. for i, completion in ipairs(bestTimes) do
  243. if jugador_activo(completion.name, teams.Team1) then
  244. jugador = "<font color = '#CB546B'>" .. completion.name .. "</font>"
  245. elseif jugador_activo(completion.name, teams.Team2) then
  246. jugador = "<font color = '#2F7FCC'>" .. completion.name .. "</font>"
  247. end
  248. mejoresTiempos = mejoresTiempos ..
  249. ("<font color='#00C17C'>@" .. completion.mapa ..
  250. '</font>' .. "\t " .. jugador .. '\t ' ..
  251. " <font color='#00C17C'> " .. completion.time ..
  252. 's</font>\n')
  253. end
  254. mejoresTiempos = mejoresTiempos .. '</textformat>'
  255. -- fin mejores tiempos -
  256.  
  257. -- mejor jugador
  258. scoreTop = -1
  259. nombreTop = ""
  260. for name, p in pairs(tfm.get.room.playerList) do
  261. if p.score + 1 > scoreTop then
  262. scoreTop = p.score + 1
  263. nombreTop = name
  264. end
  265. end
  266. if jugador_activo(nombreTop, teams.Team1) then
  267. nombreTop = "<font color = '#CB546B'>" .. nombreTop .. "</font>"
  268. elseif jugador_activo(nombreTop, teams.Team2) then
  269. nombreTop = "<font color = '#2F7FCC'>" .. nombreTop .. "</font>"
  270. end
  271.  
  272. -- fin mejor jugador
  273.  
  274. -- cantidades
  275. jugadorCantidades = "\n<textformat tabstops='[150]'>"
  276. for i, cantidades in ipairs(cantidad_f) do
  277. if jugador_activo(cantidades.nom, teams.Team1) then
  278. jugadorCantidades = jugadorCantidades .. "<font color = '#CB546B'>" .. cantidades.nom .. "\t</font>" .. "<font color='#00C17C'> " .. cantidades.c .. "</font>\n"
  279. elseif jugador_activo(cantidades.nom, teams.Team2) then
  280. jugadorCantidades = jugadorCantidades .."<font color = '#2F7FCC'>" .. cantidades.nom .. "\t</font>" .. "<font color='#00C17C'> " .. cantidades.c .. "</font>\n"
  281. end
  282. end
  283.  
  284. -- fin cantidads
  285.  
  286.  
  287. texto = "<textformat tabstops='[310, 550]'><p align='left'>" .. nombreTop .. " MVP\t" .. equipoGanador .. "\t<font color='#CB546B'><b>Red: " .. puntos.team1 .. "<font color='#2F7FCC'> Blue: " .. puntos.team2
  288.  
  289. ui.addTextArea(31, "<p align='center'><font size ='16' color='#00C17C'><b>Estadísticas Finales\n\n\n\n\n\n\n\n\n\n\n\n" .. texto, nil, 20, 127, 760, 260, 0x1E1E1E, 0x121212, 1, true)
  290. ui.addTextArea(32, "<p align='center'><font size ='15' color='#00C17C'><b>Cantidades Totales</b></font></p>" .. jugadorCantidades, nil, 35, 160, 350, 170, 0x2B2B2B, 0x2B2B2B, 1, true)
  291. ui.addTextArea(33, "<p align='center'><font size ='15' color='#00C17C'><b>Mejores Tiempos</b></font></p>" .. mejoresTiempos, nil, 415, 160, 350, 170, 0x2B2B2B, 0x2B2B2B, 1, true)
  292.  
  293. end
  294.  
  295. eventNewGame = function()
  296. if juego_activo then mapActual = tfm.get.room.xmlMapInfo.mapCode end
  297.  
  298. for name in pairs(tfm.get.room.playerList) do colores(name) end
  299.  
  300. if map_bc_actual or new_map then
  301. ui.removeTextArea(40, player)
  302. ui.removeTextArea(41, player)
  303. tfm.exec.setGameTime(time_map)
  304. else
  305. tfm.exec.setGameTime(time_lobby)
  306. end
  307.  
  308. if firstMap then
  309. firstMap = false
  310. tfm.exec.setGameTime(10000)
  311. end
  312.  
  313. end
  314.  
  315. eventNewPlayer = function(player)
  316. respawnPlayer[player] = os.time()
  317. playerInfo.verTimes[player] = false
  318. teclas(player)
  319. end
  320.  
  321. teclas = function(player)
  322. tfm.exec.bindKeyboard(player, 76, false, true)
  323. tfm.exec.bindKeyboard(player, 46, false, true)
  324. tfm.exec.bindKeyboard(player, 16, false, true)
  325. tfm.exec.bindKeyboard(player, 80, false, true)
  326. end
  327.  
  328. for player in next, tfm.get.room.playerList do
  329. eventNewPlayer(player)
  330. playerInfo.verTimes[player] = false
  331. teclas(player)
  332. end
  333.  
  334. eventPlayerDied = function(player) respawnPlayer[player] = os.time() end
  335.  
  336. setNewMap = function()
  337. math.randomseed(os.time())
  338. if estado == 1 then
  339. local map = ez_maps[math.random(#ez_maps)]
  340. tfm.exec.newGame(map)
  341. elseif estado == 2 then
  342. local map = med_maps[math.random(#med_maps)]
  343. tfm.exec.newGame(map)
  344. elseif estado == 3 then
  345. local map = hard_maps[math.random(#hard_maps)]
  346. tfm.exec.newGame(map)
  347. elseif estado == 4 then
  348. local map = ultra_maps[math.random(#utra_maps)]
  349. tfm.exec.newGame(map)
  350. end
  351. end
  352.  
  353. eventLoop = function(elapsedTime, remaining)
  354. tiempoJugado = elapsedTime
  355. if new_map then
  356. setNewMap()
  357. new_map = false
  358. end
  359.  
  360. if remaining < 500 then newMap() end
  361.  
  362. for i, n in pairs(respawnPlayer) do
  363. if n <= os.time() - 1000 then
  364. lista_A = teams.Team1
  365. lista_B = teams.Team2
  366. if jugador_activo(i, lista_A) or jugador_activo(i, lista_B) then
  367. tfm.exec.respawnPlayer(i)
  368. colores(i)
  369. end
  370. end
  371. end
  372. if juego_activo then
  373. minutos = "0" .. math.floor((remaining / 1000) / 60)
  374. segundos = math.floor(remaining / 1000) % 60
  375. if segundos <= 9 then segundos = "0" .. segundos end
  376. if #times >= 1 then
  377. mejorTiempo = times[1].name .. " " .. times[1].time .. "s"
  378. end
  379.  
  380. for i, n in pairs(removerText) do
  381. if n <= os.time() - 2000 then ui.removeTextArea(69, i) end
  382. end
  383.  
  384. if (time_map == 1234567) then
  385. tfm.exec.setUIMapName(
  386. " <font color='#CB546B'>Red: " ..
  387. puntos.team1 .. "</font>\t|\t<font color='#2F7FCC'> Blue: " ..
  388. puntos.team2 .. "</font>\t|\t" .. "\t\t" .. "\n")
  389. else
  390.  
  391. --[[ barra = dificultadMap .. " <font color='#CB546B'>Red: " ..
  392. puntos.team1 .. "</font>\t|\t<font color='#2F7FCC'> Blue: " ..
  393. puntos.team2 .. "</font>\t|\t" .. minutos .. ":" .. segundos ..
  394. "\t|\t" .. mejorTiempo .. "\n"
  395.  
  396. print(#barra) ]]
  397.  
  398. tfm.exec.setUIMapName(dificultadMap .. " <font color='#CB546B'>Red: " ..
  399. puntos.team1 .. "</font>\t|\t<font color='#2F7FCC'> Blue: " ..
  400. puntos.team2 .. "</font>\t|\t" .. minutos .. ":" .. segundos ..
  401. "\t|\t" .. mejorTiempo .. "\n")
  402. end
  403. end
  404. end
  405.  
  406. eventChatCommand = function(playerName, command)
  407. local args = {}
  408.  
  409. for arg in command:gmatch("[^%s]+") do table.insert(args, arg) end
  410. -- comandos para admins:
  411. if admin[playerName] then
  412. if args[1] == "team1" then -- y sigue con team1
  413. teams.Team1 = {}
  414. local k = 0
  415. for i = 2, #args do -- recorre toda la tabla args
  416. for j = 1, #teams.Team2 do -- recorre toda la tabla teams2
  417. if args[i] == teams.Team2[j] then -- si un elemento de la tabla args conicide con un elento de la tabla teams2
  418. table.remove(teams.Team2, j)
  419. end
  420. end
  421. if not jugador_activo(args[i], teams.Team1) then
  422. k = k + 1
  423. teams.Team1[k] = args[i]
  424. colores(args[i])
  425. end
  426. end -- fin for #args
  427.  
  428. if juego_activo == false then grafico() end
  429.  
  430. elseif args[1] == "team2" then -- y sigue con team2
  431. teams.Team2 = {}
  432. local k = 0
  433. for i = 2, #args do -- recorre toda la tabla args
  434. for j = 1, #teams.Team1 do -- recorre toda la tabla teams2
  435. if args[i] == teams.Team1[j] then -- si un elemento de la tabla args conicide con un elento de la tabla teams2
  436. table.remove(teams.Team1, j)
  437. end
  438. end
  439. if not jugador_activo(args[i], teams.Team2) then
  440. k = k + 1
  441. teams.Team2[k] = args[i]
  442. colores(args[i])
  443. end
  444. end -- fin for #args
  445.  
  446. if juego_activo == false then grafico() end
  447.  
  448. elseif args[1] == "add" then
  449. if args[2] == "team1" then
  450. local k = #teams.Team1
  451. for i = 3, #args do -- recorre toda la tabla args
  452. for j = 1, #teams.Team2 do -- recorre toda la tabla teams2
  453. if args[i] == teams.Team2[j] then -- si un elemento de la tabla args conicide con un elento de la tabla teams2
  454. table.remove(teams.Team2, j)
  455. end
  456. end
  457. if not jugador_activo(args[i], teams.Team1) then
  458. k = k + 1
  459. teams.Team1[k] = args[i]
  460. colores(args[i])
  461. end
  462. end
  463. elseif args[2] == "team2" then
  464. local k = #teams.Team2
  465. for i = 3, #args do -- recorre toda la tabla args
  466. for j = 1, #teams.Team1 do -- recorre toda la tabla teams2
  467. if args[i] == teams.Team1[j] then -- si un elemento de la tabla args conicide con un elento de la tabla teams2
  468. table.remove(teams.Team1, j)
  469. end
  470. end
  471. if not jugador_activo(args[i], teams.Team2) then
  472. k = k + 1
  473. teams.Team2[k] = args[i]
  474. colores(args[i])
  475. end
  476. end
  477. end -- fin if add
  478.  
  479. if juego_activo == false then grafico() end
  480.  
  481. elseif args[1] == "records" then
  482. if recordsActivos[playerName] then
  483. recordsActivos[playerName] = false
  484. else
  485. recordsActivos[playerName] = true
  486. end
  487. verRecords(playerName)
  488.  
  489. elseif args[1] == "time" then
  490. tfm.exec.setGameTime(3)
  491. elseif args[1] == "fix" then
  492. tfm.exec.setGameTime(time_map - 3) -- le restamos los 3s del respawn
  493. elseif args[1] == "map" and juego_activo then
  494. new_map = true
  495. elseif args[1] == "mapas" then
  496. if tonumber(args[3]) ~= nil then
  497. if args[2] == "ez" then
  498. c_ez = tonumber(args[3])
  499. elseif args[2] == "med" then
  500. c_m = tonumber(args[3])
  501. elseif args[2] == "hard" then
  502. c_h = tonumber(args[3])
  503. elseif args[2] == "ultra" then
  504. c_u = tonumber(args[3])
  505. end
  506. cantidadMaps()
  507. end
  508. elseif args[1] == "t" then
  509. if tonumber(args[3]) ~= nil then
  510. if args[2] == "mapas" then
  511. time_map = tonumber(args[3])
  512. elseif args[2] == "lobby" then
  513. time_lobby = tonumber(args[3])
  514. end
  515. cantidadMaps()
  516. end
  517. end
  518. end -- admin[playername]
  519.  
  520. -- COMANDOS PARA NO ADMINS:
  521. if args[1] == "vertimes" then
  522. if playerInfo.verTimes[playerName] == false then
  523. playerInfo.verTimes[playerName] = true
  524. else
  525. playerInfo.verTimes[playerName] = false
  526. end
  527. end
  528. end
  529.  
  530. add_points = function(playerName, p)
  531. if jugador_activo(playerName, teams.Team1) then
  532. puntos.team1 = puntos.team1 + p
  533. elseif jugador_activo(playerName, teams.Team2) then
  534. puntos.team2 = puntos.team2 + p
  535. end
  536. end
  537.  
  538. eventPlayerWon = function (playerName, tiempoRonda, tiempoRespawn)
  539.  
  540. if puesto_1 == false then
  541. table.insert(lugares, {name = playerName, puesto = 1})
  542. puesto_1 = true
  543. tfm.exec.setPlayerScore(playerName, 4, true)
  544. add_points(playerName, 4)
  545. elseif puesto_2 == false then
  546. table.insert(lugares, {name = playerName, puesto = 2})
  547. puesto_2 = true
  548. tfm.exec.setPlayerScore(playerName, 3, true)
  549. add_points(playerName, 3)
  550.  
  551. elseif puesto_3 == false then
  552. table.insert(lugares, {name = playerName, puesto = 3})
  553. puesto_3 = true
  554. tfm.exec.setPlayerScore(playerName, 2, true)
  555. add_points(playerName, 2)
  556.  
  557. else
  558. tfm.exec.setPlayerScore(playerName, 1, true)
  559. add_points(playerName, 1)
  560. end
  561.  
  562. if playerInfo.verTimes[playerName] then
  563. if jugador_activo(playerName, teams.Team1) then
  564. ui.addTextArea(69,
  565. "<b><font size ='15' color='#CB546B'>" .. playerName ..
  566. "</font> <font size ='15'>" .. tiempoRespawn /
  567. 100 .. "s</font>", playerName, 9, 368, 0, 0,
  568. 0x2B2B2B, 0, 0.7, true)
  569. elseif jugador_activo(playerName, teams.Team2) then
  570. ui.addTextArea(69,
  571. "<b><font size ='15' color='#2F7FCC'>" .. playerName ..
  572. "</font> <font size ='15'>" .. tiempoRespawn /
  573. 100 .. "s</font>", playerName, 9, 368, 0, 0,
  574. 0x2B2B2B, 0, 0.7, true)
  575. end
  576. end
  577.  
  578. str = "\n<textformat tabstops='[70, 170, 300]'>"
  579.  
  580. table.insert(times, {
  581. time = tiempoRespawn / 100,
  582. name = playerName,
  583. mapa = mapActual
  584. })
  585. if not playerInfo.alreadyRespawn[playerName] then
  586. times[#times].time = times[#times].time - 3
  587. end
  588. table.sort(times, function(i, v) return i.time < v.time end)
  589. for i, jugadores in ipairs(times) do
  590. if jugador_activo(jugadores.name, teams.Team1) then
  591. jugador = "<font color = '#CB546B'>" .. jugadores.name .. "</font>"
  592. elseif jugador_activo(jugadores.name, teams.Team2) then
  593. jugador = "<font color = '#2F7FCC'>" .. jugadores.name .. "</font>"
  594. end
  595. removerText[playerName] = os.time()
  596. if i <= 15 then
  597. if i < 10 then i = 0 .. i end
  598. str = str ..
  599. (i .. ' | ' .. jugador .. '\t| ' ..
  600. jugadores.time .. 's\n')
  601. end
  602. end
  603. str = str .. '</textformat>'
  604. for player, p in pairs(tfm.get.room.playerList) do verRecords(player) end
  605.  
  606. end
  607.  
  608. eventKeyboard = function(player, key, down, x, y)
  609. if key == 76 then
  610. if recordsActivos[player] then
  611. recordsActivos[player] = false
  612. else
  613. recordsActivos[player] = true
  614. end
  615. verRecords(player)
  616. elseif key == 46 or key == 16 then
  617. tfm.exec.killPlayer(player)
  618.  
  619. elseif key == 80 then
  620. if playerInfo.verTimes[player] == false then
  621. playerInfo.verTimes[player] = true
  622. else
  623. playerInfo.verTimes[player] = false
  624. end
  625. end
  626. end
  627.  
  628. colores = function (playerName)
  629. if jugador_activo(playerName, teams.Team1) then
  630. tfm.exec.setNameColor(playerName, 0xCB546B)
  631. elseif jugador_activo(playerName, teams.Team2) then
  632. tfm.exec.setNameColor(playerName, 0x2F7FCC)
  633. end
  634. end
  635.  
  636. jugador_activo = function(player, L) -- L lista de jugadores --
  637. for _, v in pairs(L) do if player == v then return true end end
  638. return false
  639. end
  640.  
  641. verRecords = function(player)
  642. if recordsActivos[player] then
  643. ui.addTextArea(40, str, player, 275, 80, 250, 200, 0x2B2B2B, 0x121212,
  644. 1, true)
  645. ui.addTextArea(41,
  646. "<p align='center'><font size ='13' color='#00C17C'><b>Tiempos",
  647. player, 352, 65, 100, 20, 0x2B2B2B, 0x121212, 1, true)
  648. else
  649. ui.removeTextArea(40, player)
  650. ui.removeTextArea(41, player)
  651. end
  652. end
  653.  
  654.  
  655. recordsLobby = function()
  656. jugador = "\n\n"
  657. jugadoresTimes = "\n<textformat tabstops='[175]'>"
  658. jugadorCantidad = {}
  659. jugadoresCantidad = "\n<textformat tabstops='[175]'>"
  660.  
  661. table.sort(lugares, function(i, v) return i.puesto < v.puesto end)
  662. for i, nombreJugador in ipairs(lugares) do
  663. if jugador_activo(nombreJugador.name, teams.Team1) then
  664. jugador = jugador .. "<font color='#00C17C'>" .. "0" .. nombreJugador.puesto .. "</font> " .. "<font color = '#CB546B'>" .. nombreJugador.name .. "</font>\n"
  665. elseif jugador_activo(nombreJugador.name, teams.Team2) then
  666. jugador = jugador .. "<font color='#00C17C'>" .. "0" .. nombreJugador.puesto .. "</font> " .. "<font color = '#2F7FCC'>" .. nombreJugador.name .. "</font>\n"
  667. end
  668. end
  669.  
  670. for i = 1, recorrerTimes() do
  671. if jugador_activo(times[i].name, teams.Team1) then
  672. jugadoresTimes = jugadoresTimes .. "<font color='#CB546B'>" .. times[i].name .. "\t</font><font color = '#00C17C'>" .. times[i].time .. "s</font>\n"
  673. elseif jugador_activo(times[i].name, teams.Team2) then
  674. jugadoresTimes = jugadoresTimes .. "<font color='#2F7FCC'>" .. times[i].name .. "\t</font><font color = '#00C17C'>" .. times[i].time .. "s</font>\n"
  675. end
  676. end
  677.  
  678. cantidades_mapa()
  679. cantidades_finales(name_cant)
  680.  
  681. for i, jugadorNombre in ipairs(name_cant) do
  682. if jugador_activo(jugadorNombre.nombre, teams.Team1) then
  683. jugadoresCantidad = jugadoresCantidad .. "<font color='#CB546B'>" .. jugadorNombre.nombre .. "\t</font><font color = '#00C17C'>" .. jugadorNombre.cantidad .. "</font>\n"
  684. elseif jugador_activo(jugadorNombre.nombre, teams.Team2) then
  685. jugadoresCantidad = jugadoresCantidad .. "<font color='#2F7FCC'>" .. jugadorNombre.nombre .. "\t</font><font color = '#00C17C'>" .. jugadorNombre.cantidad .. "</font>\n"
  686. end
  687. end
  688.  
  689.  
  690. ui.addTextArea(31, "<p align='center'> <font size ='16' color='#00C17C'><b>Estadísticas", nil, 20, 137, 760, 220, 0x1E1E1E, 0x121212,
  691. 1, true)
  692. ui.addTextArea(32, "<p align='center'><font size ='15' color='#00C17C'><b>Primeros Puestos</b></font>" .. jugador, nil, 35, 170, 230, 170, 0x2B2B2B, 0x2B2B2B, 1, true)
  693. ui.addTextArea(33, "<p align='center'><font size ='15' color='#00C17C'><b>Cantidades</b></font></p>" .. jugadoresCantidad, nil, 285, 170, 230, 170, 0x2B2B2B, 0x2B2B2B, 1, true)
  694. ui.addTextArea(34, "<p align='center'><font size ='15' color='#00C17C'><b>Tiempos</b></font></p>" .. jugadoresTimes, nil, 535, 170, 230, 170, 0x2B2B2B, 0x2B2B2B, 1, true)
  695.  
  696. end
  697.  
  698. cantidades_mapa = function()
  699. local cont = 1
  700. local cont_ult
  701. local names = {}
  702. name_cant = {}
  703. local canti = {}
  704.  
  705. for i = 1, #times do
  706. table.insert(names, times[i].name)
  707. end
  708.  
  709. table.sort(names, function(a,b) return a < b end)
  710.  
  711. for i = 1 , #names do
  712. if i+1 > #names or names[i] ~= names[i+1] then
  713. table.insert(name_cant, {nombre = names[i], cantidad = cont})
  714. cont = 1
  715. else
  716. cont = cont + 1
  717. end
  718. end
  719. end
  720.  
  721.  
  722. cantidades_finales = function(C) -- C array de personas que completaron el mapa
  723. local nom = {}
  724.  
  725. if #cantidad_f == 0 then
  726. for i = 1, #C do
  727. table.insert(cantidad_f, {nom = C[i].nombre, c = C[i].cantidad})
  728. end
  729.  
  730. else
  731. for i = 1, #cantidad_f do
  732. table.insert(nom, cantidad_f[i].nom)
  733. end
  734.  
  735. for i=1, #C do
  736. if not jugador_activo(C[i].nombre, nom) then
  737. table.insert(cantidad_f, {nom = C[i].nombre, c = C[i].cantidad})
  738. else
  739. for j=1, #cantidad_f do
  740. if cantidad_f[j].nom == C[i].nombre then
  741. cantidad_f[j].c = cantidad_f[j].c + C[i].cantidad
  742. end
  743. end
  744. end
  745. end
  746. end
  747. end
  748.  
  749.  
  750. recorrerTimes = function ()
  751. if #times >= 3 then
  752. return 3
  753. elseif #times == 2 then
  754. return 2
  755. elseif #times == 1 then
  756. return 1
  757. else
  758. return 0
  759. end
  760. end
  761.  
  762.  
  763. --
  764. rcorrer_times = function(L, cantidad_times)
  765. local t = 4
  766. for i = 1, cantidad_times, 1 do
  767. add_points(L[i].name, t)
  768. tfm.exec.setPlayerScore(L[i].name, t, true)
  769. t = t / 2
  770. end
  771. end
  772.  
  773. addpoints_time = function (L)
  774. if #L >= 3 then
  775. rcorrer_times(L, 3)
  776. elseif #L == 2 then
  777. rcorrer_times(L, 2)
  778. elseif #L == 1 then
  779. rcorrer_times(L, 1)
  780. end
  781. end
  782.  
  783. establecerEquipos = function()
  784. teams.Team1 = {}
  785. teams.Team2 = {}
  786. local equipo = 1
  787. local jugadoresTotal = {}
  788. for name, p in pairs(tfm.get.room.playerList) do
  789. table.insert(jugadoresTotal, name)
  790. end
  791. for i = 1, #jugadoresTotal do
  792. numJugador = math.random(#jugadoresTotal)
  793. agregarJugador = jugadoresTotal[numJugador]
  794. table.remove(jugadoresTotal, numJugador)
  795. if equipo == 1 then
  796. table.insert(teams.Team1, agregarJugador)
  797. equipo = 2
  798. elseif equipo == 2 then
  799. table.insert(teams.Team2, agregarJugador)
  800. equipo = 1
  801. end
  802. end
  803. grafico()
  804. end
  805.  
  806. establecerPuntos = function()
  807. for name in pairs(tfm.get.room.playerList) do
  808. tfm.exec.setPlayerScore(name, 0)
  809. end
  810. end
  811.  
  812. eventTextAreaCallback = function (id, player, callback)
  813. if admin[player] then
  814. if callback == 'iniciarJuego' and tiempoJugado >= 3383 then
  815. for i = 661, 671 do ui.removeTextArea(i) end
  816. establecerPuntos()
  817. newMap()
  818. elseif callback == 'equiposRandom' then
  819. establecerEquipos()
  820. colores()
  821. elseif callback == 'vaciarTeams' then
  822. teams.Team1 = {}
  823. teams.Team2 = {}
  824. grafico()
  825. end
  826. end
  827. end
  828.  
  829. grafico = function ()
  830. ui.addTextArea(668, "", nil, 300, 143, 200, 13, 0x2B2B2B, 0x121212, 0.7,
  831. true)
  832. ui.addTextArea(662, "", nil, 300, 243, 200, 13, 0x2B2B2B, 0x121212, 0.7,
  833. true)
  834. ui.addTextArea(666, "<p align='center'><font color='#CB546B'>" ..
  835. (table.concat(teams.Team1, "\n") or ""), nil, 150, 140,
  836. 175, 200, 0x2B2B2B, 0x121212, 1, true)
  837. ui.addTextArea(667, "<p align='center'><font color='#2F7FCC'>" ..
  838. (table.concat(teams.Team2, "\n") or ""), nil, 450, 140,
  839. 175, 200, 0x2B2B2B, 0x121212, 1, true)
  840. ui.addTextArea(664, "<p align='center'><font color='#CB546B'><b>Team 1",
  841. nil, 143, 115, 190, 20, 0x2B2B2B, 0x121212, 1, true)
  842. ui.addTextArea(665, "<p align='center'><font color='#2F7FCC'><b>Team 2",
  843. nil, 443, 115, 190, 20, 0x2B2B2B, 0x121212, 1, true)
  844. ui.addTextArea(661,
  845. "<p align='center'><V><a href='event:iniciarJuego'><font color='#F93018'><b>Iniciar",
  846. nil, 363, 140, 0, 0, 0x2B2B2B, 0x121212, 1, true)
  847. ui.addTextArea(663, "", nil, 290, 343, 200, 13, 0x2B2B2B, 0x121212, 1, true)
  848. ui.addTextArea(669,
  849. "<p align='center'><V><a href='event:equiposRandom'><font color='#00C17C'><b>Llenar",
  850. nil, 463, 341, 0, 0, 0x2B2B2B, 0x121212, 1, true)
  851. ui.addTextArea(670,
  852. "<p align='center'><V><a href='event:vaciarTeams'><font color='#00C17C'><b>Vaciar",
  853. nil, 263, 341, 0, 0, 0x2B2B2B, 0x121212, 1, true)
  854. end
  855.  
  856. cantidadMaps = function()
  857. if juego_activo == false then
  858. for name in pairs(admin) do
  859. ui.addTextArea(671,
  860. "<b><font color='#00C17C' size ='12'>Ez Maps " ..
  861. c_ez ..
  862. "</font>\n<font color='#EBC244' size ='12'>Med Maps " ..
  863. c_m ..
  864. "</font>\n<font color='#CB546B' size ='12'>Hard Maps " ..
  865. c_h ..
  866. "</font>\n<font color='#F93018' size ='12'>Ult Maps " ..
  867. c_u ..
  868. "</font>\n\n<BV><font size ='12'>Time Map " ..
  869. time_map .. "\nTime Lob " .. time_lobby, name,
  870. 10, 143, 100, 0, 0x2B2B2B, 0x121212, 0.7, true)
  871. end
  872. end
  873. end
  874.  
  875. main = function ()
  876. tfm.exec.newGame(7692636)
  877. grafico()
  878. tfm.exec.setGameTime(10000)
  879. cantidadMaps()
  880. end
  881.  
  882. main()
  883.  
  884. eventPlayerRespawn = function(playerName) playerInfo.alreadyRespawn[playerName] = true end
  885. -- @306365 @1722755
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement