Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.09 KB | None | 0 0
  1. /* VARIABLES */
  2.  
  3. /* ROOM */
  4.  
  5. const roomName = "!W AMISTOSOS"; // NOME DA SALA
  6. const botName = "!W"; // NOME DO BOT
  7. const maxPlayers = 16; // NÚMERO DE SLOTS DA SALA
  8. const roomPublic = true; // true = sala visível no lobby; false = sala não visível no lobby
  9. const password = "interno!W2014"; // SENHA PRA TRANCAR A SALA
  10. const passwordcamp = "campzada1999"; // SENHA PRA TRANCAR A SALA PRA CAMP
  11. const geo = [{"code": "br", "lat": -23.51634162, "lon": -46.6460824}]; // pode mudar dps
  12.  
  13. const room = HBInit({ roomName: roomName, maxPlayers: maxPlayers, public: roomPublic, playerName: botName, geo: geo[0]});
  14.  
  15. const scoreLimit = 7;
  16. const timeLimit = 0;
  17. room.setScoreLimit(scoreLimit);
  18. room.setTimeLimit(timeLimit);
  19. room.setTeamsLock(true);
  20.  
  21. var adminPassword = 1000 + getRandomInt(9000);
  22. console.log("adminPassword : " + adminPassword);
  23.  
  24. /* ESTÁDIO (MAPA) */
  25.  
  26. const playerRadius = 15;
  27. var ballRadius = 10;
  28. const triggerDistance = playerRadius + ballRadius + 0.01;
  29.  
  30. /* OPÇÕES */
  31.  
  32. var drawTimeLimit = Infinity;
  33. var maxTeamSize = 16;
  34.  
  35. /* JOGADORES - PLAYERS */
  36.  
  37. const Team = { SPECTATORS: 0, RED: 1, BLUE: 2 };
  38. var players;
  39. var teamR;
  40. var teamB;
  41. var teamS;
  42. var muteList = [];
  43.  
  44. /* JOGO - GAME */
  45.  
  46. var lastTeamTouched;
  47. var lastPlayersTouched;
  48. var goldenGoal = false;
  49. var activePlay = false;
  50.  
  51. /* CORES */
  52.  
  53. var welcomeColor = 0xC4FF65;
  54. var AnnouncementColor = 0xFFEFD6;
  55. var announcementColor = 0xFFEFD6;
  56. var redColor = 0xFF3F3F;
  57. var blueColor = 0x62CBFF;
  58. var strongRed = 0xFF0000;
  59. var colorOne = 0xFF8400;
  60. var colorTwo = 0xFFAA4F;
  61. var colorThree = 0xFFC382;
  62. var colorFour = 0xE69500;
  63. var defaultColor = null;
  64.  
  65. /* STATUS - STATS */
  66.  
  67. var GKList = new Array(2 * maxPlayers).fill(0);
  68. var Rposs = 0;
  69. var Bposs = 0;
  70. var point = [{"x": 0, "y": 0}, {"x": 0, "y": 0}]; // criado para obter a velocidade da bola
  71. var ballSpeed;
  72. var lastWinner = Team.SPECTATORS;
  73. var streak = 0;
  74. var streakb = 0;
  75.  
  76. /* AUXILIAR */
  77.  
  78. var checkTimeVariable = false;
  79. var messageSay;
  80. var messageFalar;
  81.  
  82. /* FUNÇÕES - FUNCTIONS */
  83.  
  84. /* FUNÇÕES AUXILIARES - AUXILIARY FUNCTIONS */
  85.  
  86. function getRandomInt(max) { // return random number from 0 to max-1
  87. return Math.floor(Math.random() * Math.floor(max));
  88. }
  89.  
  90. function arrayMin(arr) {
  91. var len = arr.length;
  92. var min = Infinity;
  93. while (len--) {
  94. if (arr[len] < min) {
  95. min = arr[len];
  96. }
  97. }
  98. return min;
  99. }
  100.  
  101. function getTime(scores) {
  102. 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() + "]"
  103. }
  104.  
  105. function pointDistance(p1, p2) {
  106. var d1 = p1.x - p2.x;
  107. var d2 = p1.y - p2.y;
  108. return Math.sqrt(d1 * d1 + d2 * d2);
  109. }
  110.  
  111. /* BUTTONS */
  112.  
  113. function topBtn() {
  114. if (teamS.length == 0) {
  115. return;
  116. }
  117. else {
  118. if (teamR.length == teamB.length) {
  119. if (teamS.length > 1) {
  120. room.setPlayerTeam(teamS[0].id, Team.RED);
  121. room.setPlayerTeam(teamS[1].id, Team.BLUE);
  122. }
  123. return;
  124. }
  125. else if (teamR.length < teamB.length) {
  126. room.setPlayerTeam(teamS[0].id, Team.RED);
  127. }
  128. else {
  129. room.setPlayerTeam(teamS[0].id, Team.BLUE);
  130. }
  131. }
  132. }
  133.  
  134. function resetBtn() {
  135. resettingTeams = true;
  136. setTimeout(function() { resettingTeams = false; }, 100);
  137. if (teamR.length <= teamB.length) {
  138. for (var i = 0; i < teamR.length; i++) {
  139. room.setPlayerTeam(teamB[teamB.length - 1 - i].id, Team.SPECTATORS);
  140. room.setPlayerTeam(teamR[teamR.length - 1 - i].id, Team.SPECTATORS);
  141. }
  142. for (var i = teamR.length; i < teamB.length; i++) {
  143. room.setPlayerTeam(teamB[teamB.length - 1 - i].id, Team.SPECTATORS);
  144. }
  145. }
  146. else {
  147. for (var i = 0; i < teamB.length; i++) {
  148. room.setPlayerTeam(teamB[teamB.length - 1 - i].id, Team.SPECTATORS);
  149. room.setPlayerTeam(teamR[teamR.length - 1 - i].id, Team.SPECTATORS);
  150. }
  151. for (var i = teamB.length; i < teamR.length; i++) {
  152. room.setPlayerTeam(teamR[teamR.length - 1 - i].id, Team.SPECTATORS);
  153. }
  154. }
  155. }
  156.  
  157. function blueToSpecBtn() {
  158. resettingTeams = true;
  159. setTimeout(function() { resettingTeams = false; }, 100);
  160. for (var i = 0; i < teamB.length; i++) {
  161. room.setPlayerTeam(teamB[teamB.length - 1 - i].id, Team.SPECTATORS);
  162. }
  163. }
  164.  
  165. function redToSpecBtn() {
  166. resettingTeams = true;
  167. setTimeout(function() { resettingTeams = false; }, 100);
  168. for (var i = 0; i < teamR.length; i++) {
  169. room.setPlayerTeam(teamR[teamR.length - 1 - i].id, Team.SPECTATORS);
  170. }
  171. }
  172.  
  173. function blueToRedBtn() {
  174. resettingTeams = true;
  175. setTimeout(() => { resettingTeams = false; }, 100);
  176. for (var i = 0; i < teamB.length; i++) {
  177. room.setPlayerTeam(teamB[i].id, Team.RED);
  178. }
  179. }
  180.  
  181. /* GAME FUNCTIONS */
  182.  
  183. function checkTime() {
  184. const scores = room.getScores();
  185. if (Math.abs(scores.time - scores.timeLimit) <= 0.01 && scores.timeLimit != 0) {
  186. if (scores.red != scores.blue) {
  187. if (checkTimeVariable == false) {
  188. checkTimeVariable = true;
  189. setTimeout(() => { checkTimeVariable = false; }, 3000);
  190. scores.red > scores.blue ? endGame(Team.RED) : endGame(Team.BLUE);
  191. setTimeout(() => { room.stopGame(); }, 2000);
  192. }
  193. return;
  194. }
  195. goldenGoal = true;
  196. room.sendAnnouncement("⚽ A primeira equipe a marcar vence! ⚽", null, announcementColor, "bold", null);
  197. }
  198. if (Math.abs(drawTimeLimit * 60 - scores.time - 60) <= 0.01 && players.length > 2) {
  199. if (checkTimeVariable == false) {
  200. checkTimeVariable = true;
  201. setTimeout(() => { checkTimeVariable = false; }, 10);
  202. room.sendAnnouncement("⌛ 60 segundos até o limite de tempo para empate! ⌛", null, announcementColor, "bold", null);
  203. }
  204. }
  205. if (Math.abs(scores.time - drawTimeLimit * 60) <= 0.01 && players.length > 2) {
  206. if (checkTimeVariable == false) {
  207. checkTimeVariable = true;
  208. setTimeout(() => { checkTimeVariable = false; }, 10);
  209. endGame(Team.SPECTATORS);
  210. room.stopGame();
  211. goldenGoal = false;
  212. }
  213. }
  214. }
  215.  
  216. function endGame(winner) { // no stopGame() function in it
  217. const scores = room.getScores();
  218. Rposs = Rposs/(Rposs+Bposs);
  219. Bposs = 1 - Rposs;
  220. lastWinner = winner;
  221. if (winner == Team.RED) {
  222. streak++;
  223. streakb = 0;
  224. room.sendAnnouncement("🔴 A equipe vermelha venceu! " + scores.red + "-" + scores.blue + "! Streak atual: " + streak + " 🏆", null, redColor, "bold", null);
  225. room.sendAnnouncement("⭐ Posse de bola: 🔴 " + (Rposs*100).toPrecision(3).toString() + "% : " + (Bposs*100).toPrecision(3).toString() + "% 🔵", null, announcementColor, "bold", null);
  226. if (scores.blue == 0) {
  227. 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);
  228. }
  229. }
  230. else if (winner == Team.BLUE) {
  231. streakb++;
  232. streak = 0;
  233. room.sendAnnouncement("🔵 A equipe azul venceu! " + scores.blue + "-" + scores.red + "! Streak atual : " + streakb + " 🏆", null, blueColor, "bold", null);
  234. room.sendAnnouncement("⭐ Posse de bola: 🔴 " + (Rposs*100).toPrecision(3).toString() + "% : " + (Bposs*100).toPrecision(3).toString() + "% 🔵", null, announcementColor, "bold", null);
  235. if (scores.red == 0) {
  236. 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);
  237. }
  238. }
  239. else {
  240. streak = 0;
  241. streakb = 0;
  242. room.sendAnnouncement("💤 Chegamos ao tempo limite de empate! 💤", null, announcementColor, "bold", null);
  243. room.sendAnnouncement("⭐ Posse de bola: 🔴 " + (Rposs*100).toPrecision(3).toString() + "% : " + (Bposs*100).toPrecision(3).toString() + "% 🔵", null, announcementColor, "bold", null);
  244. if (scores.red == 0) {
  245. 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);
  246. }
  247. }
  248. }
  249.  
  250. /* PLAYER FUNCTIONS */
  251.  
  252. function updateTeams() {
  253. players = room.getPlayerList().filter((player) => player.id != 0);
  254. teamR = players.filter(p => p.team === Team.RED);
  255. teamB = players.filter(p => p.team === Team.BLUE);
  256. teamS = players.filter(p => p.team === Team.SPECTATORS);
  257. }
  258.  
  259. function updateAdmins() {
  260. // pega todos os jogadaores com exceรงรฃo do host.
  261. var players = room.getPlayerList().filter((player) => player.id != 0 );
  262. if ( players.length == 0 ) return; // nenhum player sobrando, nao faz nada.
  263. if ( players.find((player) => player.admin) != null ) return; // Hรก um admin, nรฃo fazer nada.
  264. room.setPlayerAdmin(players[0].id, true); // da admin para a primeira pessoa da lista.
  265. }
  266.  
  267. function updateList(number, team) {
  268. if (room.getScores() != null) {
  269. if (team == Team.RED) {
  270. GKList = GKList.slice(0, number).concat(GKList.slice(number + 1, maxPlayers)).concat(0).concat(GKList.slice(maxPlayers, GKList.length));
  271.  
  272. }
  273. else if (team == Team.BLUE) {
  274. GKList = GKList.slice(0, maxPlayers + number).concat(GKList.slice(maxPlayers + number + 1, GKList.length).concat(0));
  275. }
  276. }
  277. }
  278.  
  279. /* STATS FUNCTIONS */
  280.  
  281. function getLastTouchOfTheBall() {
  282. const ballPosition = room.getBallPosition();
  283. updateTeams();
  284. for (var i = 0; i < players.length; i++) {
  285. if (players[i].position != null) {
  286. var distanceToBall = pointDistance(players[i].position, ballPosition);
  287. if (distanceToBall < triggerDistance) {
  288. !activePlay ? activePlay = true : null;
  289. if (lastTeamTouched == players[i].team && lastPlayersTouched[0] != null && lastPlayersTouched[0].id != players[i].id) {
  290. lastPlayersTouched[1] = lastPlayersTouched[0];
  291. lastPlayersTouched[0] = players[i];
  292. }
  293. lastTeamTouched = players[i].team;
  294. }
  295. }
  296. }
  297. }
  298.  
  299. function getStats() { // gives possession, ball speed and GK of each team
  300. if (activePlay) {
  301. updateTeams();
  302. lastTeamTouched == Team.RED ? Rposs++ : Bposs++;
  303. var ballPosition = room.getBallPosition();
  304. point[1] = point[0];
  305. point[0] = ballPosition;
  306. ballSpeed = (pointDistance(point[0], point[1]) * 60 * 60 * 60)/15000;
  307. var k = [-1, Infinity];
  308. for (var i = 0; i < teamR.length; i++) {
  309. if (teamR[i].position.x < k[1]) {
  310. k[0] = i;
  311. k[1] = teamR[i].position.x;
  312. }
  313. }
  314. GKList[k[0]]++;
  315. k = [-1, -Infinity];
  316. for (var i = 0; i < teamB.length; i++) {
  317. if (teamB[i].position.x > k[1]) {
  318. k[0] = i;
  319. k[1] = teamB[i].position.x;
  320. }
  321. }
  322. GKList[maxPlayers + k[0]]++;
  323. }
  324. }
  325.  
  326. /* EVENTS */
  327.  
  328. /* PLAYER MOVEMENT */
  329.  
  330. room.onPlayerJoin = function(player) {
  331. room.sendAnnouncement("[PV] 👋 Bem-vindo(a), " + player.name + "! ", player.id, welcomeColor, "bold", null);
  332. updateTeams();
  333. updateAdmins();
  334. }
  335.  
  336. room.onPlayerTeamChange = function(changedPlayer, byPlayer) {
  337. if (changedPlayer.id == 0) {
  338. room.setPlayerTeam(0, Team.SPECTATORS);
  339. return;
  340. }
  341. if (changedPlayer.team == Team.SPECTATORS) {
  342. 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);
  343. }
  344. updateTeams();
  345. }
  346.  
  347. room.onPlayerLeave = function(player) {
  348. 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);
  349. updateTeams();
  350. updateAdmins();
  351. }
  352.  
  353. room.onPlayerKicked = function(kickedPlayer, reason, ban, byPlayer){ //PlayerObject, string, bool, PlayerObject
  354. if (ofcAdms.includes(kickedPlayer.name) && ban == true && ofcAdms.includes(byPlayer.name) == false){
  355. room.clearBans();
  356. room.kickPlayer(byPlayer.id, '🚨👮‍♂️ Não é permitido banir um ADM oficial!', true);
  357. } else if (ofcAdms.includes(kickedPlayer.name) && ban == false && ofcAdms.includes(byPlayer.name) == false){
  358. room.kickPlayer(byPlayer.id, '🚨👮‍♂️ Não é permitido kickar um ADM oficial!', false);
  359. } else if (ofcAdms.includes(kickedPlayer.name) && ban == true && ofcAdms.includes(byPlayer.name)){
  360. room.kickPlayer(byPlayer.id, '🚨🤯 ?!', true);
  361. room.clearBans();
  362. } else if (ofcAdms.includes(kickedPlayer.name) && ban == false && ofcAdms.includes(byPlayer.name)){
  363. room.kickPlayer(byPlayer.id, '🚨🤯 ?!', false);
  364. }
  365. }
  366.  
  367.  
  368. /* PLAYER ACTIVITY */
  369.  
  370. var specMute = false;
  371. var senhasAdm = ['!senha1', '!senha2',]; // ===== ADICIONAR AS SENHAS AQUI TAMBÉM =====
  372. var colorAdm = '0xEBA300';
  373. var colorBan = '0x3A96DD';
  374. var colorPass = '0xFFC83D';
  375. var colorHelp = '0xF03A17';
  376. var redUni = '0xE56E56';
  377. var blueUni = '0x5689E5';
  378. var strongRed = '0xFF0000';
  379. var ofcAdms = [];
  380. var numofcAdms;
  381.  
  382. function timerBan(){
  383. setInterval(function(){
  384. room.clearBans();
  385. room.sendAnnouncement(`🙏 Os bans foram limpos após 30 minutos`, null, colorBan, "bold", 1);
  386. }, 1800000);
  387. }
  388.  
  389. function clearOfcAdm(){
  390. setInterval(function(){
  391. ofcAdms.splice(0, 200);
  392. console.log('[CLEARLIST] Lista de ADMs oficiais limpa após 12 horas');
  393. }, 43200000);
  394. }
  395.  
  396. timerBan();
  397. clearOfcAdm();
  398.  
  399. room.onPlayerChat = function(player, message) { // ABRINDO O ON PLAYER CHAT
  400. messageSay = message;
  401. messageFalar = message;
  402. message = message.split(" ");
  403. messageSay = messageSay.substring(5);
  404. messageFalar = messageFalar.substring(7);
  405. if (specMute == true && player.team == 0 && player.admin == false && message != senhasAdm[0] && message != senhasAdm[1] && message != senhasAdm[2] && message != senhasAdm[3] && message != senhasAdm[4]){
  406. return false;
  407. }
  408. if (["!help"].includes(message[0].toLowerCase()) && player.admin) {
  409. room.sendAnnouncement(`❓ !specoff / !specon / !bloquear / !bloquearcamp / !desbloquear / !clearbans / !say`, player.id, colorHelp, "bold", 1);
  410. } /* SENHAS DE ADM */
  411. if (message == "!senhaRichard77@") {
  412. room.setPlayerAdmin(player.id, true);
  413. if(ofcAdms.includes(player.name)){
  414. //pass
  415. } else{
  416. ofcAdms.push(player.name);
  417. }
  418. room.sendAnnouncement(`🔑 ${player.name} usou uma senha de adm by richard`, null, strongRed, "bold", 1);
  419. room.sendAnnouncement(`🔑 >>> Digite !help`, player.id, colorAdm, "bold", 1);
  420. console.log(`===== [ADM] ${player.name} USOU UMA SENHA DE ADM BY RICHARD =====`); // caso outra senha seja criada, utilizar essa estrutura
  421. }
  422. if (message == "!senhalukzboy14") {
  423. room.setPlayerAdmin(player.id, true);
  424. if(ofcAdms.includes(player.name)){
  425. //pass
  426. } else{
  427. ofcAdms.push(player.name);
  428. }
  429. room.sendAnnouncement(`🔑 ${player.name} usou uma senha de adm by Lukz`, null, strongRed, "bold", 1);
  430. room.sendAnnouncement(`🔑 >>> Digite !help`, player.id, colorAdm, "bold", 1);
  431. console.log(`===== [ADM] ${player.name} USOU UMA SENHA DE ADM BY LUKZ =====`); // caso outra senha seja criada, utilizar essa estrutura
  432. } /* FIM DAS SENHAS DE ADM */
  433. if (ofcAdms.includes(player.name) && player.admin) {
  434. /* COLORS */
  435. if (["!w1red"].includes(message[0].toLowerCase())) {
  436. room.setTeamColors(1, 45, 0x000000, [0xFFBB00, 0xE3A600]);
  437. room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 1`, null, redUni, "bold", 1);
  438. return false;
  439. }
  440. if (["!w2red"].includes(message[0].toLowerCase())) {
  441. room.setTeamColors(1, 45, 0xE3A600, [0x000000, 0x191919, 0x000000]);
  442. room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 2`, null, redUni, "bold", 1);
  443. return false;
  444. }
  445. if (["!w3red"].includes(message[0].toLowerCase())) {
  446. room.setTeamColors(1, 45, 0xE3A600, [0xFFFFFF, 0xC2C2C2]);
  447. room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 3`, null, redUni, "bold", 1);
  448. return false;
  449. }
  450. if (["!w4red"].includes(message[0].toLowerCase())) {
  451. room.setTeamColors(1, 45, 0xE3E3E3, [0x28C266, 0x22A356]);
  452. room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 4`, null, redUni, "bold", 1);
  453. return false;
  454. }
  455. if (["!w1blue"].includes(message[0].toLowerCase())) {
  456. room.setTeamColors(2, 45, 0x000000, [0xFFBB00, 0xE3A600]);
  457. room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 1`, null, blueUni, "bold", 1);
  458. return false;
  459. }
  460. if (["!w2blue"].includes(message[0].toLowerCase())) {
  461. room.setTeamColors(2, 45, 0xE3A600, [0x000000, 0x191919, 0x000000]);
  462. room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 2`, null, blueUni, "bold", 1);
  463. return false;
  464. }
  465. if (["!w3blue"].includes(message[0].toLowerCase())) {
  466. room.setTeamColors(2, 45, 0xE3A600, [0xFFFFFF, 0xC2C2C2]);
  467. room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 3`, null, blueUni, "bold", 1);
  468. return false;
  469. }
  470. if (["!w4blue"].includes(message[0].toLowerCase())) {
  471. room.setTeamColors(2, 45, 0xE3E3E3, [0x28C266, 0x22A356]);
  472. room.sendAnnouncement(`👕 ${player.name} mudou o uniforme para W! 4`, null, blueUni, "bold", 1);
  473. return false;
  474. }
  475. /* FIM DAS CORES */
  476. if (["!mute"].includes(message[0].toLowerCase())) { /* !mute <R/B/S> <team position> <duration = 3> */
  477. if (message.length == 3 || message.length == 4) {
  478. if (["R","B","S"].includes(message[1])) {
  479. var timeOut;
  480. if (message[1] == "R") {
  481. if (!Number.isNaN(Number.parseInt(message[2]))) {
  482. if (Number.parseInt(message[2]) <= teamR.length && Number.parseInt(message[2]) > 0) {
  483. if (teamR[Number.parseInt(message[2]) - 1].admin || muteList.filter((p) => p == teamR[Number.parseInt(message[2]) - 1].name).length > 0) {
  484. return false;
  485. }
  486. if (message.length == 4) {
  487. if (!Number.isNaN(Number.parseInt(message[3]))) {
  488. if (Number.parseInt(message[3]) > 0) {
  489. timeOut = Number.parseInt(message[3]) * 60 * 1000;
  490. }
  491. }
  492. }
  493. else {
  494. timeOut = 3 * 60 * 1000;
  495. }
  496. setTimeout(function(name) { muteList = muteList.filter((p) => p != name) }, timeOut, teamR[Number.parseInt(message[2]) - 1].name);
  497. muteList.push(teamR[Number.parseInt(message[2]) - 1].name);
  498. room.sendAnnouncement("🗣❌ " + teamR[Number.parseInt(message[2]) - 1].name + " foi mutado por " + (timeOut/60000) + " minuto(s) por " + player.name, null, announcementColor, "bold", null);
  499. return false;
  500. }
  501. }
  502. }
  503. if (message[1] == "B") {
  504. if (!Number.isNaN(Number.parseInt(message[2]))) {
  505. if (Number.parseInt(message[2]) <= teamB.length && Number.parseInt(message[2]) > 0) {
  506. if (teamB[Number.parseInt(message[2]) - 1].admin || muteList.filter((p) => p == teamB[Number.parseInt(message[2]) - 1].name).length > 0) {
  507. return false;
  508. }
  509. if (message.length == 4) {
  510. if (!Number.isNaN(Number.parseInt(message[3]))) {
  511. if (Number.parseInt(message[3]) > 0) {
  512. timeOut = Number.parseInt(message[3]) * 60 * 1000;
  513. }
  514. }
  515. }
  516. else {
  517. timeOut = 3 * 60 * 1000;
  518. }
  519. setTimeout(function(name) { muteList = muteList.filter((p) => p != name) }, timeOut, teamB[Number.parseInt(message[2]) - 1].name);
  520. muteList.push(teamB[Number.parseInt(message[2]) - 1].name);
  521. room.sendAnnouncement("🗣❌ " + teamB[Number.parseInt(message[2]) - 1].name + " foi mutado por " + (timeOut/60000) + " minuto(s) por " + player.name, null, announcementColor, "bold", null);
  522. return false;
  523. }
  524. }
  525. }
  526. if (message[1] == "S") {
  527. if (!Number.isNaN(Number.parseInt(message[2]))) {
  528. if (Number.parseInt(message[2]) <= teamS.length && Number.parseInt(message[2]) > 0) {
  529. if (teamS[Number.parseInt(message[2]) - 1].admin || muteList.filter((p) => p == teamS[Number.parseInt(message[2]) - 1].name).length > 0) {
  530. return false;
  531. }
  532. if (message.length == 4) {
  533. if (!Number.isNaN(Number.parseInt(message[3]))) {
  534. if (Number.parseInt(message[3]) > 0) {
  535. timeOut = Number.parseInt(message[3]) * 60 * 1000;
  536. }
  537. }
  538. }
  539. else {
  540. timeOut = 3 * 60 * 1000;
  541. }
  542. setTimeout(function(name) { muteList = muteList.filter((p) => p != name) }, timeOut, teamS[Number.parseInt(message[2]) - 1].name);
  543. muteList.push(teamS[Number.parseInt(message[2]) - 1].name);
  544. room.sendAnnouncement("🗣❌ " + teamS[Number.parseInt(message[2]) - 1].name + " foi mutado por " + (timeOut/60000) + " minuto(s) por " + player.name, null, announcementColor, "bold", null);
  545. return false;
  546. }
  547. }
  548. }
  549. }
  550. }
  551. }
  552. else if (["!unmute"].includes(message[0].toLowerCase())) { /* !unmute all/<nick> */
  553. if (message.length == 2 && message[1] == "all") {
  554. muteList = [];
  555. room.sendAnnouncement("🗣❌ Lista de mutados limpa.", null, announcementColor, "bold", null);
  556. return false;
  557. }
  558. if (message.length >= 2) {
  559. var name = "";
  560. for (var i = 1 ; i < message.length ; i++) {
  561. name += message[i] + " ";
  562. }
  563. name = name.substring(0, name.length - 1);
  564. muteList.length != muteList.filter((p) => p != name).length ? room.sendAnnouncement("🗣 " + name + " foi desmutado por " + player.name, null, announcementColor, "bold", null) : null;
  565. muteList = muteList.filter((p) => p != name);
  566. return false;
  567. }
  568. }
  569. if (["!specoff"].includes(message[0].toLowerCase())) {
  570. specMute = true;
  571. room.sendAnnouncement(`🔇 ${player.name} mutou o chat do spec`, null, strongRed, "bold", 1);
  572. }
  573. if (["!specon"].includes(message[0].toLowerCase())) {
  574. specMute = false;
  575. room.sendAnnouncement(`🔊 ${player.name} desmutou o chat da sala`, null, strongRed, "bold", 1);
  576. }
  577. if (["!bloquear", "!setpassword"].includes(message[0].toLowerCase())) {
  578. room.setPassword(password);
  579. room.sendAnnouncement(`🔒 ${player.name} bloqueou a sala!`, null, announcementColor, "bold", null);
  580. }
  581. if (["!bloquearcamp", "!setpasswordcamp"].includes(message[0].toLowerCase())) {
  582. room.setPassword(passwordcamp);
  583. room.sendAnnouncement(`🔒 ${player.name} bloqueou a sala para camp!`, null, announcementColor, "bold", null);
  584. }
  585. if (["!desbloquear", "!unsetpassword"].includes(message[0].toLowerCase())) {
  586. room.setPassword();
  587. room.sendAnnouncement(`🔓 ${player.name} desbloqueou a sala!`, null, announcementColor, "bold", null);
  588. }
  589. if (["!clearbans"].includes(message[0].toLowerCase())) {
  590. room.clearBans();
  591. room.sendAnnouncement(`🙏 ${player.name} Limpou os bans.`, null, colorBan, "bold", null);
  592. }
  593. if (["!say"].includes(message[0].toLowerCase())) {
  594. room.sendChat("" + messageSay, null);
  595. }
  596. if (["!falar"].includes(message[0].toLowerCase())) {
  597. room.sendChat("" + messageFalar, null);
  598. }
  599. } /* FECHANDO O IF PLAYERADMIN */
  600. if (["!bb", "!bye", "!cya", "!gn"].includes(message[0].toLowerCase())) {
  601. room.kickPlayer(player.id, "👋 Tchau!", false);
  602. }
  603. if (["!discord"].includes(message[0].toLowerCase())) {
  604. room.sendAnnouncement(`▒█▀▀▀ ▒█▀▀█ ▒█▀▀▀ `, player.id, colorOne, "normal", 0);
  605. room.sendAnnouncement(`▒█▀▀▀ ▒█▀▀▄ ▒█▀▀▀ `, player.id, colorTwo, "normal", 0);
  606. room.sendAnnouncement(`▒█░░░ ▒█▄▄█ ▒█░░░ `, player.id, colorThree, "normal", 0);
  607. room.sendAnnouncement(`🏆 Entre no maior campeonato de futsal x3: https://discord.gg/4mnY6tx`, player.id, colorFour, "bold", 0);
  608. }
  609. if (muteList.includes(player.name)) {
  610. room.sendAnnouncement("🗣❌ Você está mutado.", player.id);
  611. return false;
  612. }
  613. if (message[0][0] == "!") {
  614. return false;
  615. }
  616. } /* FECHANDO ON PLAYER CHAT */
  617.  
  618. room.onPlayerActivity = function(player) {
  619. }
  620.  
  621. room.onPlayerBallKick = function(player) {
  622. if (lastPlayersTouched[0] == null || player.id != lastPlayersTouched[0].id) {
  623. !activePlay ? activePlay = true : null;
  624. lastTeamTouched = player.team;
  625. lastPlayersTouched[1] = lastPlayersTouched[0];
  626. lastPlayersTouched[0] = player;
  627. }
  628. }
  629.  
  630. /* GAME MANAGEMENT */
  631.  
  632. room.onGameStart = function(byPlayer) {
  633. GKList = new Array(2 * maxPlayers).fill(0);
  634. activePlay = false;
  635. Rposs = 0;
  636. Bposs = 0;
  637. lastPlayersTouched = [null, null];
  638. goldenGoal = false;
  639. }
  640.  
  641. room.onGameStop = function(byPlayer) {
  642. }
  643.  
  644. room.onGamePause = function(byPlayer) {
  645. }
  646.  
  647. room.onGameUnpause = function(byPlayer) {
  648. }
  649.  
  650. room.onTeamGoal = function(team) {
  651. const scores = room.getScores();
  652. activePlay = false;
  653. if (lastPlayersTouched[0] == null && lastPlayersTouched[0].team == team) {
  654. room.sendAnnouncement("Não foi possível detectar de quem foi o gol.");
  655. }
  656. if (lastPlayersTouched[0] != null && lastPlayersTouched[0].team == team) {
  657. if (lastPlayersTouched[1] != null && lastPlayersTouched[1].team == team) {
  658. 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);
  659. }
  660. else {
  661. 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);
  662. }
  663. }
  664. else {
  665. 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);
  666. }
  667. if (scores.scoreLimit != 0 && (scores.red == scores.scoreLimit || scores.blue == scores.scoreLimit || goldenGoal == true)) {
  668. endGame(team);
  669. goldenGoal = false;
  670. setTimeout(() => { room.stopGame(); }, 1000);
  671. }
  672. }
  673.  
  674. room.onPositionsReset = function() {
  675. lastPlayersTouched = [null, null];
  676. }
  677.  
  678. /* MISCELLANEOUS */
  679.  
  680. room.onRoomLink = function(url) {
  681. }
  682.  
  683. room.onPlayerAdminChange = function(changedPlayer, byPlayer) {
  684. if (muteList.includes(changedPlayer.name) && changedPlayer.admin) {
  685. room.sendChat(changedPlayer.name + " foi desmutado.");
  686. muteList = muteList.filter((p) => p != changedPlayer.name);
  687. }
  688. }
  689.  
  690. room.onStadiumChange = function(newStadiumName, byPlayer) {
  691. }
  692.  
  693. room.onGameTick = function() {
  694. checkTime();
  695. getLastTouchOfTheBall();
  696. getStats();
  697. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement