<commit_before>'use strict';



events.Add("Checks", function()
{

   console.log("Check!"); //print on the console that the event is run.

if(!Started)
{
  if(!beingStart && jcmp.players.length >= battleroyale.config.game.minPlayers)
  {
    battleroyale.chat.broadcast("Minimum number of players reached to start");
      battleroyale.chat.broadcast("Game is going to start in 3 minutes");
    beingStart = true;
    global.beingStartTimer = setTimeout(function() {
      events.Call('OnBattleStart');
    }, battleroyale.utils.minutes(3));
  }

  if(beingStart && jcmp.players.length < battleroyale.config.game.minPlayers)
  {
    clearTimeout(global.beingStartTimer);
    let needplayers = battleroyale.config.game.minPlayers - jcmp.players.length;
    battleroyale.chat.broadcast("Need " + needplayers + " players more");
  }
} else { // if Started == true and the game is launch check if player is out of area

  for(let player of g_pingame) { // Check if player was in area.
    if(!battleroyale.utils.IsPointInCircle(player.position, battleArea.position, battleArea.radius)) {
      // Change player health -2
      setInterval(function() {  events.Call('OnPlayerOutArea',player);  }, battleroyale.utils.seconds(15)); //battleroyale.events.OnPlayerOutArea(player);
    }

    //timeLeft.seconds -= 1;

  }

    if(timeLeft.seconds <= 0) {
      timeLeft.minutes -= 1;
      timeLeft.seconds = 59;
    } else {
      timeLeft.seconds -= 1;
    }

    console.log(timeLeft.minutes + ":" + timeLeft.seconds);
}


// Check if the players on the lobby was in lobby area or not.

for(let player of jcmp.players) {
  if(!battleroyale.utils.IsPointInCircle(player.position, battleroyale.config.game.lobbypos, battleroyale.config.game.lobbyradius) && !player.ingame) {

    console.log(player.name + " was not in lobby area");
    console.log("changing player position");
    player.position = battleroyale.config.game.lobbypos;
    console.log(player.name + " X: " + player.position.x + " Y: " + player.position.y + " Z: " + player.position.z);
  }
}


});

events.Add("OnBattleStart", function()
{


  timeLeft.minutes = battleroyale.utils.msToMinutes(battleroyale.config.game.roundTime);
console.log("Battle started!!");

  Started = true;
  beingStart = false;

  global.EndTimer = setTimeout(function() {      // end of the party
     events.Call('OnBattleEnd');
  }, battleroyale.config.game.roundTime);

  global.AreaTimer = setInterval(function() {  // change the area
     events.Call('OnBattleAreaChange');
  }, battleroyale.utils.minutes(3));

  let maxSpawn = battleroyale.spawns.spawn.length - 1;
  let rnd = battleroyale.utils.RandomInt(0, maxSpawn);
  //console.log("RANDOM INDEX: " + rnd);
  let data = battleroyale.spawns.spawn[rnd];
  let spawnPos = new Vector3f(data.x, data.y, data.z);

  for(let player of jcmp.players) {
    player.ingame = true;
    g_pingame.push(player);
    player.position = spawnPos;
  player.GiveWeapon(2144721124, 999, true); // give to the player the gun

  }

   global.battleArea = { position: battleroyale.config.game.areapos, radius: battleroyale.config.game.startAreaRadius };

  //battleroyale.utils.LoadVehicles();

});

events.Add("OnBattleEnd", function()
{

  if(typeof player === 'undefined') { // if the round ends with more than 1 player alive.

    /*let survivorcount;
    for(let player of g_players) {
      if(player.ingame) {
        survivorcount++;
      }
    }*/

    battleroyale.chat.broadcast(g_pingame.length + " people survived to the battle");
    battleroyale.chat.broadcast("Survivors: ");

    /*for(let player of g_players) {
      if(player.ingame) {
        player.ingame = false
        player.position = battleroyale.config.game.lobbypos;
        battleroyale.chat.broadcast(" - " + player.name);
      }
    }*/

    for(let player of g_pingame) {
      player.ingame = false;
      player.position = battleroyale.config.game.lobbypos;
      battleroyale.chat.broadcast(" - " + player.name);
    }

  } else { // if round gots a winner
    battleroyale.chat.broadcast(player.name + "was the winner of battle royale!");
    player.ingame = false;
    player.position = battleroyale.config.game.lobbypos;
    events.Call('updateAllPlayers');

  }

  clearInterval(AreaTimer);
  Started = false;

  battleroyale.chat.broadcast("A new battle is going to start soon!");

});

events.Add("OnBattleAreaChange", function()
{


battleroyale.chat.broadcast("Battle area changed, look to the map");

let rnd = battleroyale.utils.RandomInt(0, g_pingame.length - 1);
let areaPos = g_pingame[rnd].position;
let rad = battleArea.radius / 2;
battleArea = { position: areaPos, radius: rad }
events.CallRemote('minimap_removeDrawcall', 'billboards', 'billboards_board1')
events.CallRemote('minimap_removeDrawcall', 'battleArea_position', 'battleArea_radius')
events.CallRemote('minimap_removeDrawcall', 'billboards', 'billboards_css')
events.CallRemote('minimap_addDrawcall', 'billboards', 'billboards_board1', 'drawText', { x: 12, y: 13, text: 'Hello', fontSize: 5})
events.CallRemote('minimap_addDrawcall', 'battleArea_position', 'battleArea_radius', 'drawCircle', { x: 12, y: 15, color: '#000'})
events.CallRemote('minimap_addDrawcall', 'billboards', 'billboards_css', 'addCustomCSS', { css: 'body { color: #fff; }'})


});

events.Add("OnPlayerOutArea", function(player)
{
  if (player.ingame == true)
  {
    battleroyale.chat.send(player,"You are not in the area!! ");
    player.health -= 100;
    battleroyale.chat.broadcast(player.name + "  " +"You're out of the area come's inside quickly!!");
  }

// Die because he is out of the area

});<commit_msg>adjusted some things Try to use this: https://github.com/airbnb/javascript<commit_after>'use strict';



events.Add("Checks", function()
{

  console.log("Check!"); //print on the console that the event is run.

  if(!Started)
  {
    if(!beingStart && jcmp.players.length >= battleroyale.config.game.minPlayers)
    {
      battleroyale.chat.broadcast("Minimum number of players reached to start");
        battleroyale.chat.broadcast("Game is going to start in 3 minutes");
      beingStart = true;
      global.beingStartTimer = setTimeout(function() {
        events.Call('OnBattleStart');
      }, battleroyale.utils.minutes(3));
    }

    if(beingStart && jcmp.players.length < battleroyale.config.game.minPlayers)
    {
      clearTimeout(global.beingStartTimer);
      let needplayers = battleroyale.config.game.minPlayers - jcmp.players.length;
      battleroyale.chat.broadcast("Need " + needplayers + " players more");
    }
  } else { // if Started == true and the game is launch check if player is out of area

    for(let player of g_pingame) { // Check if player was in area.
      if(!battleroyale.utils.IsPointInCircle(player.position, battleArea.position, battleArea.radius)) {
        // Change player health -2
        setInterval(function() {  events.Call('OnPlayerOutArea',player);  }, battleroyale.utils.seconds(15)); //battleroyale.events.OnPlayerOutArea(player);
      }

      //timeLeft.seconds -= 1;

    }

      if(timeLeft.seconds <= 0) {
        timeLeft.minutes -= 1;
        timeLeft.seconds = 59;
      } else {
        timeLeft.seconds -= 1;
      }

      console.log(timeLeft.minutes + ":" + timeLeft.seconds);
  }


  // Check if the players on the lobby was in lobby area or not.

  for(let player of jcmp.players) {
    if(!battleroyale.utils.IsPointInCircle(player.position, battleroyale.config.game.lobbypos, battleroyale.config.game.lobbyradius) && !player.ingame) {

      console.log(player.name + " was not in lobby area");
      console.log("changing player position");
      player.position = battleroyale.config.game.lobbypos;
      console.log(player.name + " X: " + player.position.x + " Y: " + player.position.y + " Z: " + player.position.z);
    }
  }
});

