Advertisement
alditojeje

Untitled

Mar 29th, 2020
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.97 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.  
  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 cantidades_f_nombre = {}
  119.  
  120.  
  121. function newMap()
  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. tfm.exec.setGameTime(time_map)
  151. estadisticasFinales()
  152. -- puntuacion_final()
  153. juego_activo = false
  154.  
  155. elseif not map_bc_actual then
  156. mejorTiempo = " "
  157. times = {}
  158. str = "\n<textformat tabstops='[70, 170, 300]'>"
  159. lugares = {}
  160.  
  161. juego_activo = true
  162. map_bc_actual = true
  163.  
  164. math.randomseed(os.time())
  165. if c_ez ~= 0 then
  166. estado = 1
  167. local map = ez_maps[math.random(#ez_maps)]
  168. tfm.exec.newGame(map)
  169. -- tfm.exec.newGame('#13')
  170. c_ez = c_ez - 1
  171. dificultadMap = "<font color='#00C17C'>Fácil</font>"
  172. elseif c_m ~= 0 then
  173. estado = 2
  174. local map = med_maps[math.random(#med_maps)]
  175. tfm.exec.newGame(map)
  176. c_m = c_m - 1
  177. dificultadMap = "<font color='#EBC244'>Medio</font>"
  178. elseif c_h ~= 0 then
  179. estado = 3
  180. local map = hard_maps[math.random(#hard_maps)]
  181. tfm.exec.newGame(map)
  182. dificultadMap = "<font color='#F93018'>Difícil</font>"
  183. -- print(time_map) --
  184. c_h = c_h - 1
  185.  
  186. elseif c_u ~= 0 then
  187. estado = 4
  188. local map = ultra_maps[math.random(#ultra_maps)]
  189. tfm.exec.newGame(map)
  190. dificultadMap = "<font color='#F93018'>Ultra</font>"
  191. c_u = c_u - 1
  192. -- else
  193. end
  194. for p, v in pairs(tfm.get.room.playerList) do
  195. if jugador_activo(p, lista_A) == false and
  196. jugador_activo(p, lista_B) == false then
  197. tfm.exec.killPlayer(p)
  198. end
  199. end
  200.  
  201. else
  202. juego_activo = true
  203. tfm.exec.newGame(7692692)
  204. -- tfm.exec.setGameTime(7)
  205. map_bc_actual = false
  206.  
  207. addpoints_time(times)
  208.  
  209. recordsLobby()
  210. if #times >= 1 then
  211. table.insert(bestTimes, {
  212. mapa = times[1].mapa,
  213. time = times[1].time,
  214. name = times[1].name
  215. })
  216. end
  217. end
  218. end
  219.  
  220. --function puntuacion_final()
  221.  
  222. --end
  223.  
  224.  
  225. function estadisticasFinales()
  226.  
  227. -- equipo ganador --
  228. equipoGanador = ""
  229. if puntos.team1 > puntos.team2 then
  230. equipoGanador = "<font color = '#CB546B'>Team Red Wins</font>"
  231. elseif puntos.team1 < puntos.team2 then
  232. equipoGanador = "<font color = '#2F7FCC'>Team Blue Wins</font>"
  233. else
  234. equipoGanador = "<font color='#00C17C'>Empate jajaencerio</font>"
  235. end
  236. -- fin equipo ganador
  237.  
  238. -- mejores tiempos --
  239. mejoresTiempos = "\n<textformat tabstops='[75, 280]'>"
  240. for i, completion in ipairs(bestTimes) do
  241. if jugador_activo(completion.name, teams.Team1) then
  242. jugador = "<font color = '#CB546B'>" .. completion.name .. "</font>"
  243. elseif jugador_activo(completion.name, teams.Team2) then
  244. jugador = "<font color = '#2F7FCC'>" .. completion.name .. "</font>"
  245. end
  246. mejoresTiempos = mejoresTiempos ..
  247. ("<font color='#00C17C'>@" .. completion.mapa ..
  248. '</font>' .. "\t " .. jugador .. '\t ' ..
  249. " <font color='#00C17C'> " .. completion.time ..
  250. 's</font>\n')
  251. end
  252. mejoresTiempos = mejoresTiempos .. '</textformat>'
  253. -- fin mejores tiempos -
  254.  
  255. -- mejor jugador
  256. scoreTop = -1
  257. nombreTop = ""
  258. for name, p in pairs(tfm.get.room.playerList) do
  259. if p.score + 1 > scoreTop then
  260. scoreTop = p.score + 1
  261. nombreTop = name
  262. end
  263. end
  264. if jugador_activo(nombreTop, teams.Team1) then
  265. nombreTop = "<font color = '#CB546B'>" .. nombreTop .. "</font>"
  266. elseif jugador_activo(nombreTop, teams.Team2) then
  267. nombreTop = "<font color = '#2F7FCC'>" .. nombreTop .. "</font>"
  268. end
  269.  
  270. -- fin mejor jugador
  271.  
  272.  
  273. 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
  274.  
  275. 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, 250, 0x1E1E1E, 0x121212, 1, true)
  276. ui.addTextArea(32, "<p align='center'><font size ='15' color='#00C17C'><b>Cantidades Totales</b></font></p>" .. jugadoresCantidad, nil, 35, 160, 350, 170, 0x2B2B2B, 0x2B2B2B, 1, true)
  277. 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)
  278.  
  279. end
  280.  
  281. function eventNewGame()
  282. if juego_activo then mapActual = tfm.get.room.xmlMapInfo.mapCode end
  283.  
  284. for name in pairs(tfm.get.room.playerList) do colores(name) end
  285.  
  286. if map_bc_actual or new_map then
  287. ui.removeTextArea(40, player)
  288. ui.removeTextArea(41, player)
  289. tfm.exec.setGameTime(time_map)
  290. else
  291. tfm.exec.setGameTime(time_lobby)
  292. end
  293.  
  294. if firstMap then
  295. firstMap = false
  296. tfm.exec.setGameTime(10000)
  297. end
  298.  
  299. end
  300.  
  301. function eventNewPlayer(player)
  302. respawnPlayer[player] = os.time()
  303. playerInfo.verTimes[player] = false
  304. teclas(player)
  305. end
  306.  
  307. function teclas(player)
  308. tfm.exec.bindKeyboard(player, 76, false, true)
  309. tfm.exec.bindKeyboard(player, 46, false, true)
  310. tfm.exec.bindKeyboard(player, 16, false, true)
  311. tfm.exec.bindKeyboard(player, 80, false, true)
  312. end
  313.  
  314. for player in next, tfm.get.room.playerList do
  315. eventNewPlayer(player)
  316. playerInfo.verTimes[player] = false
  317. teclas(player)
  318. end
  319.  
  320. function eventPlayerDied(player) respawnPlayer[player] = os.time() end
  321.  
  322. function setNewMap()
  323. math.randomseed(os.time())
  324. if estado == 1 then
  325. local map = ez_maps[math.random(#ez_maps)]
  326. tfm.exec.newGame(map)
  327. elseif estado == 2 then
  328. local map = med_maps[math.random(#med_maps)]
  329. tfm.exec.newGame(map)
  330. elseif estado == 3 then
  331. local map = hard_maps[math.random(#hard_maps)]
  332. tfm.exec.newGame(map)
  333. elseif estado == 4 then
  334. local map = ultra_maps[math.random(#utra_maps)]
  335. tfm.exec.newGame(map)
  336. end
  337. end
  338.  
  339. function eventLoop(time, remaining)
  340. if new_map then
  341. setNewMap()
  342. new_map = false
  343. end
  344.  
  345. if remaining < 500 then newMap() end
  346.  
  347. for i, n in pairs(respawnPlayer) do
  348. if n <= os.time() - 1000 then
  349. lista_A = teams.Team1
  350. lista_B = teams.Team2
  351. if jugador_activo(i, lista_A) or jugador_activo(i, lista_B) then
  352. tfm.exec.respawnPlayer(i)
  353. colores(i)
  354. end
  355. end
  356. end
  357. if juego_activo then
  358. minutos = "0" .. math.floor((remaining / 1000) / 60)
  359. segundos = math.floor(remaining / 1000) % 60
  360. if segundos <= 9 then segundos = "0" .. segundos end
  361. if #times >= 1 then
  362. mejorTiempo = times[1].name .. " " .. times[1].time .. "s"
  363. end
  364.  
  365. for i, n in pairs(removerText) do
  366. if n <= os.time() - 2000 then ui.removeTextArea(69, i) end
  367. end
  368.  
  369. if (time_map == 1234567) then
  370. tfm.exec.setUIMapName(
  371. " <font color='#CB546B'>Red: " ..
  372. puntos.team1 .. "</font>\t|\t<font color='#2F7FCC'> Blue: " ..
  373. puntos.team2 .. "</font>\t|\t" .. "\t\t" .. "\n")
  374. else
  375.  
  376. --[[ barra = dificultadMap .. " <font color='#CB546B'>Red: " ..
  377. puntos.team1 .. "</font>\t|\t<font color='#2F7FCC'> Blue: " ..
  378. puntos.team2 .. "</font>\t|\t" .. minutos .. ":" .. segundos ..
  379. "\t|\t" .. mejorTiempo .. "\n"
  380.  
  381. print(#barra) ]]
  382.  
  383. tfm.exec.setUIMapName(dificultadMap .. " <font color='#CB546B'>Red: " ..
  384. puntos.team1 .. "</font>\t|\t<font color='#2F7FCC'> Blue: " ..
  385. puntos.team2 .. "</font>\t|\t" .. minutos .. ":" .. segundos ..
  386. "\t|\t" .. mejorTiempo .. "\n")
  387. end
  388. end
  389. end
  390.  
  391. function eventChatCommand(playerName, command)
  392. local args = {}
  393.  
  394. for arg in command:gmatch("[^%s]+") do table.insert(args, arg) end
  395. -- comandos para admins:
  396. if admin[playerName] then
  397. if args[1] == "team1" then -- y sigue con team1
  398. teams.Team1 = {}
  399. for i = 2, #args do -- recorre toda la tabla args
  400. for j = 1, #teams.Team2 do -- recorre toda la tabla teams2
  401. if args[i] == teams.Team2[j] then -- si un elemento de la tabla args conicide con un elento de la tabla teams2
  402. table.remove(teams.Team2, j)
  403. -- ui.updateTextArea(667, "<p align='center'><font color='#2F7FCC'>" .. (table.concat(teams.Team2,"\n") or ""), nil)
  404. end
  405. end
  406.  
  407. if not jugador_activo(args[i], teams.Team1) then
  408. table.insert(teams.Team1, args[i])
  409. colores(args[i])
  410. end
  411. end
  412.  
  413. if juego_activo == false then grafico() end
  414.  
  415. elseif args[1] == "team2" then -- y sigue con team2
  416. teams.Team2 = {}
  417. for i = 2, #args do -- recorre toda la tabla args
  418. for j = 1, #teams.Team1 do -- recorre toda la tabla teams1
  419. if args[i] == teams.Team1[j] then -- si un elemento de la tabla args conicide con un elento de la tabla teams1
  420. table.remove(teams.Team1, j)
  421. -- ui.updateTextArea(666, "<p align='center'><font color='#CB546B'>" .. (table.concat(teams.Team1,"\n") or ""), nil)
  422. end
  423. end
  424. if not jugador_activo(args[i], teams.Team2) then
  425. table.insert(teams.Team2, args[i])
  426. colores(args[i])
  427. end
  428. end
  429. if juego_activo == false then grafico() end
  430.  
  431. elseif args[1] == "add" then
  432. if args[2] == "team1" then
  433. for i = 3, #args do -- recorre toda la tabla args
  434. for j = 1, #teams.Team2 do -- recorre toda la tabla teams2
  435. if args[i] == teams.Team2[j] then -- si un elemento de la tabla args conicide con un elento de la tabla teams2
  436. table.remove(teams.Team2, j)
  437. -- ui.updateTextArea(4, "<p align='center'><font color='#2F7FCC'>" .. (table.concat(teams.Team2,"\n") or ""), nil)
  438. end
  439. end
  440. -- if jugadorSinEquipo(args[i]) then
  441. if not jugador_activo(args[i], teams.Team1) then
  442. table.insert(teams.Team1, args[i])
  443. colores(args[i])
  444. end
  445. -- end
  446. end
  447. end
  448. if args[2] == "team2" then
  449. for i = 3, #args do
  450. for j = 1, #teams.Team1 do
  451. if args[i] == teams.Team1[j] then
  452. table.remove(teams.Team1, j)
  453. ui.updateTextArea(3,
  454. "<p align='center'><font color='#CB546B'>" ..
  455. (table.concat(teams.Team1,
  456. "\n") or ""),
  457. nil)
  458. end
  459. end
  460. -- if jugadorSinEquipo(args[i]) then
  461. if not jugador_activo(args[i], teams.Team2) then
  462. table.insert(teams.Team2, args[i])
  463. colores(args[i])
  464. end
  465. -- end
  466. end
  467. end
  468. if juego_activo == false then grafico() end
  469.  
  470. elseif args[1] == "records" then
  471. if recordsActivos[playerName] then
  472. recordsActivos[playerName] = false
  473. else
  474. recordsActivos[playerName] = true
  475. end
  476. verRecords(playerName)
  477.  
  478. elseif args[1] == "time" then
  479. tfm.exec.setGameTime(3)
  480. elseif args[1] == "fix" then
  481. tfm.exec.setGameTime(time_map - 3) -- le restamos los 3s del respawn
  482. elseif args[1] == "map" and juego_activo then
  483. new_map = true
  484. elseif args[1] == "mapas" then
  485. if tonumber(args[3]) ~= nil then
  486. if args[2] == "ez" then
  487. c_ez = tonumber(args[3])
  488. elseif args[2] == "med" then
  489. c_m = tonumber(args[3])
  490. elseif args[2] == "hard" then
  491. c_h = tonumber(args[3])
  492. elseif args[2] == "ultra" then
  493. c_u = tonumber(args[3])
  494. end
  495. cantidadMaps()
  496. end
  497. elseif args[1] == "t" then
  498. if tonumber(args[3]) ~= nil then
  499. if args[2] == "mapas" then
  500. time_map = tonumber(args[3])
  501. elseif args[2] == "lobby" then
  502. time_lobby = tonumber(args[3])
  503. end
  504. cantidadMaps()
  505. end
  506. end
  507. end -- admin[playername]
  508.  
  509. -- COMANDOS PARA NO ADMINS:
  510. if args[1] == "vertimes" then
  511. if playerInfo.verTimes[playerName] == false then
  512. playerInfo.verTimes[playerName] = true
  513. else
  514. playerInfo.verTimes[playerName] = false
  515. end
  516. end
  517. end
  518.  
  519. function add_points(playerName, p)
  520. if jugador_activo(playerName, teams.Team1) then
  521. puntos.team1 = puntos.team1 + p
  522. elseif jugador_activo(playerName, teams.Team2) then
  523. puntos.team2 = puntos.team2 + p
  524. end
  525. end
  526.  
  527. function eventPlayerWon(playerName, tiempoRonda, tiempoRespawn)
  528.  
  529. if puesto_1 == false then
  530. table.insert(lugares, {name = playerName, puesto = 1})
  531. puesto_1 = true
  532. tfm.exec.setPlayerScore(playerName, 4, true)
  533. add_points(playerName, 4)
  534. elseif puesto_2 == false then
  535. table.insert(lugares, {name = playerName, puesto = 2})
  536. puesto_2 = true
  537. tfm.exec.setPlayerScore(playerName, 3, true)
  538. add_points(playerName, 3)
  539.  
  540. elseif puesto_3 == false then
  541. table.insert(lugares, {name = playerName, puesto = 3})
  542. puesto_3 = true
  543. tfm.exec.setPlayerScore(playerName, 2, true)
  544. add_points(playerName, 2)
  545.  
  546. else
  547. tfm.exec.setPlayerScore(playerName, 1, true)
  548. add_points(playerName, 1)
  549. end
  550.  
  551. if playerInfo.verTimes[playerName] then
  552. if jugador_activo(playerName, teams.Team1) then
  553. ui.addTextArea(69,
  554. "<b><font size ='15' color='#CB546B'>" .. playerName ..
  555. "</font> <font size ='15'>" .. tiempoRespawn /
  556. 100 .. "s</font>", playerName, 9, 368, 0, 0,
  557. 0x2B2B2B, 0, 0.7, true)
  558. elseif jugador_activo(playerName, teams.Team2) then
  559. ui.addTextArea(69,
  560. "<b><font size ='15' color='#2F7FCC'>" .. playerName ..
  561. "</font> <font size ='15'>" .. tiempoRespawn /
  562. 100 .. "s</font>", playerName, 9, 368, 0, 0,
  563. 0x2B2B2B, 0, 0.7, true)
  564. end
  565. end
  566.  
  567. str = "\n<textformat tabstops='[70, 170, 300]'>"
  568.  
  569. table.insert(times, {
  570. time = tiempoRespawn / 100,
  571. name = playerName,
  572. mapa = mapActual
  573. })
  574. if not playerInfo.alreadyRespawn[playerName] then
  575. times[#times].time = times[#times].time - 3
  576. end
  577. table.sort(times, function(i, v) return i.time < v.time end)
  578. for i, completion in ipairs(times) do
  579. if jugador_activo(completion.name, teams.Team1) then
  580. jugador = "<font color = '#CB546B'>" .. completion.name .. "</font>"
  581. elseif jugador_activo(completion.name, teams.Team2) then
  582. jugador = "<font color = '#2F7FCC'>" .. completion.name .. "</font>"
  583. end
  584. removerText[playerName] = os.time()
  585. if i <= 15 then
  586. if i < 10 then i = 0 .. i end
  587. str = str ..
  588. (i .. ' | ' .. jugador .. '\t| ' ..
  589. completion.time .. 's\n')
  590. end
  591. end
  592. str = str .. '</textformat>'
  593. for player, p in pairs(tfm.get.room.playerList) do verRecords(player) end
  594.  
  595. end
  596.  
  597. function eventKeyboard(player, key, down, x, y)
  598. if key == 76 then
  599. if recordsActivos[player] then
  600. recordsActivos[player] = false
  601. else
  602. recordsActivos[player] = true
  603. end
  604. verRecords(player)
  605. elseif key == 46 or key == 16 then
  606. tfm.exec.killPlayer(player)
  607. elseif key == 80 then
  608. if playerInfo.verTimes[player] == false then
  609. playerInfo.verTimes[player] = true
  610. else
  611. playerInfo.verTimes[player] = false
  612. end
  613. end
  614. end
  615.  
  616. function colores(playerName)
  617. if jugador_activo(playerName, teams.Team1) then
  618. tfm.exec.setNameColor(playerName, 0xCB546B)
  619. elseif jugador_activo(playerName, teams.Team2) then
  620. tfm.exec.setNameColor(playerName, 0x2F7FCC)
  621. end
  622. end
  623.  
  624. function jugador_activo(player, L) -- L lista de jugadores --
  625. for _, v in pairs(L) do if player == v then return true end end
  626. return false
  627. end
  628.  
  629. function verRecords(player)
  630. if recordsActivos[player] then
  631. ui.addTextArea(40, str, player, 275, 80, 250, 200, 0x2B2B2B, 0x121212,
  632. 1, true)
  633. ui.addTextArea(41,
  634. "<p align='center'><font size ='13' color='#00C17C'><b>Tiempos",
  635. player, 352, 65, 100, 20, 0x2B2B2B, 0x121212, 1, true)
  636. else
  637. ui.removeTextArea(40, player)
  638. ui.removeTextArea(41, player)
  639. end
  640. end
  641.  
  642.  
  643. function recordsLobby()
  644. jugador = "\n\n"
  645. jugadoresTimes = "\n<textformat tabstops='[175]'>"
  646. jugadorCantidad = {}
  647. jugadoresCantidad = "\n<textformat tabstops='[175]'>"
  648.  
  649. table.sort(lugares, function(i, v) return i.puesto < v.puesto end)
  650. for i, nombreJugador in ipairs(lugares) do
  651. if jugador_activo(nombreJugador.name, teams.Team1) then
  652. jugador = jugador .. "<font color='#00C17C'>" .. "0" .. nombreJugador.puesto .. "</font> " .. "<font color = '#CB546B'>" .. nombreJugador.name .. "</font>\n"
  653. elseif jugador_activo(nombreJugador.name, teams.Team2) then
  654. jugador = jugador .. "<font color='#00C17C'>" .. "0" .. nombreJugador.puesto .. "</font> " .. "<font color = '#2F7FCC'>" .. nombreJugador.name .. "</font>\n"
  655. end
  656. end
  657.  
  658. for i = 1, recorrerTimes() do
  659. if jugador_activo(times[i].name, teams.Team1) then
  660. jugadoresTimes = jugadoresTimes .. "<font color='#CB546B'>" .. times[i].name .. "\t</font><font color = '#00C17C'>" .. times[i].time .. "s</font>\n"
  661. elseif jugador_activo(times[i].name, teams.Team2) then
  662. jugadoresTimes = jugadoresTimes .. "<font color='#2F7FCC'>" .. times[i].name .. "\t</font><font color = '#00C17C'>" .. times[i].time .. "s</font>\n"
  663. end
  664. end
  665.  
  666. local cont = 1
  667. local cont_ult
  668. local names = {}
  669. local name_cant = {}
  670. local canti = {}
  671.  
  672. for i = 1, #times do
  673. table.insert(names, times[i].name)
  674. end
  675.  
  676. table.sort(names, function(a,b) return a < b end)
  677. for i = 1, #names do
  678. end
  679.  
  680. for i = 1 , #names do
  681. if i+1 > #names or names[i] ~= names[i+1] then
  682. table.insert(name_cant, {nombre = names[i], cantidad = cont})
  683. cont = 1
  684. else
  685. cont = cont + 1
  686. end
  687. end
  688.  
  689. for i, jugadorNombre in ipairs(name_cant) do
  690. if jugador_activo(jugadorNombre.nombre, teams.Team1) then
  691. jugadoresCantidad = jugadoresCantidad .. "<font color='#CB546B'>" .. jugadorNombre.nombre .. "\t</font><font color = '#00C17C'>" .. jugadorNombre.cantidad .. "</font>\n"
  692. elseif jugador_activo(jugadorNombre.nombre, teams.Team2) then
  693. jugadoresCantidad = jugadoresCantidad .. "<font color='#2F7FCC'>" .. jugadorNombre.nombre .. "\t</font><font color = '#00C17C'>" .. jugadorNombre.cantidad .. "</font>\n"
  694. end
  695. end
  696.  
  697.  
  698. ui.addTextArea(31, "<p align='center'> <font size ='16' color='#00C17C'><b>Estadísticas", nil, 20, 137, 760, 220, 0x1E1E1E, 0x121212,
  699. 1, true)
  700. 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)
  701. 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)
  702. 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)
  703.  
  704. end
  705.  
  706. function recorrerTimes()
  707. if #times >= 3 then
  708. return 3
  709. elseif #times == 2 then
  710. return 2
  711. elseif #times == 1 then
  712. return 1
  713. else
  714. return 0
  715. end
  716. end
  717.  
  718.  
  719. --
  720. function rcorrer_times(L, cantidad_times)
  721. local t = 4
  722. for i = 1, cantidad_times, 1 do
  723. add_points(L[i].name, t)
  724. tfm.exec.setPlayerScore(L[i].name, t, true)
  725. t = t / 2
  726. end
  727. end
  728.  
  729. function addpoints_time(L)
  730. if #L >= 3 then
  731. rcorrer_times(L, 3)
  732. elseif #L == 2 then
  733. rcorrer_times(L, 2)
  734. elseif #L == 1 then
  735. rcorrer_times(L, 1)
  736. end
  737. end
  738.  
  739. function establecerEquipos()
  740. teams.Team1 = {}
  741. teams.Team2 = {}
  742. local equipo = 1
  743. local jugadoresTotal = {}
  744. for name, p in pairs(tfm.get.room.playerList) do
  745. table.insert(jugadoresTotal, name)
  746. end
  747. for i = 1, #jugadoresTotal do
  748. numJugador = math.random(#jugadoresTotal)
  749. agregarJugador = jugadoresTotal[numJugador]
  750. table.remove(jugadoresTotal, numJugador)
  751. if equipo == 1 then
  752. table.insert(teams.Team1, agregarJugador)
  753. equipo = 2
  754. elseif equipo == 2 then
  755. table.insert(teams.Team2, agregarJugador)
  756. equipo = 1
  757. end
  758. end
  759. grafico()
  760. end
  761.  
  762. function establecerPuntos()
  763. for name in pairs(tfm.get.room.playerList) do
  764. tfm.exec.setPlayerScore(name, 0)
  765. end
  766. end
  767.  
  768. function eventTextAreaCallback(id, player, callback)
  769. if admin[player] then
  770. if callback == 'equiposRandom' then
  771. establecerEquipos()
  772. colores()
  773. elseif callback == 'vaciarTeams' then
  774. teams.Team1 = {}
  775. teams.Team2 = {}
  776. grafico()
  777. elseif callback == 'iniciarJuego' then
  778. for i = 661, 671 do ui.removeTextArea(i) end
  779. newMap()
  780. establecerPuntos()
  781.  
  782. end
  783. end
  784. end
  785.  
  786. function grafico()
  787. ui.addTextArea(661, "", nil, 300, 143, 200, 13, 0x2B2B2B, 0x121212, 0.7,
  788. true)
  789. ui.addTextArea(662, "", nil, 300, 243, 200, 13, 0x2B2B2B, 0x121212, 0.7,
  790. true)
  791. ui.addTextArea(666, "<p align='center'><font color='#CB546B'>" ..
  792. (table.concat(teams.Team1, "\n") or ""), nil, 150, 140,
  793. 175, 200, 0x2B2B2B, 0x121212, 1, true)
  794. ui.addTextArea(667, "<p align='center'><font color='#2F7FCC'>" ..
  795. (table.concat(teams.Team2, "\n") or ""), nil, 450, 140,
  796. 175, 200, 0x2B2B2B, 0x121212, 1, true)
  797. ui.addTextArea(664, "<p align='center'><font color='#CB546B'><b>Team 1",
  798. nil, 143, 115, 190, 20, 0x2B2B2B, 0x121212, 1, true)
  799. ui.addTextArea(665, "<p align='center'><font color='#2F7FCC'><b>Team 2",
  800. nil, 443, 115, 190, 20, 0x2B2B2B, 0x121212, 1, true)
  801. ui.addTextArea(668,
  802. "<p align='center'><V><a href='event:iniciarJuego'><font color='#F93018'><b>Iniciar",
  803. nil, 363, 140, 0, 0, 0x2B2B2B, 0x121212, 1, true)
  804. ui.addTextArea(663, "", nil, 290, 343, 200, 13, 0x2B2B2B, 0x121212, 1, true)
  805. ui.addTextArea(669,
  806. "<p align='center'><V><a href='event:equiposRandom'><font color='#00C17C'><b>Llenar",
  807. nil, 463, 341, 0, 0, 0x2B2B2B, 0x121212, 1, true)
  808. ui.addTextArea(670,
  809. "<p align='center'><V><a href='event:vaciarTeams'><font color='#00C17C'><b>Vaciar",
  810. nil, 263, 341, 0, 0, 0x2B2B2B, 0x121212, 1, true)
  811. end
  812.  
  813. function cantidadMaps()
  814. if juego_activo == false then
  815. for name in pairs(admin) do
  816. ui.addTextArea(671,
  817. "<b><font color='#00C17C' size ='12'>Ez Maps " ..
  818. c_ez ..
  819. "</font>\n<font color='#EBC244' size ='12'>Med Maps " ..
  820. c_m ..
  821. "</font>\n<font color='#CB546B' size ='12'>Hard Maps " ..
  822. c_h ..
  823. "</font>\n<font color='#F93018' size ='12'>Ult Maps " ..
  824. c_u ..
  825. "</font>\n\n<BV><font size ='12'>Time Map " ..
  826. time_map .. "\nTime Lob " .. time_lobby, name,
  827. 10, 143, 100, 0, 0x2B2B2B, 0x121212, 0.7, true)
  828. end
  829. end
  830. end
  831.  
  832. function main()
  833. tfm.exec.newGame(7692636)
  834. grafico()
  835. tfm.exec.setGameTime(10000)
  836. cantidadMaps()
  837. end
  838.  
  839. main()
  840.  
  841. function eventPlayerRespawn(playerName) playerInfo.alreadyRespawn[playerName] = true end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement