SHARE
TWEET

Untitled

a guest Nov 19th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. This script is usable in https://www.haxball.com/headless
  3. Steps:
  4.     1) Copy this script
  5.     2) Go to the link, then press F12
  6.     3) Go to console if it's not already set, then paste
  7.     4) Enter
  8.     5) IF THIS TAB IS CLOSED THE ROOM WILL BE CLOSED TOO
  9. */
  10.  
  11. var maxPlayers = 12;
  12.  
  13. var room = HBInit({ roomName: "FUTSAL NOOBS 3V3β–ˆ", maxPlayers: maxPlayers, playerName : "πŸ“£", public : true});
  14. room.setDefaultStadium("Classic");
  15. room.setScoreLimit(5);
  16. room.setTimeLimit(3);
  17.  
  18.  
  19. var goalPts = 3;
  20. var assistPts = 2;
  21. var winPts = 5;
  22. var csPts = 3;
  23. var losePts = -5;
  24. var ogPts = 0;
  25.  
  26.  
  27.  
  28.  
  29. var boldedNumbers = 'πŸŽπŸπŸπŸ‘πŸ’πŸ“πŸ”πŸ•πŸ–πŸ—';
  30. var circledNumbers = 'πŸ„‹β“΅β“Άβ“·β“Έβ“Ήβ“Ίβ“»β“Όβ“½';
  31.  
  32. function boldedNumber(num){
  33.     var result = '';
  34.     var reversedDigits = [];
  35.     do{
  36.         reversedDigits.push(num % 10);
  37.         num = Math.floor(num / 10);
  38.     }while(num > 0);
  39.     for (var i = reversedDigits.length; i-- > 0; ){
  40.         result += boldedNumbers.substr(reversedDigits[i]*2, 2);
  41.     }
  42.    
  43.     return result;
  44. }
  45.  
  46. function circledNumber(num){
  47.     var result = '';
  48.     var reversedDigits = [];
  49.     do{
  50.         reversedDigits.push(num % 10);
  51.         num = Math.floor(num / 10);
  52.     }while(num > 0);
  53.     for (var i = reversedDigits.length; i-- > 0; ){
  54.         if(reversedDigits[i] == 0){
  55.             result += circledNumbers.substr(reversedDigits[i], 2);
  56.         }else{
  57.             result += circledNumbers.substr(1+reversedDigits[i], 1);
  58.         }
  59.     }
  60.    
  61.     return result;
  62. }
  63.  
  64. /*
  65.     Functions
  66. */
  67. // If there are no admins left in the room give admin to one of the remaining players.
  68. function updateAdmins() {
  69.   // Get all players except the host (id = 0 is always the host)
  70.   var players = room.getPlayerList().filter((player) => player.id != 0 );
  71.   if ( players.length == 0 ) return; // No players left, do nothing.
  72.   if ( players.find((player) => player.admin) != null ) return; // There's an admin left so do nothing.
  73.   room.setPlayerAdmin(players[0].id, true); // Give admin to the first non admin player in the list
  74. }
  75.  
  76. function initPlayerStats(player){
  77.     if (stats.get(player.name)) return;
  78.     stats.set(player.name, [0, 0, 0, 0, 0, 0, 0, 0]) // goals, assists, wins, loses, og, cs, games, games on GK
  79. }
  80.  
  81.  
  82.  
  83. /*
  84. for commands
  85. */
  86.  
  87. function swapFun(player){
  88.     if (player.admin == true){
  89.         if (room.getScores() == null) {
  90.             players = room.getPlayerList();
  91.             for (i = 0; i < players.length; i++){
  92.                 if (players[i].team == 1){
  93.                     room.setPlayerTeam(players[i].id, 2);
  94.                 }
  95.                 else if (players[i].team == 2){
  96.                     room.setPlayerTeam(players[i].id, 1);
  97.                 }
  98.             }
  99.         }
  100.     }
  101.     return false;
  102. }
  103.  
  104.  
  105. function pushMuteFun(player, message){ // !mute Anddy
  106.     // Prevent somebody to talk in the room (uses the nickname, not the id)
  107.     // need to be admin
  108.     if (player.admin == true){
  109.         var PlayerMutado = message.substr(6);
  110.        
  111.        
  112.         if (!(mutedPlayers.includes(mutedPlayer))){
  113.             mutedPlayers.push(mutedPlayer);
  114.             room.sendChat('πŸ”‡ ' + mutedPlayer + ' has been muted');
  115.            
  116.         }
  117.     }
  118.     return false;
  119. }
  120.  
  121.  
  122. function gotMutedFun(player){
  123.     if (mutedPlayers.includes(player.name)){
  124.         return true;
  125.     }
  126. }
  127.  
  128. function unmuteFun(player, message){ // !unmute Anddy
  129.     // Allow somebody to talk if he has been muted
  130.     // need to be admin
  131.     if (player.admin == true){
  132.         mutedPlayer = message.substr(8);
  133.         pos = mutedPlayers.indexOf(mutedPlayer);
  134.         mutedPlayers.splice(pos, 1);
  135.         room.sendChat('πŸ”ˆ ' + mutedPlayer + ' has been unmuted');
  136.     }
  137.     return false;
  138. }
  139.  
  140. function helpFun() { // !help
  141.     room.sendChat('πŸ’¬ Comandos Disponiveis: "!stats Nickname", "!ranking", "!poss", "!resetstats", "!adminhelp", "!gkhelp", "!rankhelp"');
  142. }
  143.  
  144. function adminHelpFun() {
  145.     room.sendChat('πŸ’¬ Comandos de ADM: !mute {nick}, !unmute {nick}, ' +
  146.     '!clearbans, !rr, !resetranking, !reset {nick}, !slot {nick}, !clearslot, !last, !clearlast')
  147. }
  148.  
  149. function gkHelpFun() { // !gkhelp
  150.     room.sendChat('πŸ’¬ The most backward player at the kick off will be set as gk ! (write "!gk" if the bot was wrong).')
  151. }
  152.  
  153. function rankHelpFun() { // !rankhelp
  154.     room.sendChat("πŸ’¬ Obtenha pontos para ser o REI da sala ! Goal: " + goalPts + " pts, assist: " + assistPts + " pts, win: " + winPts + " pts, lose: " + losePts + " pts, cs: " + csPts + " pts.")
  155. }
  156.  
  157.  
  158. function statsFun(player, message){ // !stats Anddy
  159.     if (stats.get(message.substr(7))){
  160.         sendStats(message.substr(7));
  161.     }
  162. }
  163.  
  164. function rankFun() { // !ranking
  165.     string = ranking();
  166.     room.sendChat("πŸ† Ranking: " + string);
  167.     //room.sendChat("πŸ“œ Ranking: " + string);
  168. }
  169.  
  170. function resetPlayerStatsFun (player, message){ // !reset Anddy
  171.     if (player.admin == true){
  172.         var playerName = message.substr(7);
  173.         stats.set(playerName, [0,0,0,0,0,0,0,0]);
  174.         room.sendChat(playerName + "'s stats have been reset ! ")
  175.     }
  176.     return false;
  177. }
  178.  
  179. function resetStatsFun (player){ // !resetstats
  180.     if (rankingCalc(player.name) > 0){
  181.         stats.set(player.name, [0,0,0,0,0,0,0,0]);
  182.         room.sendChat('Your stats have been reset ! ')
  183.     }
  184.     else (room.sendChat('Sorry, you must have positive points to be able to reset it'))
  185. }
  186.  
  187. function resetRankingFun(player){
  188.     if (player.admin == true){
  189.         var players = room.getPlayerList();
  190.         for(var i = 0; i < players.length; i++) {
  191.             stats.set(players[i].name, [0,0,0,0,0,0]);
  192.         }
  193.         room.sendChat("Ranking has been reset by admin! ")
  194.     }
  195.     return false;
  196. }
  197.  
  198. function clearFun(player){ // !clear
  199.     if (player.admin == true){
  200.         room.clearBans();
  201.     }
  202.     return false;
  203. }
  204.  
  205. function resetFun(player){
  206.     if (player.admin == true){
  207.         room.stopGame();
  208.         room.startGame();
  209.     }
  210.     return false;
  211. }
  212.  
  213. function gkFun(player){ // !gk
  214.  
  215.     if (room.getScores() != null && room.getScores().time < 60){
  216.         if (player.team == 1) {
  217.             gk[0] = player;
  218.         }
  219.         else if (player.team == 2){
  220.             gk[1] = player;
  221.         }
  222.     }
  223. }
  224.  
  225. var slotReservationNick = '';
  226. function slotFun(player, message){  // !slot Anddy
  227.     if (player.admin == true){
  228.         slotReservationNick = message.substr(6);
  229.     }
  230.     return false;
  231. }
  232.  
  233. function clearSlotFun(player){  // !clearslot
  234.     if (player.admin == true){
  235.         slotReservationNick = '';
  236.     }
  237.     return false;
  238. }
  239.  
  240. var isLastGame = false;
  241. function lastGameFun(player){
  242.     if (player.admin == true){
  243.         isLastGame = true;
  244.     }
  245.     return false;
  246. }
  247.  
  248. function clearLastGameFun(player){
  249.     if (player.admin == true){
  250.         isLastGame = false;
  251.     }
  252.     return false;
  253. }
  254.  
  255. function sendOnlyForAdminMsg(){
  256.    room.sendChat("β›” Comando sΓ³ para adms!");
  257. }
  258.  
  259.    
  260. /*
  261.     For ranking
  262. */
  263.  
  264. function rankingCalc(player){
  265.     /*return stats.get(player)[0] * 3 + stats.get(player)[1] * 2 +
  266.             stats.get(player)[2] * 5 + stats.get(player)[5] * 3 -
  267.             stats.get(player)[3] * 7 - stats.get(player)[4] * 0;*/
  268.     return stats.get(player)[0] * goalPts + stats.get(player)[1] * assistPts +
  269.         stats.get(player)[2] * winPts + stats.get(player)[5] * csPts +
  270.         stats.get(player)[3] * losePts - stats.get(player)[4] * ogPts;
  271. }
  272.  
  273. function ranking(){
  274.  
  275.     var overall = [];
  276.     players = Array.from(stats.keys());
  277.     for (var i = 2; i < players.length; i++) {
  278.         score = rankingCalc(players[i])
  279.         // Goal: 3 pts, assist: 2 pts, win: 5 pts, cs: 3 pts, lose: -7 pts, og: 0 pts
  280.         overall.push({name: players[i], value: score, games: stats.get(players[i])[6]});
  281.     }
  282.     overall.sort(function(a,b){
  283.         return b.value - a.value;
  284.     })
  285.     result = '';
  286.  
  287.     var position = 1;
  288.     for (var i = 0; i < overall.length; i++) {
  289.         //if(i > 0){
  290.         //  result += ', ';
  291.         //}
  292.         if (overall[i].games > 0){
  293.             result += circledNumber(position) + ' ' + overall[i].name + ': ' + overall[i].value + ' ';
  294.             position++;
  295.         }
  296.     }
  297.     return result;
  298. }
  299.  
  300. function sendStats(name){
  301.     var ranking = rankingCalc(name);
  302.     ps = stats.get(name); // stands for playerstats
  303.     room.sendChat(name + ": goals: " + ps[0] + ", assists: " + ps[1]
  304.     + ", cs: " + ps[5] + "/" + ps[7] +" , wins: " + ps[2] + ", loses: " + ps[3] +
  305.     ", points: " + ranking + ", avg: " + (Math.round(100 * ranking/ (ps[6]+ 0.0000001) )/100));
  306. }
  307.  
  308.  
  309. function whichTeam(){ // gives the players in the red or blue team
  310.     var players = room.getPlayerList();
  311.     var redTeam = players.filter(player => player.team == 1);
  312.     var blueTeam = players.filter(player => player.team == 2);
  313.     return [redTeam, blueTeam]
  314. }
  315.  
  316. function isGk(){ // gives the mosts backward players before the first kickOff
  317.     var players = room.getPlayerList();
  318.     var min = players[0];
  319.     min.position = {x: room.getBallPosition().x + 60}
  320.     var max = min;
  321.  
  322.     for (var i = 0; i < players.length; i++) {
  323.         if (players[i].position != null){
  324.             if (min.position.x > players[i].position.x) min = players[i];
  325.             if (max.position.x < players[i].position.x) max = players[i];
  326.         }
  327.     }
  328.     return [min, max]
  329. }
  330.  
  331.  
  332. function updateWinLoseStats(winners, losers){
  333.     for (var i = 0; i < winners.length; i++) {
  334.         stats.get(winners[i].name)[2] += 1;  //wins
  335.         stats.get(winners[i].name)[6] += 1;  // total games
  336.     }
  337.     for (var i = 0; i < losers.length; i++) {
  338.         stats.get(losers[i].name)[3] += 1;  // loses
  339.         stats.get(losers[i].name)[6] += 1;  // total games
  340.     }
  341. }
  342.  
  343. function initBallCarrying(redTeam, blueTeam){
  344.     var ballCarrying = new Map();
  345.     var playing = redTeam.concat(blueTeam);
  346.     for (var i = 0; i < playing.length; i++) {
  347.         ballCarrying.set(playing[i].name, [0, playing[i].team]); // secs, team, %
  348.     }
  349.     return ballCarrying;
  350. }
  351.  
  352.  
  353.  
  354. function updateTeamPoss(value){
  355.     if (value[1] == 1) redPoss += value[0];
  356.     if (value[1] == 2) bluePoss += value[0];
  357. }
  358.  
  359. var bluePoss;
  360. var redPoss;
  361. var timeOnHalves;
  362. function teamPossFun(){
  363.     if (room.getScores() == null) return false;
  364.     bluePoss = 0;
  365.     redPoss = 0
  366.     ballCarrying.forEach(updateTeamPoss);
  367.     var redPossPercent = Math.round((redPoss / (redPoss + bluePoss + 0.000001)) * 100);
  368.     var bluePossPercent = Math.round((bluePoss / (redPoss + bluePoss + 0.000001)) * 100);
  369.     room.sendChat("β›Ή Posse de bola: πŸ”΄ " + boldedNumber(redPossPercent) + "% - " + boldedNumber(bluePossPercent) + "% πŸ”΅" );
  370.    
  371.     var timeOnRedHalf = Math.round((timeOnHalves[0] / (timeOnHalves[0] + timeOnHalves[1] + 0.000001)) * 100);
  372.     var timeOnBlueHalf = Math.round((timeOnHalves[1] / (timeOnHalves[0] + timeOnHalves[1] + 0.000001)) * 100);
  373.     room.sendChat("β—§ Game time on halves : πŸ”΄ " + boldedNumber(timeOnRedHalf) + "% - " + boldedNumber(timeOnBlueHalf) + "% πŸ”΅" );
  374.     return false;
  375. }
  376.  
  377.  
  378.  
  379. /*
  380. For the game
  381. */
  382.  
  383. // Gives the last player who touched the ball, works only if the ball has the same
  384. // size than in classics maps.
  385. var radiusBall = 10;
  386. var triggerDistance = radiusBall + 15 + 0.1;
  387. function getLastTouchTheBall(lastPlayerTouched, time) {
  388.     var ballPosition = room.getBallPosition();
  389.     var players = room.getPlayerList();
  390.     for(var i = 0; i < players.length; i++) {
  391.         if(players[i].position != null) {
  392.             var distanceToBall = pointDistance(players[i].position, ballPosition);
  393.             if(distanceToBall < triggerDistance) {
  394.                 lastPlayerTouched = players[i];
  395.                 return lastPlayerTouched;
  396.             }
  397.         }
  398.     }
  399.     return lastPlayerTouched;
  400.  
  401. }
  402.  
  403.  
  404.  
  405. // Calculate the distance between 2 points
  406. function pointDistance(p1, p2) {
  407.     var d1 = p1.x - p2.x;
  408.     var d2 = p1.y - p2.y;
  409.     return Math.sqrt(d1 * d1 + d2 * d2);
  410. }
  411.  
  412.  
  413. // return: the name of the team who took a goal
  414. var team_name = team => team == 1 ? "πŸ”΄ Red" : "πŸ”΅ Blue";
  415.  
  416. var team_color = team => team == 1 ? "πŸ”΄" : "πŸ”΅";
  417.  
  418.  
  419. // return: whether it's an OG
  420. var isOwnGoal = (team, player) => team != player.team ? " (og)" : "";
  421.  
  422. // return: whether there's an assist
  423. var playerTouchedTwice = playerList => playerList[0].team == playerList[1].team ? " (" + playerList[1].name + ")" : "";
  424.  
  425.  
  426.  
  427. /*
  428. Events
  429. */
  430. var stats = new Map(); // map where will be set all player stats
  431. var mutedPlayers = []; // Array where will be added muted players
  432. var init = "init"; // Smth to initialize smth
  433. init.id = 0; // Faster than getting host's id with the method
  434. init.name = "init";
  435. var scorers ; // Map where will be set all scorers in the current game (undefined if reset or end)
  436. var whoTouchedLast; // var representing the last player who touched the ball
  437. var whoTouchedBall = [init, init]; // Array where will be set the 2 last players who touched the ball
  438. var gk = [init, init];
  439. var goalScored = false;
  440.  
  441. var commands = {
  442.     // Command that doesnt need to know players attributes.
  443.     "!help": helpFun,
  444.     "!gkhelp": gkHelpFun,
  445.     "!adminhelp": adminHelpFun,
  446.     "!rankhelp": rankHelpFun,
  447.     "!ranking": rankFun,
  448.     "!poss": teamPossFun,
  449.  
  450.     // Command that need to know who is the player.
  451.     "!resetstats": resetStatsFun,
  452.     "!gk": gkFun,
  453.  
  454.     // Command that need to know if a player is admin.
  455.     "!swap": swapFun,
  456.     "!rr": resetFun,
  457.     "!clearbans": clearFun,
  458.     "!resetranking": resetRankingFun,
  459.     "!reset": resetPlayerStatsFun,
  460.     "!slot": slotFun,
  461.     "!clearslot": clearSlotFun,
  462.     "!last": lastGameFun,
  463.     "!clearlast": clearLastGameFun,
  464.  
  465.     // Command that need to know what's the message.
  466.     "!stats": statsFun,
  467.  
  468.     // Command that need to know who is the player and what's the message.
  469.     "!mute" : pushMuteFun,
  470.     "!unmute": unmuteFun
  471.  
  472. }
  473.  
  474.  
  475. initPlayerStats(room.getPlayerList()[0]) // lazy lol, i'll fix it later
  476. initPlayerStats(init);
  477.  
  478. room.onPlayerLeave = function(player) {
  479.   updateAdmins();
  480. }
  481.  
  482.  
  483.  
  484. room.onPlayerJoin = function(player) {
  485.     if(isLastGame){
  486.         room.kickPlayer(player.id, 'Last game', false);
  487.         return;
  488.     }
  489.     var players = room.getPlayerList().filter((player) => player.id != 0 );
  490.     if(slotReservationNick && players.length == maxPlayers && slotReservationNick != player.name){
  491.         room.kickPlayer(player.id, 'Sorry, last slot is reserved. Try again later!', false);
  492.         return;
  493.     }
  494.     if(slotReservationNick == player.name){
  495.         slotReservationNick = '';
  496.     }
  497.     updateAdmins(); // Gives admin to the first player who join the room if there's no one
  498.     initPlayerStats(player); // Set new player's stat
  499.     room.sendChat("πŸ’¬ OlΓ‘ " + player.name + " ! Escreva !help, !adminhelp, !rankhelp." )
  500. }
  501.  
  502. var redTeam;
  503. var blueTeam;
  504. room.onGameStart = function() {
  505.     [redTeam,blueTeam] = whichTeam();
  506.     ballCarrying = initBallCarrying(redTeam, blueTeam);
  507.     timeOnHalves = [0,0];
  508. }
  509.  
  510. room.onPlayerTeamChange = function(player, byPlayer){
  511.     console.log('room.onPlayerTeamChange');
  512.     console.log(player);
  513.     console.log(byPlayer);
  514.     if (room.getScores() != null){
  515.         if (1 <= player.team <= 2) {
  516.             ballCarrying.set(player.name, [0, player.team]);
  517.         }
  518.        
  519.     }
  520. }
  521.  
  522.  
  523.  
  524. room.onPlayerChat = function(player, message) {
  525.     if (mutedPlayers.includes(player.name)) return false;
  526.     let spacePos = message.search(" ");
  527.     let command = message.substr(0, spacePos !== -1 ? spacePos : message.length);
  528.     if (commands.hasOwnProperty(command) == true) return commands[command](player, message);
  529.  
  530. }
  531.  
  532.  
  533.  
  534.  
  535. room.onPlayerBallKick = function (player){
  536.     whoTouchedLast = player;
  537. }
  538.  
  539. var kickOff = false;
  540.  
  541. room.onGameTick = function() {
  542.  
  543.  
  544.     if (kickOff == false) { // simplest comparison to not charge usulessly the tick thing
  545.         if (room.getScores().time != 0){
  546.             kickOff = true;
  547.             gk = isGk();
  548.             room.sendChat("Goalkeepers: πŸ”΄ " + gk[0].name + ", πŸ”΅ " + gk[1].name);
  549.         }
  550.     }
  551.     if (goalScored == false){
  552.         whoTouchedLast = getLastTouchTheBall(whoTouchedLast);
  553.     }
  554.     if (whoTouchedLast != undefined) {
  555.  
  556.         if (ballCarrying.get(whoTouchedLast.name)) {
  557.             ballCarrying.get(whoTouchedLast.name)[0] += 1/60;
  558.         }
  559.  
  560.         if  ( whoTouchedLast.id != whoTouchedBall[0].id){
  561.             whoTouchedBall[1] = whoTouchedBall[0];
  562.             whoTouchedBall[0] = whoTouchedLast; // last player who touched the ball
  563.         }
  564.     }
  565.     updateTimeOnHalves();
  566. }
  567.  
  568. updateTimeOnHalves = function(){
  569.     if(room.getBallPosition().x < 0){
  570.         timeOnHalves[0] += 1/60;
  571.     }else if(room.getBallPosition().x > 0){
  572.         timeOnHalves[1] += 1/60;
  573.     }
  574. }
  575.  
  576. function formatTime(time){
  577.     var result = '';
  578.     var m = Math.trunc(time/60); var s = Math.trunc(time % 60);
  579.     result = boldedNumber(m) + ':';
  580.     if(s < 10){
  581.         result+= boldedNumber(0) + boldedNumber(s);
  582.     }else{
  583.         result+= boldedNumber(s);
  584.     }
  585.     return result;
  586. }
  587.  
  588.  
  589. room.onTeamGoal = function(team){ // Write on chat who scored and when.
  590.  
  591.     goalScored = true;
  592.     var time = formatTime(room.getScores().time);
  593.     var ownGoal = isOwnGoal(team, whoTouchedBall[0]);
  594.     var assist = "";
  595.     if (ownGoal == "") assist = playerTouchedTwice(whoTouchedBall);
  596.  
  597.  
  598.     room.sendChat("⚽ " + time + " - " + whoTouchedBall[0].name + assist + ownGoal + " " + team_color(1) + " " +
  599.                     boldedNumber(room.getScores().red) + " - " + boldedNumber(room.getScores().blue) + " " + team_color(2));
  600.    
  601.     //room.sendChat("⚽ Gol Marcado por " + whoTouchedBall[0].name +
  602.     // assist + ownGoal + " at " +
  603.     // time + " for team " + team_name(team));
  604.  
  605.      if (ownGoal != "") {
  606.          stats.get(whoTouchedBall[0].name)[4] += 1;
  607.      } else {
  608.          stats.get(whoTouchedBall[0].name)[0] += 1;
  609.      }
  610.  
  611.     if (whoTouchedBall[1] != init && assist != "") stats.get(whoTouchedBall[1].name)[1] += 1;
  612.  
  613.  
  614.     if (scorers == undefined) scorers = []; // Initializing array of scorers
  615.     scorers[scorers.length] = [whoTouchedLast.name, [time, assist, ownGoal]];
  616.     whoTouchedBall = [init, init];
  617.     whoTouchedLast = undefined;
  618. }
  619.  
  620. room.onPositionsReset = function(){
  621.     goalScored = false;
  622. }
  623.  
  624. room.onTeamVictory = function(scores){ // Sum up all scorers since the beginning of the match.
  625.     console.log('room.onTeamVictory, ' + scores.time);
  626.     stats.get(gk[0].name)[7] += 1;  // games on gk
  627.     if (scores.blue == 0 && gk[0].position != null ) {
  628.         stats.get(gk[0].name)[5] += 1;
  629.     } else if (Math.round(scores.time) > scores.timeLimit && scores.red == 0 && scores.blue == 1 && gk[0].position != null){
  630.         stats.get(gk[0].name)[5] += 1;
  631.     }
  632.     stats.get(gk[1].name)[7] += 1;  // games on gk
  633.     if (scores.red == 0 && gk[1].position != null){
  634.         stats.get(gk[1].name)[5] += 1;
  635.     }else if (Math.round(scores.time) > scores.timeLimit && scores.blue == 0 && scores.red == 1 && gk[1].position != null){
  636.         stats.get(gk[1].name)[5] += 1;
  637.     }
  638.     if (scores.red > scores.blue) {
  639.         updateWinLoseStats(redTeam, blueTeam);
  640.     }
  641.     else{ updateWinLoseStats(blueTeam, redTeam); }
  642.  
  643.     room.sendChat("Scorers:")
  644.     for (var [key, value] of scorers) { // key: name of the player, value: time of the goal
  645.         room.sendChat("⚽ " + key + " " + value[1] + value[2] + ": " + value[0]);
  646.     }
  647.     teamPossFun();
  648. }
  649.  
  650. room.onGameStop = function(){
  651.     scorers = undefined;
  652.     whoTouchedBall = [init, init];
  653.     whoTouchedLast = undefined;
  654.     gk = [init, init];
  655.     kickOff = false;
  656. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top