Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* VARIABLES */
- /* ROOM */
- const roomName = "!W AMISTOSOS"; // NOME DA SALA
- const botName = "!W"; // NOME DO BOT
- const maxPlayers = 16; // NÚMERO DE SLOTS DA SALA
- const roomPublic = true; // true = sala visível no lobby; false = sala não visível no lobby
- const password = "interno!W2014"; // SENHA PRA TRANCAR A SALA
- const passwordcamp = "campzada1999"; // SENHA PRA TRANCAR A SALA PRA CAMP
- const geo = [{"code": "br", "lat": -23.51634162, "lon": -46.6460824}]; // pode mudar dps
- const room = HBInit({ roomName: roomName, maxPlayers: maxPlayers, public: roomPublic, playerName: botName, geo: geo[0]});
- const scoreLimit = 7;
- const timeLimit = 0;
- room.setScoreLimit(scoreLimit);
- room.setTimeLimit(timeLimit);
- room.setTeamsLock(true);
- var adminPassword = 1000 + getRandomInt(9000);
- console.log("adminPassword : " + adminPassword);
- /* ESTÁDIO (MAPA) */
- const playerRadius = 15;
- var ballRadius = 10;
- const triggerDistance = playerRadius + ballRadius + 0.01;
- /* OPÇÕES */
- var drawTimeLimit = Infinity;
- var maxTeamSize = 16;
- /* JOGADORES - PLAYERS */
- const Team = { SPECTATORS: 0, RED: 1, BLUE: 2 };
- var players;
- var teamR;
- var teamB;
- var teamS;
- var muteList = [];
- /* JOGO - GAME */
- var lastTeamTouched;
- var lastPlayersTouched;
- var goldenGoal = false;
- var activePlay = false;
- /* CORES */
- var welcomeColor = 0xC4FF65;
- var AnnouncementColor = 0xFFEFD6;
- var announcementColor = 0xFFEFD6;
- var redColor = 0xFF3F3F;
- var blueColor = 0x62CBFF;
- var strongRed = 0xFF0000;
- var colorOne = 0xFF8400;
- var colorTwo = 0xFFAA4F;
- var colorThree = 0xFFC382;
- var colorFour = 0xE69500;
- var defaultColor = null;
- /* STATUS - STATS */
- var GKList = new Array(2 * maxPlayers).fill(0);
- var Rposs = 0;
- var Bposs = 0;
- var point = [{"x": 0, "y": 0}, {"x": 0, "y": 0}]; // criado para obter a velocidade da bola
- var ballSpeed;
- var lastWinner = Team.SPECTATORS;
- var streak = 0;
- var streakb = 0;
- /* AUXILIAR */
- var checkTimeVariable = false;
- var messageSay;
- var messageFalar;
- /* FUNÇÕES - FUNCTIONS */
- /* FUNÇÕES AUXILIARES - AUXILIARY FUNCTIONS */
- function getRandomInt(max) { // return random number from 0 to max-1
- return Math.floor(Math.random() * Math.floor(max));
- }
- function arrayMin(arr) {
- var len = arr.length;
- var min = Infinity;
- while (len--) {
- if (arr[len] < min) {
- min = arr[len];
- }
- }
- return min;
- }
- function getTime(scores) {
- return "[" + Math.floor(Math.floor(scores.time/60)/10).toString() + Math.floor(Math.floor(scores.time/60)%10).toString() + ":" + Math.floor(Math.floor(scores.time - (Math.floor(scores.time/60) * 60))/10).toString() + Math.floor(Math.floor(scores.time - (Math.floor(scores.time/60) * 60))%10).toString() + "]"
- }
- function pointDistance(p1, p2) {
- var d1 = p1.x - p2.x;
- var d2 = p1.y - p2.y;
- return Math.sqrt(d1 * d1 + d2 * d2);
- }
- /* BUTTONS */
- function topBtn() {
- if (teamS.length == 0) {
- return;
- }
- else {
- if (teamR.length == teamB.length) {
- if (teamS.length > 1) {
- room.setPlayerTeam(teamS[0].id, Team.RED);
- room.setPlayerTeam(teamS[1].id, Team.BLUE);
- }
- return;
- }
- else if (teamR.length < teamB.length) {
- room.setPlayerTeam(teamS[0].id, Team.RED);
- }
- else {
- room.setPlayerTeam(teamS[0].id, Team.BLUE);
- }
- }
- }
- function resetBtn() {
- resettingTeams = true;
- setTimeout(function() { resettingTeams = false; }, 100);
- if (teamR.length <= teamB.length) {
- for (var i = 0; i < teamR.length; i++) {
- room.setPlayerTeam(teamB[teamB.length - 1 - i].id, Team.SPECTATORS);
- room.setPlayerTeam(teamR[teamR.length - 1 - i].id, Team.SPECTATORS);
- }
- for (var i = teamR.length; i < teamB.length; i++) {
- room.setPlayerTeam(teamB[teamB.length - 1 - i].id, Team.SPECTATORS);
- }
- }
- else {
- for (var i = 0; i < teamB.length; i++) {
- room.setPlayerTeam(teamB[teamB.length - 1 - i].id, Team.SPECTATORS);
- room.setPlayerTeam(teamR[teamR.length - 1 - i].id, Team.SPECTATORS);
- }
- for (var i = teamB.length; i < teamR.length; i++) {
- room.setPlayerTeam(teamR[teamR.length - 1 - i].id, Team.SPECTATORS);
- }
- }
- }
- function blueToSpecBtn() {
- resettingTeams = true;
- setTimeout(function() { resettingTeams = false; }, 100);
- for (var i = 0; i < teamB.length; i++) {
- room.setPlayerTeam(teamB[teamB.length - 1 - i].id, Team.SPECTATORS);
- }
- }
- function redToSpecBtn() {
- resettingTeams = true;
- setTimeout(function() { resettingTeams = false; }, 100);
- for (var i = 0; i < teamR.length; i++) {
- room.setPlayerTeam(teamR[teamR.length - 1 - i].id, Team.SPECTATORS);
- }
- }
- function blueToRedBtn() {
- resettingTeams = true;
- setTimeout(() => { resettingTeams = false; }, 100);
- for (var i = 0; i < teamB.length; i++) {
- room.setPlayerTeam(teamB[i].id, Team.RED);
- }
- }
- /* GAME FUNCTIONS */
- function checkTime() {
- const scores = room.getScores();
- if (Math.abs(scores.time - scores.timeLimit) <= 0.01 && scores.timeLimit != 0) {
- if (scores.red != scores.blue) {
- if (checkTimeVariable == false) {
- checkTimeVariable = true;
- setTimeout(() => { checkTimeVariable = false; }, 3000);
- scores.red > scores.blue ? endGame(Team.RED) : endGame(Team.BLUE);
- setTimeout(() => { room.stopGame(); }, 2000);
- }
- return;
- }
- goldenGoal = true;
- room.sendAnnouncement("⚽ A primeira equipe a marcar vence! ⚽", null, announcementColor, "bold", null);
- }
- if (Math.abs(drawTimeLimit * 60 - scores.time - 60) <= 0.01 && players.length > 2) {
- if (checkTimeVariable == false) {
- checkTimeVariable = true;
- setTimeout(() => { checkTimeVariable = false; }, 10);
- room.sendAnnouncement("⌛ 60 segundos até o limite de tempo para empate! ⌛", null, announcementColor, "bold", null);
- }
- }
- if (Math.abs(scores.time - drawTimeLimit * 60) <= 0.01 && players.length > 2) {
- if (checkTimeVariable == false) {
- checkTimeVariable = true;
- setTimeout(() => { checkTimeVariable = false; }, 10);
- endGame(Team.SPECTATORS);
- room.stopGame();
- goldenGoal = false;
- }
- }
- }
- function endGame(winner) { // no stopGame() function in it
- const scores = room.getScores();
- Rposs = Rposs/(Rposs+Bposs);
- Bposs = 1 - Rposs;
- lastWinner = winner;
- if (winner == Team.RED) {
- streak++;
- streakb = 0;
- room.sendAnnouncement("🔴 A equipe vermelha venceu! " + scores.red + "-" + scores.blue + "! Streak atual: " + streak + " 🏆", null, redColor, "bold", null);
- room.sendAnnouncement("⭐ Posse de bola: 🔴 " + (Rposs*100).toPrecision(3).toString() + "% : " + (Bposs*100).toPrecision(3).toString() + "% 🔵", null, announcementColor, "bold", null);
- if (scores.blue == 0) {
- room.sendAnnouncement("🏆 " + teamR[GKList.slice(0, maxPlayers).findIndex(p => p == Math.max(...GKList.slice(0, maxPlayers)))].name + " não sofreu gol! ⚽️✋❌", null, announcementColor, "bold", null);
- }
- }
- else if (winner == Team.BLUE) {
- streakb++;
- streak = 0;
- room.sendAnnouncement("🔵 A equipe azul venceu! " + scores.blue + "-" + scores.red + "! Streak atual : " + streakb + " 🏆", null, blueColor, "bold", null);
- room.sendAnnouncement("⭐ Posse de bola: 🔴 " + (Rposs*100).toPrecision(3).toString() + "% : " + (Bposs*100).toPrecision(3).toString() + "% 🔵", null, announcementColor, "bold", null);
- if (scores.red == 0) {
- room.sendAnnouncement("🏆 " + teamB[GKList.slice(maxPlayers, 2 * maxPlayers).findIndex(p => p == Math.max(...GKList.slice(maxPlayers, 2 * maxPlayers)))].name + " não sofreu gol! ⚽️✋❌", null, announcementColor, "bold", null);
- }
- }
- else {
- streak = 0;
- streakb = 0;
- room.sendAnnouncement("💤 Chegamos ao tempo limite de empate! 💤", null, announcementColor, "bold", null);
- room.sendAnnouncement("⭐ Posse de bola: 🔴 " + (Rposs*100).toPrecision(3).toString() + "% : " + (Bposs*100).toPrecision(3).toString() + "% 🔵", null, announcementColor, "bold", null);
- if (scores.red == 0) {
- room.sendAnnouncement("🏆 " + teamB[GKList.slice(maxPlayers, 2 * maxPlayers).findIndex(p => p == Math.max(...GKList.slice(maxPlayers, 2 * maxPlayers)))].name + " and " + teamR[GKList.slice(0, maxPlayers).findIndex(p => p == Math.max(...GKList.slice(0, maxPlayers)))].name + " não sofreu gol! ⚽️✋❌", null, announcementColor, "bold", null);
- }
- }
- }
- /* PLAYER FUNCTIONS */
- function updateTeams() {
- players = room.getPlayerList().filter((player) => player.id != 0);
- teamR = players.filter(p => p.team === Team.RED);
- teamB = players.filter(p => p.team === Team.BLUE);
- teamS = players.filter(p => p.team === Team.SPECTATORS);
- }
- function updateAdmins() {
- // pega todos os jogadaores com exceรงรฃo do host.
- var players = room.getPlayerList().filter((player) => player.id != 0 );
- if ( players.length == 0 ) return; // nenhum player sobrando, nao faz nada.
- if ( players.find((player) => player.admin) != null ) return; // Hรก um admin, nรฃo fazer nada.
- room.setPlayerAdmin(players[0].id, true); // da admin para a primeira pessoa da lista.
- }
- function updateList(number, team) {
- if (room.getScores() != null) {
- if (team == Team.RED) {
- GKList = GKList.slice(0, number).concat(GKList.slice(number + 1, maxPlayers)).concat(0).concat(GKList.slice(maxPlayers, GKList.length));
- }
- else if (team == Team.BLUE) {
- GKList = GKList.slice(0, maxPlayers + number).concat(GKList.slice(maxPlayers + number + 1, GKList.length).concat(0));
- }
- }
- }
- /* STATS FUNCTIONS */
- function getLastTouchOfTheBall() {
- const ballPosition = room.getBallPosition();
- updateTeams();
- for (var i = 0; i < players.length; i++) {
- if (players[i].position != null) {
- var distanceToBall = pointDistance(players[i].position, ballPosition);
- if (distanceToBall < triggerDistance) {
- !activePlay ? activePlay = true : null;
- if (lastTeamTouched == players[i].team && lastPlayersTouched[0] != null && lastPlayersTouched[0].id != players[i].id) {
- lastPlayersTouched[1] = lastPlayersTouched[0];
- lastPlayersTouched[0] = players[i];
- }
- lastTeamTouched = players[i].team;
- }
- }
- }
- }
- function getStats() { // gives possession, ball speed and GK of each team
- if (activePlay) {
- updateTeams();
- lastTeamTouched == Team.RED ? Rposs++ : Bposs++;
- var ballPosition = room.getBallPosition();
- point[1] = point[0];
- point[0] = ballPosition;
- ballSpeed = (pointDistance(point[0], point[1]) * 60 * 60 * 60)/15000;
- var k = [-1, Infinity];
- for (var i = 0; i < teamR.length; i++) {
- if (teamR[i].position.x < k[1]) {
- k[0] = i;
- k[1] = teamR[i].position.x;
- }
- }
- GKList[k[0]]++;
- k = [-1, -Infinity];
- for (var i = 0; i < teamB.length; i++) {
- if (teamB[i].position.x > k[1]) {
- k[0] = i;
- k[1] = teamB[i].position.x;
- }
- }
- GKList[maxPlayers + k[0]]++;
- }
- }
- /* EVENTS */
- /* PLAYER MOVEMENT */
- room.onPlayerJoin = function(player) {
- room.sendAnnouncement("[PV] 👋 Bem-vindo(a), " + player.name + "! ", player.id, welcomeColor, "bold", null);
- updateTeams();
- updateAdmins();
- }
- room.onPlayerTeamChange = function(changedPlayer, byPlayer) {
- if (changedPlayer.id == 0) {
- room.setPlayerTeam(0, Team.SPECTATORS);
- return;
- }
- if (changedPlayer.team == Team.SPECTATORS) {
- updateList(Math.max(teamR.findIndex((p) => p.id == changedPlayer.id), teamB.findIndex((p) => p.id == changedPlayer.id), teamS.findIndex((p) => p.id == changedPlayer.id)), changedPlayer.team);
- }
- updateTeams();
- }
- room.onPlayerLeave = function(player) {
- updateList(Math.max(teamR.findIndex((p) => p.id == player.id), teamB.findIndex((p) => p.id == player.id), teamS.findIndex((p) => p.id == player.id)), player.team);
- updateTeams();
- updateAdmins();
- }
- room.onPlayerKicked = function(kickedPlayer, reason, ban, byPlayer){ //PlayerObject, string, bool, PlayerObject
- if (ofcAdms.includes(kickedPlayer.name) && ban == true && ofcAdms.includes(byPlayer.name) == false){
- room.clearBans();
- room.kickPlayer(byPlayer.id, '🚨👮♂️ Não é permitido banir um ADM oficial!', true);
- } else if (ofcAdms.includes(kickedPlayer.name) && ban == false && ofcAdms.includes(byPlayer.name) == false){
- room.kickPlayer(byPlayer.id, '🚨👮♂️ Não é permitido kickar um ADM oficial!', false);
- } else if (ofcAdms.includes(kickedPlayer.name) && ban == true && ofcAdms.includes(byPlayer.name)){
- room.kickPlayer(byPlayer.id, '🚨🤯 ?!', true);
- room.clearBans();
- } else if (ofcAdms.includes(kickedPlayer.name) && ban == false && ofcAdms.includes(byPlayer.name)){
- room.kickPlayer(byPlayer.id, '🚨🤯 ?!', false);
- }
- }
- /* PLAYER ACTIVITY */
- var specMute = false;
- var senhasAdm = ['!senha1', '!senha2',]; // ===== ADICIONAR AS SENHAS AQUI TAMBÉM =====
- var colorAdm = '0xEBA300';
- var colorBan = '0x3A96DD';
- var colorPass = '0xFFC83D';
- var colorHelp = '0xF03A17';
- var redUni = '0xE56E56';
- var blueUni = '0x5689E5';
- var strongRed = '0xFF0000';
- var ofcAdms = [];
- var numofcAdms;
- function timerBan(){
- setInterval(function(){
- room.clearBans();
- room.sendAnnouncement(`🙏 Os bans foram limpos após 30 minutos`, null, colorBan, "bold", 1);
- }, 1800000);
- }
- function clearOfcAdm(){
- setInterval(function(){
- ofcAdms.splice(0, 200);
- console.log('[CLEARLIST] Lista de ADMs oficiais limpa após 12 horas');
- }, 43200000);
- }
- timerBan();
- clearOfcAdm();
- room.onPlayerChat = function(player, message) { // ABRINDO O ON PLAYER CHAT
- messageSay = message;
- messageFalar = message;
- message = message.split(" ");
- messageSay = messageSay.substring(5);
- messageFalar = messageFalar.substring(7);
- if (specMute == true && player.team == 0 && player.admin == false && message != senhasAdm[0] && message != senhasAdm[1] && message != senhasAdm[2] && message != senhasAdm[3] && message != senhasAdm[4]){
- return false;
- }
- if (["!help"].includes(message[0].toLowerCase()) && player.admin) {
- room.sendAnnouncement(`❓ !specoff / !specon / !bloquear / !bloquearcamp / !desbloquear / !clearbans / !say`, player.id, colorHelp, "bold", 1);
- } /* SENHAS DE ADM */
- if (message == "!senhaRichard77@") {
- room.setPlayerAdmin(player.id, true);
- if(ofcAdms.includes(player.name)){
- //pass
- } else{
- ofcAdms.push(player.name);
- }
- room.sendAnnouncement(`🔑 ${player.name} usou uma senha de adm by richard`, null, strongRed, "bold", 1);
- room.sendAnnouncement(`🔑 >>> Digite !help`, player.id, colorAdm, "bold", 1);
- console.log(`===== [ADM] ${player.name} USOU UMA SENHA DE ADM BY RICHARD =====`); // caso outra senha seja criada, utilizar essa estrutura
- }
- if (message == "!senhalukzboy14") {
- room.setPlayerAdmin(player.id, true);
- if(ofcAdms.includes(player.name)){
- //pass
- } else{
- ofcAdms.push(player.name);
- }
- room.sendAnnouncement(`🔑 ${player.name} usou uma senha de adm by Lukz`, null, strongRed, "bold", 1);
- room.sendAnnouncement(`🔑 >>> Digite !help`, player.id, colorAdm, "bold", 1);
- console.log(`===== [ADM] ${player.name} USOU UMA SENHA DE ADM BY LUKZ =====`); // caso outra senha seja criada, utilizar essa estrutura
- } /* FIM DAS SENHAS DE ADM */
- if (ofcAdms.includes(player.name) && player.admin) {
- /* COLORS */
- if (["!w1red"].includes(message[0].toLowerCase())) {
- room.setTeamColors(1, 45, 0x000000, [0xFFBB00, 0xE3A600]);
- room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 1`, null, redUni, "bold", 1);
- return false;
- }
- if (["!w2red"].includes(message[0].toLowerCase())) {
- room.setTeamColors(1, 45, 0xE3A600, [0x000000, 0x191919, 0x000000]);
- room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 2`, null, redUni, "bold", 1);
- return false;
- }
- if (["!w3red"].includes(message[0].toLowerCase())) {
- room.setTeamColors(1, 45, 0xE3A600, [0xFFFFFF, 0xC2C2C2]);
- room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 3`, null, redUni, "bold", 1);
- return false;
- }
- if (["!w4red"].includes(message[0].toLowerCase())) {
- room.setTeamColors(1, 45, 0xE3E3E3, [0x28C266, 0x22A356]);
- room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 4`, null, redUni, "bold", 1);
- return false;
- }
- if (["!w1blue"].includes(message[0].toLowerCase())) {
- room.setTeamColors(2, 45, 0x000000, [0xFFBB00, 0xE3A600]);
- room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 1`, null, blueUni, "bold", 1);
- return false;
- }
- if (["!w2blue"].includes(message[0].toLowerCase())) {
- room.setTeamColors(2, 45, 0xE3A600, [0x000000, 0x191919, 0x000000]);
- room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 2`, null, blueUni, "bold", 1);
- return false;
- }
- if (["!w3blue"].includes(message[0].toLowerCase())) {
- room.setTeamColors(2, 45, 0xE3A600, [0xFFFFFF, 0xC2C2C2]);
- room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 3`, null, blueUni, "bold", 1);
- return false;
- }
- if (["!w4blue"].includes(message[0].toLowerCase())) {
- room.setTeamColors(2, 45, 0xE3E3E3, [0x28C266, 0x22A356]);
- room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 4`, null, blueUni, "bold", 1);
- return false;
- }
- /* FIM DAS CORES */
- if (["!mute"].includes(message[0].toLowerCase())) { /* !mute <R/B/S> <team position> <duration = 3> */
- if (message.length == 3 || message.length == 4) {
- if (["R","B","S"].includes(message[1])) {
- var timeOut;
- if (message[1] == "R") {
- if (!Number.isNaN(Number.parseInt(message[2]))) {
- if (Number.parseInt(message[2]) <= teamR.length && Number.parseInt(message[2]) > 0) {
- if (teamR[Number.parseInt(message[2]) - 1].admin || muteList.filter((p) => p == teamR[Number.parseInt(message[2]) - 1].name).length > 0) {
- return false;
- }
- if (message.length == 4) {
- if (!Number.isNaN(Number.parseInt(message[3]))) {
- if (Number.parseInt(message[3]) > 0) {
- timeOut = Number.parseInt(message[3]) * 60 * 1000;
- }
- }
- }
- else {
- timeOut = 3 * 60 * 1000;
- }
- setTimeout(function(name) { muteList = muteList.filter((p) => p != name) }, timeOut, teamR[Number.parseInt(message[2]) - 1].name);
- muteList.push(teamR[Number.parseInt(message[2]) - 1].name);
- room.sendAnnouncement("🗣❌ " + teamR[Number.parseInt(message[2]) - 1].name + " foi mutado por " + (timeOut/60000) + " minuto(s) por " + player.name, null, announcementColor, "bold", null);
- return false;
- }
- }
- }
- if (message[1] == "B") {
- if (!Number.isNaN(Number.parseInt(message[2]))) {
- if (Number.parseInt(message[2]) <= teamB.length && Number.parseInt(message[2]) > 0) {
- if (teamB[Number.parseInt(message[2]) - 1].admin || muteList.filter((p) => p == teamB[Number.parseInt(message[2]) - 1].name).length > 0) {
- return false;
- }
- if (message.length == 4) {
- if (!Number.isNaN(Number.parseInt(message[3]))) {
- if (Number.parseInt(message[3]) > 0) {
- timeOut = Number.parseInt(message[3]) * 60 * 1000;
- }
- }
- }
- else {
- timeOut = 3 * 60 * 1000;
- }
- setTimeout(function(name) { muteList = muteList.filter((p) => p != name) }, timeOut, teamB[Number.parseInt(message[2]) - 1].name);
- muteList.push(teamB[Number.parseInt(message[2]) - 1].name);
- room.sendAnnouncement("🗣❌ " + teamB[Number.parseInt(message[2]) - 1].name + " foi mutado por " + (timeOut/60000) + " minuto(s) por " + player.name, null, announcementColor, "bold", null);
- return false;
- }
- }
- }
- if (message[1] == "S") {
- if (!Number.isNaN(Number.parseInt(message[2]))) {
- if (Number.parseInt(message[2]) <= teamS.length && Number.parseInt(message[2]) > 0) {
- if (teamS[Number.parseInt(message[2]) - 1].admin || muteList.filter((p) => p == teamS[Number.parseInt(message[2]) - 1].name).length > 0) {
- return false;
- }
- if (message.length == 4) {
- if (!Number.isNaN(Number.parseInt(message[3]))) {
- if (Number.parseInt(message[3]) > 0) {
- timeOut = Number.parseInt(message[3]) * 60 * 1000;
- }
- }
- }
- else {
- timeOut = 3 * 60 * 1000;
- }
- setTimeout(function(name) { muteList = muteList.filter((p) => p != name) }, timeOut, teamS[Number.parseInt(message[2]) - 1].name);
- muteList.push(teamS[Number.parseInt(message[2]) - 1].name);
- room.sendAnnouncement("🗣❌ " + teamS[Number.parseInt(message[2]) - 1].name + " foi mutado por " + (timeOut/60000) + " minuto(s) por " + player.name, null, announcementColor, "bold", null);
- return false;
- }
- }
- }
- }
- }
- }
- else if (["!unmute"].includes(message[0].toLowerCase())) { /* !unmute all/<nick> */
- if (message.length == 2 && message[1] == "all") {
- muteList = [];
- room.sendAnnouncement("🗣❌ Lista de mutados limpa.", null, announcementColor, "bold", null);
- return false;
- }
- if (message.length >= 2) {
- var name = "";
- for (var i = 1 ; i < message.length ; i++) {
- name += message[i] + " ";
- }
- name = name.substring(0, name.length - 1);
- muteList.length != muteList.filter((p) => p != name).length ? room.sendAnnouncement("🗣 " + name + " foi desmutado por " + player.name, null, announcementColor, "bold", null) : null;
- muteList = muteList.filter((p) => p != name);
- return false;
- }
- }
- if (["!specoff"].includes(message[0].toLowerCase())) {
- specMute = true;
- room.sendAnnouncement(`🔇 ${player.name} mutou o chat do spec`, null, strongRed, "bold", 1);
- }
- if (["!specon"].includes(message[0].toLowerCase())) {
- specMute = false;
- room.sendAnnouncement(`🔊 ${player.name} desmutou o chat da sala`, null, strongRed, "bold", 1);
- }
- if (["!bloquear", "!setpassword"].includes(message[0].toLowerCase())) {
- room.setPassword(password);
- room.sendAnnouncement(`🔒 ${player.name} bloqueou a sala!`, null, announcementColor, "bold", null);
- }
- if (["!bloquearcamp", "!setpasswordcamp"].includes(message[0].toLowerCase())) {
- room.setPassword(passwordcamp);
- room.sendAnnouncement(`🔒 ${player.name} bloqueou a sala para camp!`, null, announcementColor, "bold", null);
- }
- if (["!desbloquear", "!unsetpassword"].includes(message[0].toLowerCase())) {
- room.setPassword();
- room.sendAnnouncement(`🔓 ${player.name} desbloqueou a sala!`, null, announcementColor, "bold", null);
- }
- if (["!clearbans"].includes(message[0].toLowerCase())) {
- room.clearBans();
- room.sendAnnouncement(`🙏 ${player.name} Limpou os bans.`, null, colorBan, "bold", null);
- }
- if (["!say"].includes(message[0].toLowerCase())) {
- room.sendChat("" + messageSay, null);
- }
- if (["!falar"].includes(message[0].toLowerCase())) {
- room.sendChat("" + messageFalar, null);
- }
- } /* FECHANDO O IF PLAYERADMIN */
- if (["!bb", "!bye", "!cya", "!gn"].includes(message[0].toLowerCase())) {
- room.kickPlayer(player.id, "👋 Tchau!", false);
- }
- if (["!discord"].includes(message[0].toLowerCase())) {
- room.sendAnnouncement(`▒█▀▀▀ ▒█▀▀█ ▒█▀▀▀ `, player.id, colorOne, "normal", 0);
- room.sendAnnouncement(`▒█▀▀▀ ▒█▀▀▄ ▒█▀▀▀ `, player.id, colorTwo, "normal", 0);
- room.sendAnnouncement(`▒█░░░ ▒█▄▄█ ▒█░░░ `, player.id, colorThree, "normal", 0);
- room.sendAnnouncement(`🏆 Entre no maior campeonato de futsal x3: https://discord.gg/4mnY6tx`, player.id, colorFour, "bold", 0);
- }
- if (muteList.includes(player.name)) {
- room.sendAnnouncement("🗣❌ Você está mutado.", player.id);
- return false;
- }
- if (message[0][0] == "!") {
- return false;
- }
- } /* FECHANDO ON PLAYER CHAT */
- room.onPlayerActivity = function(player) {
- }
- room.onPlayerBallKick = function(player) {
- if (lastPlayersTouched[0] == null || player.id != lastPlayersTouched[0].id) {
- !activePlay ? activePlay = true : null;
- lastTeamTouched = player.team;
- lastPlayersTouched[1] = lastPlayersTouched[0];
- lastPlayersTouched[0] = player;
- }
- }
- /* GAME MANAGEMENT */
- room.onGameStart = function(byPlayer) {
- GKList = new Array(2 * maxPlayers).fill(0);
- activePlay = false;
- Rposs = 0;
- Bposs = 0;
- lastPlayersTouched = [null, null];
- goldenGoal = false;
- }
- room.onGameStop = function(byPlayer) {
- }
- room.onGamePause = function(byPlayer) {
- }
- room.onGameUnpause = function(byPlayer) {
- }
- room.onTeamGoal = function(team) {
- const scores = room.getScores();
- activePlay = false;
- if (lastPlayersTouched[0] == null && lastPlayersTouched[0].team == team) {
- room.sendAnnouncement("Não foi possível detectar de quem foi o gol.");
- }
- if (lastPlayersTouched[0] != null && lastPlayersTouched[0].team == team) {
- if (lastPlayersTouched[1] != null && lastPlayersTouched[1].team == team) {
- room.sendAnnouncement("⚽ " + getTime(scores) + " Gol de " + lastPlayersTouched[0].name + "! Assistência de " + lastPlayersTouched[1].name + ". Velocidade da bola: " + ballSpeed.toPrecision(4).toString() + "km/h ", null, (team == Team.RED ? redColor : blueColor), null, null);
- }
- else {
- room.sendAnnouncement("⚽ " + getTime(scores) + " Gol de " + lastPlayersTouched[0].name + "! Velocidade da bola: " + ballSpeed.toPrecision(4).toString() + "km/h ", null, (team == Team.RED ? redColor : blueColor), null, null);
- }
- }
- else {
- room.sendAnnouncement("😂 " + getTime(scores) + " Gol contra de " + lastPlayersTouched[0].name + "! Velocidade da bola: " + ballSpeed.toPrecision(4).toString() + "km/h ", null, (team == Team.RED ? redColor : blueColor), null, null);
- }
- if (scores.scoreLimit != 0 && (scores.red == scores.scoreLimit || scores.blue == scores.scoreLimit || goldenGoal == true)) {
- endGame(team);
- goldenGoal = false;
- setTimeout(() => { room.stopGame(); }, 1000);
- }
- }
- room.onPositionsReset = function() {
- lastPlayersTouched = [null, null];
- }
- /* MISCELLANEOUS */
- room.onRoomLink = function(url) {
- }
- room.onPlayerAdminChange = function(changedPlayer, byPlayer) {
- if (muteList.includes(changedPlayer.name) && changedPlayer.admin) {
- room.sendChat(changedPlayer.name + " foi desmutado.");
- muteList = muteList.filter((p) => p != changedPlayer.name);
- }
- }
- room.onStadiumChange = function(newStadiumName, byPlayer) {
- }
- room.onGameTick = function() {
- checkTime();
- getLastTouchOfTheBall();
- getStats();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement