Advertisement
alditojeje

Untitled

Nov 10th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.27 KB | None | 0 0
  1. -- TODO:
  2. -- checkpoints, score arriba grafico, SI NO ES JUGADOR MUERE, arriba poner puntos, establecer score con los puntos
  3. -- añadir jugadores con !team1 etc, cuando se va un jugador quitarlo del team
  4. adm="Alditohacker#0000"
  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("text", true)
  14.  
  15. enJuego = false
  16. contTeam1 = 0
  17. contTeam2 = 0
  18. verTexto = true
  19. tiempoJugado = 0
  20. puntosParaGanar = 5
  21. scoreTeams = 3
  22. args = {}
  23. jugador = false
  24. active = true
  25. local teams = {Team1 = {}, Team2 = {}}
  26. local puntos = {team1Puntos = 0, team2Puntos = 0}
  27. 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}
  28.  
  29. function eventLoop (elapsedTime, remainingTime )
  30. tiempoJugado = elapsedTime
  31.  
  32. if remainingTime <= 2823 then
  33. newMap()
  34. end
  35. end
  36.  
  37. function newMap()
  38. -- active = false
  39. enJuego = true
  40. contTeam1 = 0
  41. contTeam2 = 0
  42. local mapcode = maps[math.random(#maps)]
  43. tfm.exec.newGame(mapcode)
  44. establecerColor()
  45. establecerTiempo()
  46. end
  47.  
  48. function eventChatCommand(playerName, command)
  49. if playerName == adm then
  50. args = string.split(command, " ")
  51.  
  52. if args[1] == "skip" and enJuego then
  53. newMap()
  54. end
  55. if args[1] == "text" and enJuego == false then
  56. if verTexto then
  57. verTexto = false
  58. else
  59. verTexto = true
  60. end
  61. end
  62.  
  63. if args[1] == "d" then
  64. puntosParaGanar = args[2]
  65. end
  66. if args[1] == "pointsteam" or args[1] == "pointsteams" or args[1] == "pointeams" or args[1] == "pt" then
  67. scoreTeams = args[2]
  68. print(scoreTeams)
  69. end
  70. if args[1] == "add" then -- si el comando es add
  71. if args[2] == "team1" then -- y sigue con team1
  72. for i=3, #args do -- recorre toda la tabla args
  73. for j=1, #teams.Team2 do -- recorre toda la tabla teams2
  74. if args[i] == teams.Team2[j] then -- si un elemento de la tabla args conicide con un elento de la tabla teams2
  75. teams.Team2[j] = "----Removed----" -- reemplaza su nombre por removed
  76. end
  77. end
  78. end
  79. teams.Team1 = {} -- establece vacio la tabla teams1
  80. for i=3, #args do
  81. table.insert (teams.Team1, args[i]) -- le añade a team1 los argumentos escritos.
  82. end
  83. end
  84.  
  85. if args[2] == "team2" then
  86. for i=3, #args do -- recorre toda la tabla args
  87. for j=1, #teams.Team1 do -- recorre toda la tabla teams1
  88. if args[i] == teams.Team1[j] then -- si un elemento de la tabla args conicide con un elento de la tabla teams1
  89. teams.Team1[j] = "----Removed----" -- reemplaza su nombre por removed
  90. end
  91. end
  92. end
  93. teams.Team2 = {}
  94. print(#teams.Team2)
  95. for i=3, #args do
  96. table.insert (teams.Team2, args[i])
  97. end
  98. end
  99. end
  100. textoArea()
  101. end
  102. end
  103.  
  104. function establecerTiempo()
  105. tfm.exec.setGameTime(1080)
  106. end
  107.  
  108. function establecerTiempoGanar()
  109. tfm.exec.setGameTime(10)
  110. end
  111.  
  112. function eventTextAreaCallback(id, player, callback)
  113. if callback == 'iniciarJuego' and tiempoJugado >= 3383 then
  114. verTexto = false
  115. textoArea()
  116. newMap()
  117. establecerTiempo()
  118. end
  119. if callback == 'llenarEquipos' then
  120. establecerPuntos()
  121. establecerEquipos()
  122. textoArea()
  123. end
  124. if callback == 'vaciar' then
  125. teams.Team1 = {}
  126. teams.Team2 = {}
  127. textoArea()
  128. end
  129. end
  130.  
  131. function eventPlayerDied (playerName)
  132. if enJuego == false or matarNoJugadores(playerName) == true then
  133. tfm.exec.respawnPlayer(playerName)
  134. establecerColor()
  135. end
  136. end
  137.  
  138. function eventNewGame ()
  139. if enJuego then
  140. for name in pairs(tfm.get.room.playerList) do
  141. matarNoJugadores(name)
  142. end
  143. end
  144. end
  145.  
  146. function matarNoJugadores(name)
  147. print(name)
  148. for i, v in pairs(teams.Team1) do
  149. if v == name then
  150. jugador = true
  151. end
  152. end
  153. for i, v in pairs(teams.Team2) do
  154. if v == name then
  155. jugador = true
  156. end
  157. end
  158. jugador = false
  159. if jugador == false and enJuego == true then
  160. tfm.exec.killPlayer(name)
  161. end
  162. end
  163.  
  164.  
  165. function establecerPuntos()
  166. for name in pairs(tfm.get.room.playerList) do
  167. tfm.exec.setPlayerScore(name, 0)
  168. end
  169. end
  170.  
  171. function establecerEquipos()
  172. teams.Team1 = {}
  173. teams.Team2 = {}
  174. local t = 1
  175. for k in pairs(tfm.get.room.playerList) do
  176. if t == 1 then
  177. table.insert(teams.Team1, k)
  178. t = 2
  179. elseif t == 2 then
  180. table.insert(teams.Team2, k)
  181. t = 1
  182. end
  183. end
  184. end
  185.  
  186. function establecerColor()
  187. for i, v in pairs(teams.Team1) do
  188. tfm.exec.setNameColor(v, 0xE2FF14)
  189. end
  190. for i, v in pairs(teams.Team2) do
  191. tfm.exec.setNameColor(v, 0x2F7FCC)
  192. end
  193. end
  194.  
  195. function eventPlayerWon (playerName, timeElapsed, timeElapsedSinceRespawn)
  196.  
  197. active = true
  198. tfm.exec.respawnPlayer(playerName)
  199. establecerColor()
  200. system.bindMouse(playerName, active)
  201. system.bindKeyboard(playerName, 32, active)
  202. for i, v in pairs(teams.Team1) do
  203. if playerName == v then
  204. contTeam1 = contTeam1 +1
  205. end
  206. end
  207.  
  208. for i,v in pairs (teams.Team2) do
  209. if playerName == v then
  210. contTeam2 = contTeam2 +1
  211. end
  212. end
  213. equipoPunto()
  214. end
  215.  
  216. function eventKeyboard(name, key, down, px, py)
  217. _space = 32
  218. if active then
  219. if key == _space then
  220. tfm.exec.movePlayer(name, 0, 0, true, 0, -40, true)
  221. end
  222. end
  223. end
  224.  
  225. function eventMouse(name, mx, my)
  226. if active then
  227. tfm.exec.movePlayer(name, mx, my)
  228. end
  229. end
  230.  
  231. function equipoPunto()
  232. if contTeam1 == scoreTeams then
  233. puntos.team1Puntos = puntos.team1Puntos + 1
  234. contTeam1 = 0
  235. contTeam2 = 0
  236. enJuego = false
  237. establecerTiempoGanar()
  238. end
  239. if contTeam2 == scoreTeams then
  240. puntos.team2Puntos = puntos.team2Puntos + 1
  241. contTeam1 = 0
  242. contTeam2 = 0
  243. enJuego = false
  244. establecerTiempoGanar()
  245. end
  246. if puntos.team1Puntos >= puntosParaGanar then
  247. team1Gano = true
  248. ganador()
  249. end
  250. if puntos.team2Puntos >= puntosParaGanar then
  251. ganador()
  252. end
  253. end
  254.  
  255. function ganador()
  256. tfm.exec.newGame(7589151)
  257. if team1Gano then
  258. print ("equp1")
  259. else
  260. print ("equp2")
  261. end
  262. end
  263.  
  264. function string.split(s, pattern, n)
  265. local st = {}
  266. for sb in string.gmatch(s, "[^"..pattern.."]+") do
  267. if not n or n > -1 then
  268. table.insert(st,sb)
  269. else
  270. st[#st] = st[#st]..pattern..sb
  271. end
  272. n = n and n-1 or false
  273. end
  274. return st
  275. end
  276.  
  277. -- GRAFICO --
  278.  
  279. function textoArea()
  280. if verTexto then
  281. ui.addTextArea(0, "", nil, 200, 62, 400, 12, 0x324650, 0x121212, 0.7, true)
  282. ui.addTextArea(1, "", nil, 200, 44, 400, 12, 0x324650, 0x121212, 1, true)
  283. ui.addTextArea(2, "<p align='center'><font color='#00C17C'><b>" ..(adm), nil, 320, 36, 150, 20, 0x324650, 0x121212, 1, true)
  284. ui.addTextArea(3, "<p align='center'><font color='#E2FF14'>" .. (table.concat(teams.Team1,"\n") or ""), nil, 15, 72, 180, 266, 0x324650, 0x121212, 1, true)
  285. ui.addTextArea(4, "<p align='center'><font color='#2F7FCC'>" .. (table.concat(teams.Team2,"\n") or ""), nil, 605, 72, 180, 266, 0x324650, 0x121212, 1, true)
  286. ui.addTextArea(5, "<p align='center'><font color='#E2FF14'><b>Team 1", nil, 10, 44, 190, 20, 0x324650, 0x121212, 1, true)
  287. ui.addTextArea(6, "<p align='center'><font color='#2F7FCC'><b>Team 2", nil, 600, 44, 190, 20, 0x324650, 0x121212, 1, true)
  288. ui.addTextArea(7, "<p align='center'><V><a href='event:iniciarJuego'><font color='#F93018'><b>Iniciar", adm, 375, 60, 0, 0, 0x324650, 0x121212, 1, true)
  289. ui.addTextArea(8, "<p align='center'>ScoreT: <font color='#00C17C'><b>" ..(scoreTeams), nil, 225, 36, 70, 20, 0x324650, 0x121212, 1, true)
  290. ui.addTextArea(9, "<p align='center'><V><a href='event:llenarEquipos'><font color='#F93018'><b>Llenar", adm, 240, 60, 0, 0, 0x324650, 0x121212, 1, true)
  291. ui.addTextArea(10, "<p align='center'>Score: <font color='#00C17C'><b>" ..(puntosParaGanar), nil, 500, 36, 70, 20, 0x324650, 0x121212, 1, true)
  292. ui.addTextArea(11, "<p align='center'><V><a href='event:vaciar'><font color='#F93018'><b>Vaciar", adm, 515, 60, 0, 0, 0x324650, 0x121212, 1, true)
  293. establecerColor()
  294. else
  295. for i=0, 17,1 do
  296. ui.removeTextArea(i)
  297. end
  298. end
  299. end
  300.  
  301. establecerTiempo()
  302. textoArea()
  303. establecerPuntos()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement