Advertisement
alditojeje

Untitled

Nov 10th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.52 KB | None | 0 0
  1. -- TODO:
  2. -- sistema admin, graficos, checkpoints, terminar que cambie el mapa cuando ganen, score arriba grafico
  3.  
  4. adm="Blood#3565"
  5. tfm.exec.disableAfkDeath(true)
  6. tfm.exec.disableAutoShaman()
  7. tfm.exec.disableAutoTimeLeft()
  8. tfm.exec.disablePhysicalConsumables()
  9. tfm.exec.disableAutoScore()
  10. tfm.exec.disableMinimalistMode()
  11. tfm.exec.newGame(7657121)
  12. tfm.exec.disableAutoNewGame(false)
  13. system.disableChatCommandDisplay("mapa", true)
  14. system.disableChatCommandDisplay("texto", true)
  15.  
  16. enJuego = false
  17. contTeam1 = 0
  18. contTeam2 = 0
  19. verTexto = true
  20. tiempoJugado = 0
  21. puntosParaGanar = 5
  22. local gameRunning = false
  23. local teams = {Team1 = {}, Team2 = {}}
  24. local puntos = {team1Puntos = 0, team2Puntos = 0}
  25. local maps = {7623375, 7618265, 7598750, 7572953, 7569215, 7565716, 7569454, 7571727, 7568533, 7566172, 7570693, 7197833, 7573427, 7142793, 7565563, 7571737, 7568384, 7566459, 7571491, 7568359, 7568830, 7171137, 7356802, 7506432, 4612890, 7172091, 7565705, 7196916, 7367964}
  26.  
  27. function eventLoop (elapsedTime, remainingTime )
  28. tiempoJugado = elapsedTime
  29. if enJuego then
  30. if remainingTime <= 2823 then
  31. newMap()
  32. end
  33. else
  34. tfm.exec.disableAutoNewGame(true)
  35. end
  36. end
  37.  
  38. function newMap()
  39. contTeam1 = 0
  40. contTeam2 = 0
  41. local mapcode = maps[math.random(#maps)]
  42. tfm.exec.newGame(mapcode)
  43. establecerColor()
  44. establecerTiempo()
  45. end
  46.  
  47. function eventChatCommand(playerName, command, puntos)
  48.  
  49. if playerName == adm then
  50. if command == "mapa" and enJuego then
  51. newMap()
  52. end
  53. if command == "texto" then
  54. if verTexto then
  55. verTexto = false
  56. else
  57. verTexto = true
  58. end
  59. textoArea()
  60. end
  61. if command == "puntos" then
  62. puntosParaGanar = puntos
  63. print(puntosParaGanar)
  64. end
  65. end
  66. end
  67. function establecerTiempo()
  68. tfm.exec.setGameTime(1080)
  69. end
  70.  
  71. function establecerTiempoGanar()
  72. tfm.exec.setGameTime(5)
  73. end
  74.  
  75. function eventTextAreaCallback(id, player, callback)
  76. if callback == 'iniciarJuego' and tiempoJugado >= 3683 then
  77. enJuego = true
  78. for i=0, 17,1 do
  79. ui.removeTextArea(i)
  80. end
  81. newMap()
  82. establecerTiempo()
  83. enJuego = true
  84. end
  85. if callback == 'llenarEquipos' then
  86. establecerPuntos()
  87. establecerEquipos()
  88. textoArea()
  89. end
  90. end
  91.  
  92. function eventPlayerDied (playerName)
  93. tfm.exec.respawnPlayer(playerName)
  94. establecerColor()
  95. end
  96.  
  97. -- borrar?
  98. function jugadores()
  99. jugadoresEnSala = 0
  100. for name in pairs(tfm.get.room.playerList) do
  101. jugadoresEnSala = jugadoresEnSala +1
  102. end
  103. function eventPlayerLeft()
  104. jugadoresEnSala = jugadoresEnSala -1
  105. end
  106. end
  107. ----------------
  108.  
  109. function establecerPuntos()
  110. for name in pairs(tfm.get.room.playerList) do
  111. tfm.exec.setPlayerScore(name, 0)
  112. end
  113. end
  114.  
  115.  
  116. function establecerEquipos()
  117. teams.Team1 = {}
  118. teams.Team2 = {}
  119.  
  120. local t = 1
  121. for k in pairs(tfm.get.room.playerList) do
  122. if t == 1 then
  123. table.insert(teams.Team1, k)
  124. t = 2
  125. elseif t == 2 then
  126. table.insert(teams.Team2, k)
  127. t = 1
  128. end
  129. end
  130. end
  131.  
  132. function establecerColor()
  133. for i, v in pairs(teams.Team1) do
  134. tfm.exec.setNameColor(v, 0xE2FF14)
  135. end
  136. for i, v in pairs(teams.Team2) do
  137. tfm.exec.setNameColor(v, 0x2F7FCC)
  138. end
  139. end
  140.  
  141. function eventPlayerWon ( playerName, timeElapsed, timeElapsedSinceRespawn )
  142.  
  143. for i, v in pairs(teams.Team1) do
  144. if playerName == v then
  145. contTeam1 = contTeam1 +1
  146. print(contTeam1)
  147. end
  148. end
  149. for i,v in pairs (teams.Team2) do
  150. if playerName == v then
  151. contTeam2 = contTeam2 +1
  152. print(contTeam2)
  153. end
  154. end
  155. equipoPunto()
  156.  
  157. end
  158.  
  159. function equipoPunto()
  160. if contTeam1 == 3 then
  161. puntos.team1Puntos = puntos.team1Puntos + 1
  162. contTeam1 = 0
  163. contTeam2 = 0
  164. establecerTiempoGanar()
  165. end
  166. if contTeam2 == 3 then
  167. puntos.team1Puntos = puntos.team2Puntos + 1
  168. contTeam1 = 0
  169. contTeam2 = 0
  170. establecerTiempoGanar()
  171. end
  172. if puntos.team1Puntos >= puntosParaGanar then
  173. team1Gano = true
  174. ganador()
  175. end
  176. if puntos.team2Puntos >= puntosParaGanar then
  177. ganador()
  178. end
  179. end
  180.  
  181. function ganador()
  182. tfm.exec.newGame(7589151)
  183. if team1Gano then
  184. print ("equp1")
  185. else
  186. print ("equp2")
  187. end
  188. end
  189.  
  190. -- GRAFICO --
  191.  
  192. function textoArea()
  193. if verTexto then
  194. ui.addTextArea(0, "", nil, 200, 62, 400, 12, 0x324650, 0x121212, 0.7, true)
  195. ui.addTextArea(1, "", nil, 200, 44, 400, 12, 0x324650, 0x121212, 1, true)
  196. ui.addTextArea(2, "<p align='center'><font color='#00ff40'><b>" ..(adm), nil, 320, 36, 150, 20, 0x324650, 0x121212, 1, true)
  197. ui.addTextArea(3, "<p align='center'><font color='#E2FF14'>" .. (table.concat(teams.Team1,"\n") or ""), nil, 15, 72, 180, 266, 0x324650, 0x121212, 1, true)
  198. ui.addTextArea(4, "<p align='center'><font color='#2F7FCC'>" .. (table.concat(teams.Team2,"\n") or ""), nil, 605, 72, 180, 266, 0x324650, 0x121212, 1, true)
  199. ui.addTextArea(5, "<p align='center'><font color='#E2FF14'><b>Team 1", nil, 10, 44, 190, 20, 0x324650, 0x121212, 1, true)
  200. ui.addTextArea(6, "<p align='center'><font color='#2F7FCC'><b>Team 2", nil, 600, 44, 190, 20, 0x324650, 0x121212, 1, true)
  201. ui.addTextArea(7, "<p align='center'><V><a href='event:iniciarJuego'><font color='#CA2411'><b>Iniciar", adm, 375, 60, 0, 0, 0x324650, 0x121212, 1, true)
  202. ui.addTextArea(8, "<p align='center'><V><a href='event:llenarEquipos'><font color='#CA2411'><b>Llenar", adm, 240, 50, 0, 0, 0x324650, 0x121212, 1, true)
  203. else
  204. for i=0, 17,1 do
  205. ui.removeTextArea(i)
  206. end
  207. end
  208. end
  209.  
  210. establecerTiempo()
  211. textoArea()
  212. establecerPuntos()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement