Advertisement
alditojeje

Untitled

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