events.Add("OnBattleStart", function()
{


  timeLeft.minutes = battleroyale.utils.msToMinutes(battleroyale.config.game.roundTime);
  console.log("Battle started!!");

  Started = true;
  beingStart = false;

  global.EndTimer = setTimeout(function() {      // end of the party
     events.Call('OnBattleEnd');
  }, battleroyale.config.game.roundTime);

  global.AreaTimer = setInterval(function() {  // change the area
     events.Call('OnBattleAreaChange');
  }, battleroyale.utils.minutes(3));

  let maxSpawn = battleroyale.spawns.spawn.length - 1;
  let rnd = battleroyale.utils.RandomInt(0, maxSpawn);
  //console.log("RANDOM INDEX: " + rnd);
  let data = battleroyale.spawns.spawn[rnd];
  let spawnPos = new Vector3f(data.x, data.y, data.z);

  for(let player of jcmp.players) {
    player.ingame = true;
    g_pingame.push(player);
    player.position = spawnPos;
    player.GiveWeapon(2144721124, 999, true); // give to the player the gun
  }

  global.battleArea = { position: battleroyale.config.game.areapos, radius: battleroyale.config.game.startAreaRadius };

  //battleroyale.utils.LoadVehicles();

});

events.Add("OnBattleEnd", function()
{

  if(typeof player === 'undefined') { // if the round ends with more than 1 player alive.

    /*let survivorcount;
    for(let player of g_players) {
      if(player.ingame) {
        survivorcount++;
      }
    }*/

    battleroyale.chat.broadcast(g_pingame.length + " people survived to the battle");
    battleroyale.chat.broadcast("Survivors: ");

    /*for(let player of g_players) {
      if(player.ingame) {
        player.ingame = false
        player.position = battleroyale.config.game.lobbypos;
        battleroyale.chat.broadcast(" - " + player.name);
      }
    }*/

    for(let player of g_pingame) {
      player.ingame = false;
      player.position = battleroyale.config.game.lobbypos;
      battleroyale.chat.broadcast(" - " + player.name);
    }

  } else { // if round gots a winner
    battleroyale.chat.broadcast(player.name + "was the winner of battle royale!");
    player.ingame = false;
    player.position = battleroyale.config.game.lobbypos;
    events.Call('updateAllPlayers');

  }

  clearInterval(AreaTimer);
  Started = false;

  battleroyale.chat.broadcast("A new battle is going to start soon!");

});

events.Add("OnBattleAreaChange", function()
{
  battleroyale.chat.broadcast("Battle area changed, look to the map");

  let rnd = battleroyale.utils.RandomInt(0, g_pingame.length - 1);
  let areaPos = g_pingame[rnd].position;
  let rad = battleArea.radius / 2;
  battleArea = { position: areaPos, radius: rad }

  events.CallRemote('minimap_removeDrawcall', 'battleroyale', 'battleroyale_battlearea')
  events.CallRemote('minimap_addDrawcall', 'battleroyale', 'battleArea_battlearea', 'drawCircle', { x: 12, y: 15, radius: rad})
});

events.Add("OnPlayerOutArea", function(player)
{
  if (player.ingame == true)
  {
    battleroyale.chat.send(player,"You are not in the area!! ");
    player.health -= 100;
    battleroyale.chat.broadcast(player.name + "  " +"You're out of the area come's inside quickly!!");
  }

// Die because he is out of the area

});
{'fraction_non_alphanumeric': 0.13903791943257252, 'fraction_numerical': 0.008002182413385468, 'mean_word_length': 3.5653798256537983, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3348122', 'n_tokens_mistral': 3790, 'n_tokens_neox': 3674, 'n_words': 749}