LEGENDBOSS123

Bonk Commands

Sep 13th, 2022 (edited)
2,391
0
Never
3
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 346.41 KB | Gaming | 0 0
  1.  
  2. function BonkCommandsScriptInjector(f){
  3.     if(window.location == window.parent.location){
  4.         if(document.readyState == "complete"){f();}
  5.         else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  6.     }
  7. }
  8.  
  9. BonkCommandsScriptInjector(function(){
  10. var scope = window;
  11. scope.scope = scope;
  12. scope.Gwindow = document.getElementById("maingameframe").contentWindow;
  13. scope.Gdocument = document.getElementById("maingameframe").contentDocument;
  14. Gwindow.Gwindow = window;
  15. Gwindow.Gdocument = document;
  16.  
  17. scope.link2pastebin = "https://pastebin.com/2b8XqqYu";
  18. scope.link2greasyfork = "https://greasyfork.org/en/scripts/451341-bonk-commands";
  19.  
  20. if(typeof(scope.injectedBonkCommandsScript)=='undefined'){
  21.     scope.injectedBonkCommandsScript = true;
  22. }
  23. else{
  24.     clearInterval(injectedBonkCommandsScript);
  25. }
  26. scope.GENERATE_COPRIME_NUMBER = function(mini = 0,maxi = 0,coprimewith = 0,choices = []){
  27.     if(choices.length == 0){
  28.         for(var i = mini;i<maxi+1;i++){
  29.             choices.push(i);
  30.         }
  31.     }
  32.     firstTry = choices[Math.floor(Math.random()*choices.length)];
  33.     for(var i = 2; i<firstTry+1;i++){
  34.         if(firstTry%i == 0 && coprimewith%i == 0){
  35.             choices.splice(choices.indexOf(firstTry),1);
  36.             if(choices.length == 0){
  37.                 return 0;
  38.             }
  39.             return GENERATE_COPRIME_NUMBER(mini,maxi,coprimewith,choices);
  40.         }
  41.     }
  42.     return firstTry;
  43. };
  44. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  45.     if(choices.length == 0){
  46.         for(var i = mini;i<maxi+1;i++){
  47.             choices.push(i);
  48.         }
  49.     }
  50.     firstTry = choices[Math.floor(Math.random()*choices.length)];
  51.     for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  52.         if(i!=firstTry){
  53.             if(firstTry%i == 0){
  54.                 choices.splice(choices.indexOf(firstTry),1);
  55.                 if(choices.length == 0){
  56.                     return 0;
  57.                 }
  58.                 return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  59.             }
  60.         }
  61.     }
  62.     return firstTry;
  63. };
  64. scope.SHUFFLE_LIST = function(x){
  65.     var nl = x.slice();
  66.     for(var i = nl.length - 1;i>0;i--){
  67.         var r = Math.floor(Math.random()*(i+1));
  68.         var t = nl[i];
  69.         nl[i] = nl[r];
  70.         nl[r] = t;
  71.     }
  72.     return nl;
  73. };
  74. scope.str2ab = function(str) {
  75.     const buf = new ArrayBuffer(str.length);
  76.     const bufView = new Uint8Array(buf);
  77.     for (let i = 0, strLen = str.length; i < strLen; i++) {
  78.         bufView[i] = str.charCodeAt(i);
  79.     }
  80.     return buf;
  81. };
  82. scope.ab2str = function(buffer) {
  83.     return String.fromCharCode.apply(null, new Uint8Array(buffer));
  84. };
  85. scope.GENERATE_KEYS = async function(){
  86.     return crypto.subtle.generateKey({name: "RSA-OAEP",modulusLength: 2048,publicExponent: new Uint8Array([1, 0, 1]),hash: {name: "SHA-256"}},true,["encrypt","decrypt"]);
  87. };
  88. scope.CRYPT_NUMBER = function(key, data){
  89.  
  90.     result = 1;
  91.  
  92.     for(var i = 0;i<key[1];i++){
  93.         result*=data;
  94.         result = result%key[0];
  95.     }
  96.     return result%key[0];
  97.  
  98. };
  99.  
  100. scope.ENCRYPT_MESSAGE = async function(key,data){
  101.     try{
  102.         var encrypted = await window.crypto.subtle.encrypt(
  103.             {
  104.                 name: "RSA-OAEP"
  105.             },
  106.             key,
  107.             new TextEncoder().encode(data)
  108.         );
  109.         return btoa(ab2str(encrypted));
  110.     }
  111.     catch(E){
  112.         console.log(E);
  113.         return 0;
  114.     }
  115. };
  116.  
  117. scope.DECRYPT_MESSAGE = async function(key,data){
  118.     try{
  119.         var decrypted = await window.crypto.subtle.decrypt(
  120.             {
  121.                 name: "RSA-OAEP"
  122.             },
  123.             key,
  124.             str2ab(atob(data))
  125.         );
  126.         return new TextDecoder().decode(decrypted);
  127.     }
  128.     catch{
  129.         return 0;
  130.     }
  131. };
  132. scope.IMPORT_KEY = async function(key){
  133.     return await crypto.subtle.importKey("spki", str2ab(atob(key)),public_key.algorithm,true,["encrypt"]);
  134. };
  135. scope.EXPORT_KEY = async function(key){
  136.     var result = await crypto.subtle.exportKey("spki",key);
  137.     return btoa(ab2str(result));
  138. };
  139. scope.loadMap = function (m, encode = true) {
  140.     var mapdata = m;
  141.     if (encode) {
  142.         var mapdata = encodeToDatabase(m);
  143.     }
  144.     RECIEVE('42' + JSON.stringify([29, mapdata]));
  145.     SEND('42' + JSON.stringify([23, { "m": mapdata }]));
  146. };
  147. if(typeof(scope.textdecoder)=='undefined'){scope.textdecoder = new Gwindow.TextDecoder;}
  148. if(typeof(scope.textencoder)=='undefined'){scope.textencoder = new Gwindow.TextEncoder;}
  149.  
  150. class bytebuffer2 {
  151.   constructor() {
  152.     var g1d = [arguments];
  153.     this.index = 0;
  154.     this.buffer = new ArrayBuffer(100*1024);
  155.     this.view = new DataView(this.buffer);
  156.     this.implicitClassAliasArray = [];
  157.     this.implicitStringArray = [];
  158.     this.bodgeCaptureZoneDataIdentifierArray = [];
  159.   }
  160.  
  161.   readByte() {
  162.     var N0H = [arguments];
  163.     N0H[4] = this.view.getUint8(this.index);
  164.     this.index += 1;
  165.     return N0H[4];
  166.   }
  167.   writeByte(z0w) {
  168.     var v8$ = [arguments];
  169.     this.view.setUint8(this.index, v8$[0][0]);
  170.     this.index += 1;
  171.   }
  172.   readInt() {
  173.     var A71 = [arguments];
  174.     A71[6] = this.view.getInt32(this.index);
  175.     this.index += 4;
  176.     return A71[6];
  177.   }
  178.   writeInt(W6i) {
  179.     var p5u = [arguments];
  180.     this.view.setInt32(this.index, p5u[0][0]);
  181.     this.index += 4;
  182.   }
  183.   readShort() {
  184.     var R1R = [arguments];
  185.     R1R[9] = this.view.getInt16(this.index);
  186.     this.index += 2;
  187.     return R1R[9];
  188.   }
  189.   writeShort(H8B) {
  190.     var d_3 = [arguments];
  191.     this.view.setInt16(this.index, d_3[0][0]);
  192.     this.index += 2;
  193.   }
  194.   readUint() {
  195.     var W2$ = [arguments];
  196.     W2$[8] = this.view.getUint32(this.index);
  197.     this.index += 4;
  198.     return W2$[8];
  199.   }
  200.   writeUint(B2X) {
  201.     var f8B = [arguments];
  202.     this.view.setUint32(this.index, f8B[0][0]);
  203.     this.index += 4;
  204.   }
  205.   readBoolean() {
  206.     var h6P = [arguments];
  207.     h6P[6] = this.readByte();
  208.     return h6P[6] == 1;
  209.   }
  210.   writeBoolean(Y3I) {
  211.     var l79 = [arguments];
  212.     if (l79[0][0]) {
  213.       this.writeByte(1);
  214.     } else {
  215.       this.writeByte(0);
  216.     }
  217.   }
  218.   readDouble() {
  219.     var V60 = [arguments];
  220.     V60[4] = this.view.getFloat64(this.index);
  221.     this.index += 8;
  222.     return V60[4];
  223.   }
  224.   writeDouble(z4Z) {
  225.     var O41 = [arguments];
  226.     this.view.setFloat64(this.index, O41[0][0]);
  227.     this.index += 8;
  228.   }
  229.   readFloat() {
  230.     var I0l = [arguments];
  231.     I0l[5] = this.view.getFloat32(this.index);
  232.     this.index += 4;
  233.     return I0l[5];
  234.   }
  235.   writeFloat(y4B) {
  236.     var B0v = [arguments];
  237.     this.view.setFloat32(this.index, B0v[0][0]);
  238.     this.index += 4;
  239.   }
  240.   readUTF() {
  241.     var d6I = [arguments];
  242.     d6I[8] = this.readByte();
  243.     d6I[7] = this.readByte();
  244.     d6I[9] = d6I[8] * 256 + d6I[7];
  245.     d6I[1] = new Uint8Array(d6I[9]);
  246.     for (d6I[6] = 0; d6I[6] < d6I[9]; d6I[6]++) {
  247.       d6I[1][d6I[6]] = this.readByte();
  248.     }
  249.     return textdecoder.decode(d6I[1]);
  250.   }
  251.   writeUTF(L3Z) {
  252.     var Z75 = [arguments];
  253.     Z75[4] = textencoder.encode(Z75[0][0]);
  254.     Z75[3] = Z75[4].length;
  255.     Z75[5] = Math.floor(Z75[3]/256);
  256.     Z75[8] = Z75[3] % 256;
  257.     this.writeByte(Z75[5]);
  258.     this.writeByte(Z75[8]);
  259.     Z75[7] = this;
  260.     Z75[4].forEach(I_O);
  261.     function I_O(s0Q, H4K, j$o) {
  262.       var N0o = [arguments];
  263.       Z75[7].writeByte(N0o[0][0]);
  264.     }
  265.   }
  266.   toBase64() {
  267.     var P4$ = [arguments];
  268.     P4$[4] = "";
  269.     P4$[9] = new Uint8Array(this.buffer);
  270.     P4$[8] = this.index;
  271.     for (P4$[7] = 0; P4$[7] < P4$[8]; P4$[7]++) {
  272.       P4$[4] += String.fromCharCode(P4$[9][P4$[7]]);
  273.     }
  274.     return Gwindow.btoa(P4$[4]);
  275.   }
  276.   fromBase64(W69, A8Q) {
  277.     var o0n = [arguments];
  278.     o0n[8] = Gwindow.pako;
  279.     o0n[6] = Gwindow.atob(o0n[0][0]);
  280.     o0n[9] = o0n[6].length;
  281.     o0n[4] = new Uint8Array(o0n[9]);
  282.     for (o0n[1] = 0; o0n[1] < o0n[9]; o0n[1]++) {
  283.       o0n[4][o0n[1]] = o0n[6].charCodeAt(o0n[1]);
  284.     }
  285.     if (o0n[0][1] === true) {
  286.       o0n[5] = o0n[8].inflate(o0n[4]);
  287.       o0n[4] = o0n[5];
  288.     }
  289.     this.buffer = o0n[4].buffer.slice(
  290.       o0n[4].byteOffset,
  291.       o0n[4].byteLength + o0n[4].byteOffset
  292.     );
  293.     this.view = new DataView(this.buffer);
  294.     this.index = 0;
  295.   }
  296. };
  297.  
  298. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  299. if(typeof(scope.originalDatenow)=='undefined'){scope.originalDatenow = Gwindow.Date.now;}
  300.  
  301. if(typeof(scope.originalXMLOpen)=='undefined'){scope.originalXMLOpen = Gwindow.XMLHttpRequest.prototype.open;}
  302. if(typeof(scope.originalXMLSend)=='undefined'){scope.originalXMLSend = Gwindow.XMLHttpRequest.prototype.send;}
  303. if(typeof(scope.searchrequested)=='undefined'){scope.searchrequested = 0;}
  304. if(typeof(scope.originalDrawCircle)=='undefined'){scope.originalDrawCircle = Gwindow.PIXI.Graphics.prototype.drawCircle;}
  305. if(typeof(scope.parentDraw)=='undefined'){scope.parentDraw = 0;}
  306. if(typeof(scope.pixiCircle)=='undefined'){scope.pixiCircle = new Gwindow.PIXI.Graphics();}
  307. if(typeof(scope.container)=='undefined'){scope.container = new Gwindow.PIXI.Container();container.addChild(pixiCircle);}
  308. if(typeof(scope.canvasWidth)=='undefined'){scope.canvasWidth = -1;}
  309. if(typeof(scope.savedrooms)=='undefined'){scope.savedrooms = [];}
  310. if(typeof(scope.inroom)=='undefined'){scope.inroom = false;}
  311. if(typeof(scope.currentroomaddress)=='undefined'){scope.currentroomaddress = -1;}
  312. if(typeof(scope.savedroomsdata)=='undefined'){scope.savedroomsdata = {};}
  313. if(typeof(scope.jukeboxplayerURL)=='undefined'){scope.jukeboxplayerURL = "";}
  314. if(typeof(scope.jukeboxplayervolume)=='undefined'){scope.jukeboxplayervolume = 20;}
  315. if(typeof(scope.gameStartTimeStamp)=='undefined'){scope.gameStartTimeStamp = 0;}
  316. scope.checkInstance = async function(index){
  317.     var doesitwork = false;
  318.     await fetch(pipedurllist[index]+"dQw4w9WgXcQ").then(
  319.         function(r){
  320.             return r.json();
  321.         }
  322.     ).then(async function(r){
  323.         if (r.audioStreams && !r.error){
  324.             for(var i2 = 0;i2<r.audioStreams.length;i2++){
  325.                 if(r.audioStreams[i2].url){
  326.                     try{
  327.                         var f = await fetch(r.audioStreams[i2].url);
  328.                         if(f.ok){
  329.                             doesitwork = true;
  330.                             return;
  331.                         }
  332.  
  333.                     }
  334.                     catch(e){}
  335.                 }
  336.             }
  337.         }
  338.     }).catch(function(e){});
  339.     if(!doesitwork){
  340.         return -1;
  341.     }
  342.     return index;
  343. };
  344. scope.checkJukeboxStream = async function(index,id){
  345.     var doesitwork = false;
  346.     var urlreturn = [];
  347.     await fetch(pipedurllist[index]+id).then(
  348.         function(r){
  349.             return r.json();
  350.         }
  351.     ).then(async function(r){
  352.         if (r.audioStreams && !r.error){
  353.             for(var i2 = 0;i2<r.audioStreams.length;i2++){
  354.                 if(r.audioStreams[i2].url){
  355.                     try{
  356.                         var f = await fetch(r.audioStreams[i2].url);
  357.                         if(f.ok){
  358.                             doesitwork = true;
  359.                             urlreturn = [r.audioStreams[i2].url,r.title,r.uploader];
  360.                             return;
  361.                         }
  362.  
  363.                     }
  364.                     catch(e){}
  365.                 }
  366.             }
  367.         }
  368.     }).catch(function(e){});
  369.     if(!doesitwork){
  370.         return -1;
  371.     }
  372.     return urlreturn;
  373. };
  374.  
  375. scope.checkInstances = async function (){
  376.     pipedindexes = [];
  377.     for (var index = 0;index<pipedurllist.length;index++){
  378.         checkInstance(index).then(function(value){
  379.             if(value!=-1){
  380.                 pipedindexes.push(value);
  381.             }
  382.         });
  383.     }    
  384. };
  385. if(typeof(scope.pipedurllist)=='undefined'){
  386.     scope.pipedurllist = [
  387.         "https://pipedapi.kavin.rocks/streams/",
  388.         "https://pipedapi.syncpundit.io/streams/",
  389.         "https://api-piped.mha.fi/streams/",
  390.         "https://piped-api.garudalinux.org/streams/",
  391.         "https://pipedapi.rivo.lol/streams/",
  392.         "https://pipedapi.leptons.xyz/streams/",
  393.         "https://piped-api.lunar.icu/streams/",
  394.         "https://ytapi.dc09.ru/streams/",
  395.         "https://piped.tokhmi.xyz/streams/",
  396.         "https://pipedapi.aeong.one/streams/"];
  397.     scope.pipedindexes = [];
  398.     checkInstances();
  399. }
  400.  
  401.  
  402.  
  403. if(typeof(scope.requestAnimationFrameOriginal)=='undefined'){scope.requestAnimationFrameOriginal = Gwindow.requestAnimationFrame;}
  404.  
  405.  
  406. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  407. if(typeof(scope.bonkwssextra)=='undefined'){scope.bonkwssextra = [];}
  408. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  409. if(typeof(scope.wsssendrecievelog)=='undefined'){scope.wsssendrecievelog = [];}
  410. if(typeof(scope.wsssendlog)=='undefined'){scope.wsssendlog = [];}
  411. if(typeof(scope.wssrecievelog)=='undefined'){scope.wssrecievelog = [];}
  412. if(typeof(scope.wsslogpaused)=='undefined'){scope.wsslogpaused = false;}
  413. if(typeof(scope.debuggeropen)=='undefined'){scope.debuggeropen = false;}
  414. if(typeof(scope.debuggercount)=='undefined'){scope.debuggercount = true;}
  415. if(typeof(scope.packetcount)=='undefined'){scope.packetcount = 0;}
  416. if(typeof(scope.requestedmaps)=='undefined'){scope.requestedmaps = [];}
  417. if(typeof(scope.maponclick)=='undefined'){scope.maponclick = 0;}
  418. if(typeof(scope.LZString)=='undefined'){scope.LZString = Gwindow.LZString;}
  419. if(typeof(scope.PSON)=='undefined'){scope.PSON = Gwindow.dcodeIO.PSON;}
  420. if(typeof(scope.bytebuffer)=='undefined'){scope.bytebuffer = Gwindow.dcodeIO.ByteBuffer;}
  421. if(typeof(scope.speech)=='undefined'){scope.speech = new SpeechSynthesisUtterance();speech.pitch = 0.75;}
  422. if(typeof(scope.sayer)=='undefined'){scope.sayer = speechSynthesis;sayer.volume = 0.5;sayer.rate = 1.25;}
  423. if(typeof(scope.pollactive)=='undefined'){scope.pollactive = [false,0,0,[]];}
  424. if(typeof(scope.pollactive2)=='undefined'){scope.pollactive2 = [false,0,[]];}
  425. if(typeof(scope.mode)=='undefined'){scope.mode = '';}
  426. if(typeof(scope.FFA)=='undefined'){scope.FFA = true;}
  427. if(typeof(scope.recording)=='undefined'){scope.recording = false;}
  428. if(typeof(scope.recordingdata)=='undefined'){scope.recordingdata = [];}
  429. if(typeof(scope.recorddata)=='undefined'){scope.recorddata = {};}
  430. if(typeof(scope.recordingid)=='undefined'){scope.recordingid = -1;}
  431. if (typeof (scope.currentmap) == 'undefined') { scope.currentmap = []; }
  432.  
  433. if(typeof(scope.wordlist)=='undefined'){
  434.     scope.wordlist = [];
  435.     fetch("https://api.github.com/repos/first20hours/google-10000-english/contents/20k.txt").then(function(data){
  436.         return data.json();
  437.     }).then(function(data){
  438.         fetch("https://api.github.com/repos/first20hours/google-10000-english/git/blobs/"+data.sha).then(function(data){
  439.             return data.json();
  440.         }).then(function(data){
  441.             scope.wordlist = atob(data.content).split("\n");
  442.         });
  443.     });
  444. }
  445.  
  446. if(typeof(scope.allstyles)=='undefined'){scope.allstyles = {};}
  447. if(typeof(scope.mystyle)=='undefined'){scope.mystyle = [0,0,0];}
  448. if(typeof(scope.ISpsonpair)=='undefined'){scope.ISpsonpair = new Gwindow.dcodeIO.PSON.StaticPair(["physics", "shapes", "fixtures", "bodies", "bro", "joints", "ppm", "lights", "spawns", "lasers", "capZones", "type", "w", "h", "c", "a", "v", "l", "s", "sh", "fr", "re", "de", "sn", "fc", "fm", "f", "d", "n", "bg", "lv", "av", "ld", "ad", "fr", "bu", "cf", "rv", "p", "d", "bf", "ba", "bb", "aa", "ab", "axa", "dr", "em", "mmt", "mms", "ms", "ut", "lt", "New body", "Box Shape", "Circle Shape", "Polygon Shape", "EdgeChain Shape", "priority", "Light", "Laser", "Cap Zone", "BG Shape", "Background Layer", "Rotate Joint", "Slider Joint", "Rod Joint", "Gear Joint", 65535, 16777215]);}
  449. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  450. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 200;}
  451. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  452. if(typeof(scope.delplayerids)=='undefined'){scope.delplayerids = {};}
  453. if(typeof(scope.myid)=='undefined'){scope.myid = -1;}
  454. if(typeof(scope.hostid)=='undefined'){scope.hostid = -1;}
  455. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  456. if(typeof(scope.originalMapLoad)=='undefined'){scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild;}
  457. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  458. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  459. if(typeof(scope.private_chat_keys)=='undefined'){GENERATE_KEYS().then(function(e){scope.private_chat_keys = e;scope.private_key = private_chat_keys.privateKey;scope.public_key = private_chat_keys.publicKey;});}
  460.  
  461. if(typeof(scope.jukeboxplayer)=='undefined'){
  462.     scope.jukeboxplayer = Gdocument.createElement("audio");
  463.     jukeboxplayer.controls = true;
  464.     jukeboxplayer.loop = true;
  465. }
  466.  
  467. if(Gdocument.getElementById("savedroombutton") == null){
  468.     scope.savedroombutton = Gdocument.createElement("div");
  469.     savedroombutton.id = "savedroombutton";
  470.     savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
  471.     savedroombutton.textContent = "Save Room";
  472.     savedroombutton.style["left"] = "120px";
  473.     savedroombutton.style["position"] = "absolute";
  474.     savedroombutton.style["width"] = "90px";
  475.     savedroombutton.style["height"] = "30px";
  476.     savedroombutton.style["color"] = "#ffffff";
  477.     savedroombutton.style["text-align"] = "center";
  478.     savedroombutton.style["vertical-align"] = "middle";
  479.     savedroombutton.style["line-height"] = "30px";
  480.     savedroombutton.style["right"] = "0";
  481.     savedroombutton.style["cursor"] = "pointer";
  482.     savedroombutton.style["bottom"] = "10px";
  483.     savedroombutton.style["margin"] = "auto";
  484.     savedroombutton.style["bottom"] = "10px";
  485.     savedroombutton.onclick = function(){
  486.         if(!savedrooms.includes(currentroomaddress) && currentroomaddress!=-1){
  487.             savedrooms.push(currentroomaddress);
  488.             savedroomsdata[currentroomaddress] = {"exists":true};
  489.         }
  490.         Gdocument.getElementById("sm_connectingWindowCancelButton").click();
  491.     };
  492.     Gdocument.getElementById("sm_connectingWindowCancelButton").style["left"] = "-120px";
  493.     Gdocument.getElementById("sm_connectingWindow").appendChild(savedroombutton)
  494. }
  495.    
  496. if(Gdocument.getElementById("maploadtypedropdowntitlerequested") == null){
  497.     scope.clearmaprequests = Gdocument.createElement("div");
  498.     clearmaprequests.id = "clearmaprequests";
  499.     clearmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  500.     clearmaprequests.textContent = "Clear";
  501.     clearmaprequests.style["position"] = "absolute";
  502.     clearmaprequests.style["display"] = "none";
  503.     if(typeof(ishost)!='undefined'){
  504.         if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  505.             clearmaprequests.style["display"] = "block";
  506.         }
  507.     }
  508.     clearmaprequests.style["right"] = "306px";
  509.     clearmaprequests.style["top"] = "57px";
  510.     clearmaprequests.style["height"] = "23px";
  511.     clearmaprequests.style["width"] = "47px";
  512.     clearmaprequests.style["line-height"] = "23px";
  513.     clearmaprequests.style["font-size"] = "14px";
  514.     clearmaprequests.addEventListener("click",function(){
  515.         requestedmaps = [];
  516.         Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "inherit";
  517.         Gdocument.getElementById("maploadwindowstatustext").textContent = "No Maps";
  518.         while(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0){
  519.             Gdocument.getElementById("maploadwindowmapscontainer").removeChild(Gdocument.getElementById("maploadwindowmapscontainer").firstChild);
  520.         }
  521.     });
  522.     Gdocument.getElementById("maploadwindow").insertBefore(clearmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  523.    
  524.     scope.refreshmaprequests = Gdocument.createElement("div");
  525.     refreshmaprequests.id = "refreshmaprequests";
  526.     refreshmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  527.     refreshmaprequests.textContent = "Refresh";
  528.     refreshmaprequests.style["position"] = "absolute";
  529.     refreshmaprequests.style["display"] = "none";
  530.     if(typeof(ishost)!='undefined'){
  531.         if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  532.             refreshmaprequests.style["display"] = "block";
  533.         }
  534.     }
  535.     refreshmaprequests.style["right"] = "357px";
  536.     refreshmaprequests.style["top"] = "57px";
  537.     refreshmaprequests.style["height"] = "23px";
  538.     refreshmaprequests.style["width"] = "47px";
  539.     refreshmaprequests.style["line-height"] = "23px";
  540.     refreshmaprequests.style["font-size"] = "14px";
  541.     refreshmaprequests.addEventListener("click",function(){
  542.         searchrequested = 1;
  543.        
  544.         Gdocument.getElementById("maploadtypedropdowntitle").click();
  545.         Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  546.         dropdownrequested.style["display"] = "none";
  547.         clearmaprequests.style["display"] = "block";
  548.         refreshmaprequests.style["display"] = "block";
  549.         Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  550.         Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  551.         Gdocument.getElementById("maploadtypedropdownoption10").click();
  552.        
  553.     });
  554.     Gdocument.getElementById("maploadwindow").insertBefore(refreshmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  555.  
  556.    
  557.    
  558.     scope.dropdownrequested = Gdocument.createElement("div");
  559.     dropdownrequested.classList = "dropdown-option dropdown_classic";
  560.     dropdownrequested.style["display"] = "none";
  561.     dropdownrequested.id = "maploadtypedropdowntitlerequested";
  562.  
  563.     if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block"){
  564.         dropdownrequested.style["display"] = "block";
  565.     }
  566.     dropdownrequested.textContent = "MAP REQUESTS";
  567.     dropdownrequested.onclick = function(){
  568.         searchrequested = 1;
  569.         Gdocument.getElementById("maploadtypedropdowntitle").click();
  570.         Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  571.         dropdownrequested.style["display"] = "none";
  572.         clearmaprequests.style["display"] = "block";
  573.         refreshmaprequests.style["display"] = "block";
  574.         Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  575.         Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  576.         Gdocument.getElementById("maploadtypedropdownoption10").click();
  577.        
  578.     };
  579.     (new MutationObserver(function(){if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "none"){ dropdownrequested.style["display"] = "none"; clearmaprequests.style["display"] = "none";refreshmaprequests.style["display"] = "none"; } else{ dropdownrequested.style["display"] = "block";}})).observe(Gdocument.getElementById("maploadtypedropdownoption10"),{attributes:true,childList:true});
  580.    
  581.    
  582.        
  583.     Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownrequested,Gdocument.getElementById("maploadtypedropdownoption1"));
  584.     Gdocument.getElementById("maploadwindowmapscontainer").__defineGetter__("clientHeight",function(){if(Gdocument.getElementById("maploadtypedropdowntitle").textContent != "MAP REQUESTS"){return Gdocument.getElementById("maploadwindowmapscontainer").getClientRects()[0].height;}else{return 0;}});
  585.  
  586. };
  587. scope.sandboxonclick = function(){
  588.     Gdocument.getElementById("roomlistrefreshbutton").click();
  589.     Gdocument.getElementById("roomlistcreatebutton").click();
  590.     sandboxon = true;
  591. };
  592. scope.checkboxclearbuttononclick = function(){
  593.     var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  594.     var e = true;
  595.     for(var i = 0; i<classes.length;i++){
  596.         if(classes[i].checked == true){
  597.             e = false
  598.         }
  599.         classes[i].checked = false;
  600.     }
  601.     if(e){
  602.         for(var i = 0; i<classes.length;i++){
  603.             classes[i].checked = true;
  604.         }
  605.     }
  606. };
  607. Gdocument.getElementById("ingamechatcontent").__defineGetter__("childElementCount",function(){return this.children.length/50;});
  608. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  609.     Gdocument.getElementById("roomlistrefreshbutton").click();
  610.     scope.sandboxbutton = Gdocument.createElement("div");
  611.     sandboxbutton.id = "classic_mid_sandbox";
  612.     sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  613.     sandboxbutton.textContent = "Sandbox";
  614.     sandboxbutton.addEventListener("click",sandboxonclick);
  615.     Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  616.  
  617. }
  618. if(Gdocument.getElementById("clearallcheckboxes")==null){
  619.     scope.checkboxclearbutton = Gdocument.createElement("div");
  620.     checkboxclearbutton.id = "clearallcheckboxes";
  621.     checkboxclearbutton.classList.value = "brownButton brownButton_classic buttonShadow";
  622.     checkboxclearbutton.textContent = "On/Off";
  623.     checkboxclearbutton.style["position"] = "absolute";
  624.     checkboxclearbutton.style["display"] = "none";
  625.     if(typeof(ishost)!='undefined'){
  626.         if(ishost && stopquickplay == 0){
  627.             checkboxclearbutton.style["display"] = "block";
  628.         }
  629.     }
  630.     checkboxclearbutton.style["right"] = "255px";
  631.     checkboxclearbutton.style["top"] = "57px";
  632.     checkboxclearbutton.style["height"] = "23px";
  633.     checkboxclearbutton.style["width"] = "47px";
  634.     checkboxclearbutton.style["line-height"] = "23px";
  635.     checkboxclearbutton.style["font-size"] = "13px";
  636.     checkboxclearbutton.addEventListener("click",checkboxclearbuttononclick);
  637.     Gdocument.getElementById("maploadwindow").insertBefore(checkboxclearbutton,Gdocument.getElementById("maploadwindowsearchinput"));
  638.  
  639. }
  640. scope.holdloadbuttonTimeout = [];
  641. scope.holdloadbutton = function(){
  642.     var scrollcount = 0;
  643.     var mapwindow = Gdocument.getElementById("maploadwindowmapscontainer");
  644.     mapwindow.scroll(0,mapwindow.scrollHeight);
  645. };
  646.    
  647.  
  648. if(Gdocument.getElementById("mapwindowloadall")==null){
  649.     scope.loadall = Gdocument.createElement("div");
  650.     loadall.id = "mapwindowloadall";
  651.     loadall.classList.value = "brownButton brownButton_classic buttonShadow";
  652.     loadall.textContent = "Load";
  653.     loadall.style["position"] = "absolute";
  654.     loadall.style["display"] = "block";
  655.     loadall.style["left"] = "204px";
  656.     loadall.style["top"] = "57px";
  657.     loadall.style["height"] = "23px";
  658.     loadall.style["width"] = "34px";
  659.     loadall.style["line-height"] = "23px";
  660.     loadall.style["font-size"] = "12px";
  661.     var repeat = function(){holdloadbutton();holdloadbuttonTimeout.push(setTimeout(repeat,25));};
  662.     loadall.onmousedown = function(){repeat();};
  663.     loadall.onmouseup = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  664.     loadall.onmouseout = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  665.  
  666.     Gdocument.getElementById("maploadwindow").insertBefore(loadall,Gdocument.getElementById("maploadwindowsearchinput"));
  667.  
  668. }
  669. if(Gdocument.getElementById("BonkCommandsDebuggerContainer")==null){
  670.     Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  671.     scope.debuggermenu = Gdocument.createElement("div");
  672.     debuggermenu.id = "BonkCommandsDebuggerContainer";
  673.     debuggermenu.style["position"] = "absolute";
  674.     debuggermenu.style["display"] = "none";
  675.     if(typeof(debuggeropen)!='undefined'){
  676.         if(debuggeropen){
  677.             debuggermenu.style["display"] = "block";
  678.         }
  679.     }
  680.    
  681.     debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  682.     debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  683.  
  684.     debuggermenu.style["background"] = "rgb(26, 39, 51)";
  685.  
  686.    
  687.     scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  688.     scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  689.  
  690.    
  691.     scope.logmenu = Gdocument.createElement("div");
  692.     logmenu.id = "BonkCommandsWebSocketLog";
  693.     logmenu.style["position"] = "absolute";
  694.     logmenu.style["width"] = width.toString()+"px";
  695.     logmenu.style["height"] = height.toString()+"px";
  696.     logmenu.style["top"] = "80px";
  697.     logmenu.style["left"] = "10px";
  698.     logmenu.style["background"] = "rgb(207, 216, 220)";
  699.    
  700.    
  701.    
  702.    
  703.     scope.logmenutopleft = Gdocument.createElement("div");
  704.     logmenutopleft.id = "BonkCommandsWebSocketLog";
  705.     logmenutopleft.style["position"] = "absolute";
  706.     logmenutopleft.textContent = "Sending";
  707.     logmenutopleft.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  708.    
  709.     logmenutopleft.style["width"] = (width/2).toString()+"px";
  710.     logmenutopleft.style["height"] = "30px";
  711.     logmenutopleft.style["top"] = "-30px";
  712.     logmenutopleft.style["background"] = "rgb(0, 150, 136)";
  713.    
  714.    
  715.     logmenu.appendChild(logmenutopleft);
  716.    
  717.     scope.logmenutopright = Gdocument.createElement("div");
  718.     logmenutopright.id = "BonkCommandsWebSocketLog";
  719.     logmenutopright.style["position"] = "absolute";
  720.     logmenutopright.textContent = "Recieving";
  721.     logmenutopright.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  722.     logmenutopright.style["width"] = (width/2).toString()+"px";
  723.     logmenutopright.style["height"] = "30px";
  724.     logmenutopright.style["left"] = (width/2).toString()+"px";
  725.     logmenutopright.style["top"] = "-30px";
  726.     logmenutopright.style["background"] = "rgb(0, 150, 136)";
  727.     logmenu.appendChild(logmenutopright);
  728.    
  729.    
  730.     scope.logmenutable = Gdocument.createElement("table");
  731.     logmenutable.id = "BonkCommandsWebSocketTable";
  732.     logmenutable.style["position"] = "absolute";
  733.     logmenutable.style["border-spacing"] = "0px";
  734.     logmenutable.style["font-size"] = "12px";
  735.     logmenutable.style["display"] = "table-cell";
  736.     logmenutable.style["width"] = "50%";
  737.     logmenutable.style["height"] = "100%";
  738.     logmenutable.style["table-layout"] = "fixed";
  739.     logmenutable.style["overflow-y"] = "scroll";
  740.  
  741.     scope.logmenutable2 = Gdocument.createElement("table");
  742.     logmenutable2.id = "BonkCommandsWebSocketTable2";
  743.     logmenutable2.style["position"] = "absolute";
  744.     logmenutable2.style["width"] = "50%";
  745.     logmenutable2.style["left"] = "50%";
  746.     logmenutable2.style["font-size"] = "12px";
  747.     logmenutable2.style["display"] = "table-cell";
  748.     logmenutable2.style["height"] = "100%";
  749.     logmenutable2.style["table-layout"] = "fixed";
  750.     logmenutable2.style["overflow-y"] = "scroll";
  751.     logmenutable2.style["border-spacing"] = "0px";
  752.     scope.leftsync = false;
  753.     scope.rightsync = false;
  754.     logmenutable2.onscroll = function(){
  755.         if(!leftsync){
  756.             rightsync = true;
  757.             logmenutable.scrollTop = this.scrollTop;
  758.         }
  759.         else{
  760.             leftsync = false;
  761.         }
  762.     };
  763.     logmenutable.onscroll = function(){
  764.         if(!rightsync){
  765.             leftsync = true;
  766.             logmenutable2.scrollTop = this.scrollTop;
  767.         }
  768.         else{
  769.             rightsync = false
  770.         }
  771.     };
  772.    
  773.     logmenu.appendChild(logmenutable);
  774.     logmenu.appendChild(logmenutable2);
  775.    
  776.     debuggermenu.appendChild(logmenu);
  777.    
  778.     scope.debuggermenuclose = Gdocument.createElement("div");
  779.     debuggermenuclose.id = "debuggerclose";
  780.     debuggermenuclose.classList = "windowCloseButton brownButton brownButton_classic buttonShadow";
  781.     debuggermenuclose.style["position"] = "absolute";
  782.     debuggermenuclose.style["top"] = "40px";
  783.     debuggermenuclose.style["right"] = "5px";
  784.     debuggermenuclose.onclick = function(){debuggeropen = false;debuggermenu.style["display"] = "none";Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  785. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";};
  786.    
  787.     debuggermenu.appendChild(debuggermenuclose);
  788.    
  789.    
  790.    
  791.     scope.debuggerform = Gdocument.createElement("form");
  792.     debuggerform.autocomplete = "off";
  793.    
  794.     scope.debuggerinput = Gdocument.createElement("input");
  795.     debuggerinput.style["position"] = "absolute";
  796.     debuggerinput.style["width"] = width.toString()+"px";
  797.     debuggerinput.style["left"] = "10px";
  798.     debuggerinput.style["top"] = (height+90).toString()+"px";
  799.     debuggerinput.style["font-size"] = "12px";
  800.     debuggerinput.style["height"] = "20px";
  801.     debuggerform.appendChild(debuggerinput);
  802.    
  803.    
  804.    
  805.     scope.debuggersendrecieve = Gdocument.createElement("div");
  806.     debuggersendrecieve.style["position"] = "absolute";
  807.     debuggersendrecieve.style["width"] = "140px";
  808.     debuggersendrecieve.style["left"] = "10px";
  809.     debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  810.     debuggersendrecieve.style["font-size"] = "15px";
  811.     debuggersendrecieve.style["height"] = "20px";
  812.     debuggersendrecieve.classList = "brownButton brownButton_classic buttonShadow";
  813.     debuggersendrecieve.textContent = "Send";
  814.     debuggersendrecieve.value = 0;
  815.     debuggersendrecieve.onclick = function(){if(this.value == 0){this.textContent = "Recieve";this.value = 1;}else{this.textContent = "Send";this.value = 0;}};
  816.  
  817.     debuggermenu.appendChild(debuggersendrecieve);
  818.    
  819.     scope.debuggerpausebutton = Gdocument.createElement("div");
  820.     debuggerpausebutton.style["position"] = "absolute";
  821.     debuggerpausebutton.style["width"] = "140px";
  822.     debuggerpausebutton.style["left"] = "10px";
  823.     debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  824.     debuggerpausebutton.style["font-size"] = "15px";
  825.     debuggerpausebutton.style["height"] = "20px";
  826.     debuggerpausebutton.classList = "brownButton brownButton_classic buttonShadow";
  827.     debuggerpausebutton.textContent = "Pause";
  828.     debuggerpausebutton.value = 0;
  829.     debuggerpausebutton.onclick = function(){if(this.value == 0){this.textContent = "Play";this.value = 1;wsslogpaused = true}else{this.textContent = "Pause";this.value = 0;wsslogpaused = false;}};
  830.  
  831.     debuggermenu.appendChild(debuggerpausebutton);
  832.    
  833.     scope.debuggereval = Gdocument.createElement("input");
  834.     debuggereval.style["position"] = "absolute";
  835.     debuggereval.style["width"] = (width-150).toString()+"px";
  836.     debuggereval.style["right"] = "10px";
  837.     debuggereval.style["top"] = (height+120).toString()+"px";
  838.     debuggereval.style["font-size"] = "12px";
  839.     debuggereval.style["height"] = "20px";
  840.     debuggereval.addEventListener("keypress",function(e){if(e.repeat){return;}if(e.code == "Enter" && this.value.length>0){if(debuggersendrecieve.value == 0){SEND(this.value);}else{RECIEVE(this.value);}}});
  841.    
  842.    
  843.     debuggerform.appendChild(debuggereval);
  844.     debuggermenu.appendChild(debuggerform);
  845.     Gdocument.getElementById("newbonkgamecontainer").appendChild(debuggermenu);
  846.  
  847. }
  848. scope.ISdecode = function(rawdata) {
  849.     rawdata_caseflipped = "";
  850.     for (i = 0; i < rawdata.length; i++) {
  851.         if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toLowerCase()) {
  852.             rawdata_caseflipped += rawdata.charAt(i).toUpperCase();
  853.         } else if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toUpperCase()) {
  854.             rawdata_caseflipped += rawdata.charAt(i).toLowerCase();
  855.         } else {
  856.             rawdata_caseflipped += rawdata.charAt(i);
  857.         }
  858.     }
  859.  
  860.     data_deLZd = LZString.decompressFromEncodedURIComponent(rawdata_caseflipped);
  861.     databuffer = bytebuffer.fromBase64(data_deLZd);
  862.     data = ISpsonpair.decode(databuffer.buffer);
  863.     return data;
  864. };
  865.    
  866. scope.ISencode = function(obj) {
  867.     data = ISpsonpair.encode(obj);
  868.     b64 = data.toBase64();
  869.     lzd = LZString.compressToEncodedURIComponent(b64);
  870.  
  871.     caseflipped = "";
  872.     for (i = 0; i < lzd.length; i++) {
  873.         if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toLowerCase()) {
  874.             caseflipped += lzd.charAt(i).toUpperCase();
  875.         } else if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toUpperCase()) {
  876.             caseflipped += lzd.charAt(i).toLowerCase();
  877.         } else {
  878.             caseflipped += lzd.charAt(i);
  879.         }
  880.     }
  881.  
  882.  
  883.     return caseflipped;
  884. };
  885.    
  886. scope.decodeIS = function(x){
  887.     return ISdecode(x);
  888. };
  889. scope.encodeIS = function(x){
  890.     return ISencode(x);
  891. };
  892. scope.encodeToDatabase = function (W2A) {
  893.     var M3n = [arguments];
  894.     M3n[1] = new bytebuffer2;
  895.     M3n[9] = M3n[0][0].physics;
  896.     M3n[0][0].v = 15;
  897.     M3n[1].writeShort(M3n[0][0].v);
  898.     M3n[1].writeBoolean(M3n[0][0].s.re);
  899.     M3n[1].writeBoolean(M3n[0][0].s.nc);
  900.     M3n[1].writeShort(M3n[0][0].s.pq);
  901.     M3n[1].writeFloat(M3n[0][0].s.gd);
  902.     M3n[1].writeBoolean(M3n[0][0].s.fl);
  903.     M3n[1].writeUTF(M3n[0][0].m.rxn);
  904.     M3n[1].writeUTF(M3n[0][0].m.rxa);
  905.     M3n[1].writeUint(M3n[0][0].m.rxid);
  906.     M3n[1].writeShort(M3n[0][0].m.rxdb);
  907.     M3n[1].writeUTF(M3n[0][0].m.n);
  908.     M3n[1].writeUTF(M3n[0][0].m.a);
  909.     M3n[1].writeUint(M3n[0][0].m.vu);
  910.     M3n[1].writeUint(M3n[0][0].m.vd);
  911.     M3n[1].writeShort(M3n[0][0].m.cr.length);
  912.     for (
  913.         M3n[84] = 0;
  914.         M3n[84] < M3n[0][0].m.cr.length;
  915.         M3n[84]++
  916.     ) {
  917.         M3n[1].writeUTF(M3n[0][0].m.cr[M3n[84]]);
  918.     }
  919.     M3n[1].writeUTF(M3n[0][0].m.mo);
  920.     M3n[1].writeInt(M3n[0][0].m.dbid);
  921.     M3n[1].writeBoolean(M3n[0][0].m.pub);
  922.     M3n[1].writeInt(M3n[0][0].m.dbv);
  923.     M3n[1].writeShort(M3n[9].ppm);
  924.     M3n[1].writeShort(M3n[9].bro.length);
  925.     for (M3n[17] = 0; M3n[17] < M3n[9].bro.length; M3n[17]++) {
  926.         M3n[1].writeShort(M3n[9].bro[M3n[17]]);
  927.     }
  928.     M3n[1].writeShort(M3n[9].shapes.length);
  929.     for (M3n[80] = 0; M3n[80] < M3n[9].shapes.length; M3n[80]++) {
  930.         M3n[2] = M3n[9].shapes[M3n[80]];
  931.         if (M3n[2].type == "bx") {
  932.         M3n[1].writeShort(1);
  933.         M3n[1].writeDouble(M3n[2].w);
  934.         M3n[1].writeDouble(M3n[2].h);
  935.         M3n[1].writeDouble(M3n[2].c[0]);
  936.         M3n[1].writeDouble(M3n[2].c[1]);
  937.         M3n[1].writeDouble(M3n[2].a);
  938.         M3n[1].writeBoolean(M3n[2].sk);
  939.         }
  940.         if (M3n[2].type == "ci") {
  941.         M3n[1].writeShort(2);
  942.         M3n[1].writeDouble(M3n[2].r);
  943.         M3n[1].writeDouble(M3n[2].c[0]);
  944.         M3n[1].writeDouble(M3n[2].c[1]);
  945.         M3n[1].writeBoolean(M3n[2].sk);
  946.         }
  947.         if (M3n[2].type == "po") {
  948.         M3n[1].writeShort(3);
  949.         M3n[1].writeDouble(M3n[2].s);
  950.         M3n[1].writeDouble(M3n[2].a);
  951.         M3n[1].writeDouble(M3n[2].c[0]);
  952.         M3n[1].writeDouble(M3n[2].c[1]);
  953.         M3n[1].writeShort(M3n[2].v.length);
  954.         for (M3n[61] = 0; M3n[61] < M3n[2].v.length; M3n[61]++) {
  955.             M3n[1].writeDouble(M3n[2].v[M3n[61]][0]);
  956.             M3n[1].writeDouble(M3n[2].v[M3n[61]][1]);
  957.         }
  958.         }
  959.     }
  960.     M3n[1].writeShort(M3n[9].fixtures.length);
  961.     for (M3n[20] = 0; M3n[20] < M3n[9].fixtures.length; M3n[20]++) {
  962.         M3n[7] = M3n[9].fixtures[M3n[20]];
  963.         M3n[1].writeShort(M3n[7].sh);
  964.         M3n[1].writeUTF(M3n[7].n);
  965.         if (M3n[7].fr === null) {
  966.         M3n[1].writeDouble(Number.MAX_VALUE);
  967.         } else {
  968.         M3n[1].writeDouble(M3n[7].fr);
  969.         }
  970.         if (M3n[7].fp === null) {
  971.         M3n[1].writeShort(0);
  972.         }
  973.         if (M3n[7].fp === false) {
  974.         M3n[1].writeShort(1);
  975.         }
  976.         if (M3n[7].fp === true) {
  977.         M3n[1].writeShort(2);
  978.         }
  979.         if (M3n[7].re === null) {
  980.         M3n[1].writeDouble(Number.MAX_VALUE);
  981.         } else {
  982.         M3n[1].writeDouble(M3n[7].re);
  983.         }
  984.         if (M3n[7].de === null) {
  985.         M3n[1].writeDouble(Number.MAX_VALUE);
  986.         } else {
  987.         M3n[1].writeDouble(M3n[7].de);
  988.         }
  989.         M3n[1].writeUint(M3n[7].f);
  990.         M3n[1].writeBoolean(M3n[7].d);
  991.         M3n[1].writeBoolean(M3n[7].np);
  992.         M3n[1].writeBoolean(M3n[7].ng);
  993.         M3n[1].writeBoolean(M3n[7].ig);
  994.     }
  995.     M3n[1].writeShort(M3n[9].bodies.length);
  996.     for (M3n[37] = 0; M3n[37] < M3n[9].bodies.length; M3n[37]++) {
  997.         M3n[4] = M3n[9].bodies[M3n[37]];
  998.         M3n[1].writeUTF(M3n[4].type);
  999.         M3n[1].writeUTF(M3n[4].n);
  1000.         M3n[1].writeDouble(M3n[4].p[0]);
  1001.         M3n[1].writeDouble(M3n[4].p[1]);
  1002.         M3n[1].writeDouble(M3n[4].a);
  1003.         M3n[1].writeDouble(M3n[4].fric);
  1004.         M3n[1].writeBoolean(M3n[4].fricp);
  1005.         M3n[1].writeDouble(M3n[4].re);
  1006.         M3n[1].writeDouble(M3n[4].de);
  1007.         M3n[1].writeDouble(M3n[4].lv[0]);
  1008.         M3n[1].writeDouble(M3n[4].lv[1]);
  1009.         M3n[1].writeDouble(M3n[4].av);
  1010.         M3n[1].writeDouble(M3n[4].ld);
  1011.         M3n[1].writeDouble(M3n[4].ad);
  1012.         M3n[1].writeBoolean(M3n[4].fr);
  1013.         M3n[1].writeBoolean(M3n[4].bu);
  1014.         M3n[1].writeDouble(M3n[4].cf.x);
  1015.         M3n[1].writeDouble(M3n[4].cf.y);
  1016.         M3n[1].writeDouble(M3n[4].cf.ct);
  1017.         M3n[1].writeBoolean(M3n[4].cf.w);
  1018.         M3n[1].writeShort(M3n[4].f_c);
  1019.         M3n[1].writeBoolean(M3n[4].f_1);
  1020.         M3n[1].writeBoolean(M3n[4].f_2);
  1021.         M3n[1].writeBoolean(M3n[4].f_3);
  1022.         M3n[1].writeBoolean(M3n[4].f_4);
  1023.         M3n[1].writeBoolean(M3n[4].f_p);
  1024.         M3n[1].writeBoolean(M3n[4].fz.on);
  1025.         if (M3n[4].fz.on) {
  1026.         M3n[1].writeDouble(M3n[4].fz.x);
  1027.         M3n[1].writeDouble(M3n[4].fz.y);
  1028.         M3n[1].writeBoolean(M3n[4].fz.d);
  1029.         M3n[1].writeBoolean(M3n[4].fz.p);
  1030.         M3n[1].writeBoolean(M3n[4].fz.a);
  1031.         M3n[1].writeShort(M3n[4].fz.t);
  1032. +       M3n[1].writeDouble(M3n[4].fz.cf);
  1033.         }
  1034.         M3n[1].writeShort(M3n[4].fx.length);
  1035.         for (M3n[28] = 0; M3n[28] < M3n[4].fx.length; M3n[28]++) {
  1036.         M3n[1].writeShort(M3n[4].fx[M3n[28]]);
  1037.         }
  1038.     }
  1039.     M3n[1].writeShort(M3n[0][0].spawns.length);
  1040.     for (
  1041.         M3n[30] = 0;
  1042.         M3n[30] < M3n[0][0].spawns.length;
  1043.         M3n[30]++
  1044.     ) {
  1045.         M3n[6] = M3n[0][0].spawns[M3n[30]];
  1046.         M3n[1].writeDouble(M3n[6].x);
  1047.         M3n[1].writeDouble(M3n[6].y);
  1048.         M3n[1].writeDouble(M3n[6].xv);
  1049.         M3n[1].writeDouble(M3n[6].yv);
  1050.         M3n[1].writeShort(M3n[6].priority);
  1051.         M3n[1].writeBoolean(M3n[6].r);
  1052.         M3n[1].writeBoolean(M3n[6].f);
  1053.         M3n[1].writeBoolean(M3n[6].b);
  1054.         M3n[1].writeBoolean(M3n[6].gr);
  1055.         M3n[1].writeBoolean(M3n[6].ye);
  1056.         M3n[1].writeUTF(M3n[6].n);
  1057.     }
  1058.     M3n[1].writeShort(M3n[0][0].capZones.length);
  1059.     for (
  1060.         M3n[74] = 0;
  1061.         M3n[74] < M3n[0][0].capZones.length;
  1062.         M3n[74]++
  1063.     ) {
  1064.         M3n[3] = M3n[0][0].capZones[M3n[74]];
  1065.         M3n[1].writeUTF(M3n[3].n);
  1066.         M3n[1].writeDouble(M3n[3].l);
  1067.         M3n[1].writeShort(M3n[3].i);
  1068.         M3n[1].writeShort(M3n[3].ty);
  1069.     }
  1070.     M3n[1].writeShort(M3n[9].joints.length);
  1071.     for (M3n[89] = 0; M3n[89] < M3n[9].joints.length; M3n[89]++) {
  1072.         M3n[5] = M3n[9].joints[M3n[89]];
  1073.         if (M3n[5].type == "rv") {
  1074.         M3n[1].writeShort(1);
  1075.         M3n[1].writeDouble(M3n[5].d.la);
  1076.         M3n[1].writeDouble(M3n[5].d.ua);
  1077.         M3n[1].writeDouble(M3n[5].d.mmt);
  1078.         M3n[1].writeDouble(M3n[5].d.ms);
  1079.         M3n[1].writeBoolean(M3n[5].d.el);
  1080.         M3n[1].writeBoolean(M3n[5].d.em);
  1081.         M3n[1].writeDouble(M3n[5].aa[0]);
  1082.         M3n[1].writeDouble(M3n[5].aa[1]);
  1083.         }
  1084.         if (M3n[5].type == "d") {
  1085.         M3n[1].writeShort(2);
  1086.         M3n[1].writeDouble(M3n[5].d.fh);
  1087.         M3n[1].writeDouble(M3n[5].d.dr);
  1088.         M3n[1].writeDouble(M3n[5].aa[0]);
  1089.         M3n[1].writeDouble(M3n[5].aa[1]);
  1090.         M3n[1].writeDouble(M3n[5].ab[0]);
  1091.         M3n[1].writeDouble(M3n[5].ab[1]);
  1092.         }
  1093.         if (M3n[5].type == "lpj") {
  1094.         M3n[1].writeShort(3);
  1095.         M3n[1].writeDouble(M3n[5].pax);
  1096.         M3n[1].writeDouble(M3n[5].pay);
  1097.         M3n[1].writeDouble(M3n[5].pa);
  1098.         M3n[1].writeDouble(M3n[5].pf);
  1099.         M3n[1].writeDouble(M3n[5].pl);
  1100.         M3n[1].writeDouble(M3n[5].pu);
  1101.         M3n[1].writeDouble(M3n[5].plen);
  1102.         M3n[1].writeDouble(M3n[5].pms);
  1103.         }
  1104.         if (M3n[5].type == "lsj") {
  1105.         M3n[1].writeShort(4);
  1106.         M3n[1].writeDouble(M3n[5].sax);
  1107.         M3n[1].writeDouble(M3n[5].say);
  1108.         M3n[1].writeDouble(M3n[5].sf);
  1109.         M3n[1].writeDouble(M3n[5].slen);
  1110.         }
  1111.         if(M3n[5].type == "g"){
  1112.             M3n[1].writeShort(5);
  1113.             M3n[1].writeUTF(M3n[5].n);
  1114.             M3n[1].writeShort(M3n[5].ja);
  1115.             M3n[1].writeShort(M3n[5].jb);
  1116.             M3n[1].writeDouble(M3n[5].r);
  1117.         }
  1118.         if(M3n[5].type != "g"){
  1119.             M3n[1].writeShort(M3n[5].ba);
  1120.             M3n[1].writeShort(M3n[5].bb);
  1121.             M3n[1].writeBoolean(M3n[5].d.cc);
  1122.             M3n[1].writeDouble(M3n[5].d.bf);
  1123.             M3n[1].writeBoolean(M3n[5].d.dl);
  1124.         }
  1125.     }
  1126.     M3n[32] = M3n[1].toBase64();
  1127.     M3n[77] = LZString.compressToEncodedURIComponent(M3n[32]);
  1128.     return M3n[77];
  1129. };
  1130. scope.decodeFromDatabase = function (map) {
  1131.     var F5W = [arguments];
  1132.     var b64mapdata = LZString.decompressFromEncodedURIComponent(map);
  1133.     var binaryReader = new bytebuffer2;
  1134.     binaryReader.fromBase64(b64mapdata, false);
  1135.     map = { v: 1, s: { re: false, nc: false, pq: 1, gd: 25, fl: false }, physics: { shapes: [], fixtures: [], bodies: [], bro: [], joints: [], ppm: 12, }, spawns: [], capZones: [], m: { a: "noauthor", n: "noname", dbv: 2, dbid: -1, authid: -1, date: "", rxid: 0, rxn: "", rxa: "", rxdb: 1, cr: [], pub: false, mo: "", }};
  1136.     map.physics = map.physics;
  1137.     map.v = binaryReader.readShort();
  1138.     if (map.v > 15) {
  1139.         throw new Error("Future map version, please refresh page");
  1140.     }
  1141.     map.s.re = binaryReader.readBoolean();
  1142.     map.s.nc = binaryReader.readBoolean();
  1143.     if (map.v >= 3) {
  1144.         map.s.pq = binaryReader.readShort();
  1145.     }
  1146.     if (map.v >= 4 && map.v <= 12) {
  1147.         map.s.gd = binaryReader.readShort();
  1148.     } else if (map.v >= 13) {
  1149.         map.s.gd = binaryReader.readFloat();
  1150.     }
  1151.     if (map.v >= 9) {
  1152.         map.s.fl = binaryReader.readBoolean();
  1153.     }
  1154.     map.m.rxn = binaryReader.readUTF();
  1155.     map.m.rxa = binaryReader.readUTF();
  1156.     map.m.rxid = binaryReader.readUint();
  1157.     map.m.rxdb = binaryReader.readShort();
  1158.     map.m.n = binaryReader.readUTF();
  1159.     map.m.a = binaryReader.readUTF();
  1160.     if (map.v >= 10) {
  1161.         map.m.vu = binaryReader.readUint();
  1162.         map.m.vd = binaryReader.readUint();
  1163.     }
  1164.     if (map.v >= 4) {
  1165.         F5W[7] = binaryReader.readShort();
  1166.         for (F5W[83] = 0; F5W[83] < F5W[7]; F5W[83]++) {
  1167.         map.m.cr.push(binaryReader.readUTF());
  1168.         }
  1169.     }
  1170.     if (map.v >= 5) {
  1171.         map.m.mo = binaryReader.readUTF();
  1172.         map.m.dbid = binaryReader.readInt();
  1173.     }
  1174.     if (map.v >= 7) {
  1175.         map.m.pub = binaryReader.readBoolean();
  1176.     }
  1177.     if (map.v >= 8) {
  1178.         map.m.dbv = binaryReader.readInt();
  1179.     }
  1180.     map.physics.ppm = binaryReader.readShort();
  1181.     F5W[4] = binaryReader.readShort();
  1182.     for (F5W[15] = 0; F5W[15] < F5W[4]; F5W[15]++) {
  1183.         map.physics.bro[F5W[15]] = binaryReader.readShort();
  1184.     }
  1185.     F5W[6] = binaryReader.readShort();
  1186.     for (F5W[28] = 0; F5W[28] < F5W[6]; F5W[28]++) {
  1187.         F5W[5] = binaryReader.readShort();
  1188.         if (F5W[5] == 1) {
  1189.         map.physics.shapes[F5W[28]] = { type: "bx", w: 10, h: 40, c: [0, 0], a: 0.0, sk: false };
  1190.         map.physics.shapes[F5W[28]].w = binaryReader.readDouble();
  1191.         map.physics.shapes[F5W[28]].h = binaryReader.readDouble();
  1192.         map.physics.shapes[F5W[28]].c = [
  1193.             binaryReader.readDouble(),
  1194.             binaryReader.readDouble(),
  1195.         ];
  1196.         map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
  1197.         map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
  1198.         }
  1199.         if (F5W[5] == 2) {
  1200.         map.physics.shapes[F5W[28]] = { type: "ci", r: 25, c: [0, 0], sk: false };
  1201.         map.physics.shapes[F5W[28]].r = binaryReader.readDouble();
  1202.         map.physics.shapes[F5W[28]].c = [
  1203.             binaryReader.readDouble(),
  1204.             binaryReader.readDouble(),
  1205.         ];
  1206.         map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
  1207.         }
  1208.         if (F5W[5] == 3) {
  1209.         map.physics.shapes[F5W[28]] = { type: "po", v: [], s: 1, a: 0, c: [0, 0] };
  1210.         map.physics.shapes[F5W[28]].s = binaryReader.readDouble();
  1211.         map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
  1212.         map.physics.shapes[F5W[28]].c = [
  1213.             binaryReader.readDouble(),
  1214.             binaryReader.readDouble(),
  1215.         ];
  1216.         F5W[74] = binaryReader.readShort();
  1217.         map.physics.shapes[F5W[28]].v = [];
  1218.         for (F5W[27] = 0; F5W[27] < F5W[74]; F5W[27]++) {
  1219.             map.physics.shapes[F5W[28]].v.push([
  1220.             binaryReader.readDouble(),
  1221.             binaryReader.readDouble(),
  1222.             ]);
  1223.         }
  1224.         }
  1225.     }
  1226.     F5W[71] = binaryReader.readShort();
  1227.     for (F5W[17] = 0; F5W[17] < F5W[71]; F5W[17]++) {
  1228.         map.physics.fixtures[F5W[17]] = { sh: 0, n: "Def Fix", fr: 0.3, fp: null, re: 0.8, de: 0.3, f: 0x4f7cac, d: false, np: false, ng: false };
  1229.         map.physics.fixtures[F5W[17]].sh = binaryReader.readShort();
  1230.         map.physics.fixtures[F5W[17]].n = binaryReader.readUTF();
  1231.         map.physics.fixtures[F5W[17]].fr = binaryReader.readDouble();
  1232.         if (map.physics.fixtures[F5W[17]].fr == Number.MAX_VALUE) {
  1233.         map.physics.fixtures[F5W[17]].fr = null;
  1234.         }
  1235.         F5W[12] = binaryReader.readShort();
  1236.         if (F5W[12] == 0) {
  1237.         map.physics.fixtures[F5W[17]].fp = null;
  1238.         }
  1239.         if (F5W[12] == 1) {
  1240.         map.physics.fixtures[F5W[17]].fp = false;
  1241.         }
  1242.         if (F5W[12] == 2) {
  1243.         map.physics.fixtures[F5W[17]].fp = true;
  1244.         }
  1245.         map.physics.fixtures[F5W[17]].re = binaryReader.readDouble();
  1246.         if (map.physics.fixtures[F5W[17]].re == Number.MAX_VALUE) {
  1247.         map.physics.fixtures[F5W[17]].re = null;
  1248.         }
  1249.         map.physics.fixtures[F5W[17]].de = binaryReader.readDouble();
  1250.         if (map.physics.fixtures[F5W[17]].de == Number.MAX_VALUE) {
  1251.         map.physics.fixtures[F5W[17]].de = null;
  1252.         }
  1253.         map.physics.fixtures[F5W[17]].f = binaryReader.readUint();
  1254.         map.physics.fixtures[F5W[17]].d = binaryReader.readBoolean();
  1255.         map.physics.fixtures[F5W[17]].np = binaryReader.readBoolean();
  1256.         if (map.v >= 11) {
  1257.         map.physics.fixtures[F5W[17]].ng = binaryReader.readBoolean();
  1258.         }
  1259.         if (map.v >= 12) {
  1260.         map.physics.fixtures[F5W[17]].ig = binaryReader.readBoolean();
  1261.         }
  1262.     }
  1263.     F5W[63] = binaryReader.readShort();
  1264.     for (F5W[52] = 0; F5W[52] < F5W[63]; F5W[52]++) {
  1265.         map.physics.bodies[F5W[52]] ={ type: "s", n: "Unnamed", p: [0, 0], a: 0, fric: 0.3, fricp: false, re: 0.8, de: 0.3, lv: [0, 0], av: 0, ld: 0, ad: 0, fr: false, bu: false, cf: { x: 0, y: 0, w: true, ct: 0 }, fx: [], f_c: 1, f_p: true, f_1: true, f_2: true, f_3: true, f_4: true, fz: { on: false, x: 0, y: 0, d: true, p: true, a: true, t: 0, cf: 0}};
  1266.         map.physics.bodies[F5W[52]].type = binaryReader.readUTF();
  1267.         map.physics.bodies[F5W[52]].n = binaryReader.readUTF();
  1268.         map.physics.bodies[F5W[52]].p = [binaryReader.readDouble(), binaryReader.readDouble()];
  1269.         map.physics.bodies[F5W[52]].a = binaryReader.readDouble();
  1270.         map.physics.bodies[F5W[52]].fric = binaryReader.readDouble();
  1271.         map.physics.bodies[F5W[52]].fricp = binaryReader.readBoolean();
  1272.         map.physics.bodies[F5W[52]].re = binaryReader.readDouble();
  1273.         map.physics.bodies[F5W[52]].de = binaryReader.readDouble();
  1274.         map.physics.bodies[F5W[52]].lv = [
  1275.         binaryReader.readDouble(),
  1276.         binaryReader.readDouble(),
  1277.         ];
  1278.         map.physics.bodies[F5W[52]].av = binaryReader.readDouble();
  1279.         map.physics.bodies[F5W[52]].ld = binaryReader.readDouble();
  1280.         map.physics.bodies[F5W[52]].ad = binaryReader.readDouble();
  1281.         map.physics.bodies[F5W[52]].fr = binaryReader.readBoolean();
  1282.         map.physics.bodies[F5W[52]].bu = binaryReader.readBoolean();
  1283.         map.physics.bodies[F5W[52]].cf.x = binaryReader.readDouble();
  1284.         map.physics.bodies[F5W[52]].cf.y = binaryReader.readDouble();
  1285.         map.physics.bodies[F5W[52]].cf.ct = binaryReader.readDouble();
  1286.         map.physics.bodies[F5W[52]].cf.w = binaryReader.readBoolean();
  1287.         map.physics.bodies[F5W[52]].f_c = binaryReader.readShort();
  1288.         map.physics.bodies[F5W[52]].f_1 = binaryReader.readBoolean();
  1289.         map.physics.bodies[F5W[52]].f_2 = binaryReader.readBoolean();
  1290.         map.physics.bodies[F5W[52]].f_3 = binaryReader.readBoolean();
  1291.         map.physics.bodies[F5W[52]].f_4 = binaryReader.readBoolean();
  1292.         if (map.v >= 2) {
  1293.         map.physics.bodies[F5W[52]].f_p = binaryReader.readBoolean();
  1294.         }
  1295.         if (map.v >= 14) {
  1296.         map.physics.bodies[F5W[52]].fz.on = binaryReader.readBoolean();
  1297.         if (map.physics.bodies[F5W[52]].fz.on) {
  1298.             map.physics.bodies[F5W[52]].fz.x = binaryReader.readDouble();
  1299.             map.physics.bodies[F5W[52]].fz.y = binaryReader.readDouble();
  1300.             map.physics.bodies[F5W[52]].fz.d = binaryReader.readBoolean();
  1301.             map.physics.bodies[F5W[52]].fz.p = binaryReader.readBoolean();
  1302.             map.physics.bodies[F5W[52]].fz.a = binaryReader.readBoolean();
  1303.             if(map.v >= 15){
  1304.                 map.physics.bodies[F5W[52]].t = binaryReader.readShort();
  1305.                 map.physics.bodies[F5W[52]].cf = binaryReader.readDouble();
  1306.             }
  1307.         }
  1308.         }
  1309.         F5W[88] = binaryReader.readShort();
  1310.         for (F5W[65] = 0; F5W[65] < F5W[88]; F5W[65]++) {
  1311.         map.physics.bodies[F5W[52]].fx.push(binaryReader.readShort());
  1312.         }
  1313.     }
  1314.     F5W[97] = binaryReader.readShort();
  1315.     for (F5W[41] = 0; F5W[41] < F5W[97]; F5W[41]++) {
  1316.         map.spawns[F5W[41]] = {"x":400,"y":300,"xv":0,"yv":0,"priority":5,"r":true,"f":true,"b":true,"gr":false,"ye":false,"n":"Spawn"};
  1317.         F5W[35] = map.spawns[F5W[41]];
  1318.         F5W[35].x = binaryReader.readDouble();
  1319.         F5W[35].y = binaryReader.readDouble();
  1320.         F5W[35].xv = binaryReader.readDouble();
  1321.         F5W[35].yv = binaryReader.readDouble();
  1322.         F5W[35].priority = binaryReader.readShort();
  1323.         F5W[35].r = binaryReader.readBoolean();
  1324.         F5W[35].f = binaryReader.readBoolean();
  1325.         F5W[35].b = binaryReader.readBoolean();
  1326.         F5W[35].gr = binaryReader.readBoolean();
  1327.         F5W[35].ye = binaryReader.readBoolean();
  1328.         F5W[35].n = binaryReader.readUTF();
  1329.     }
  1330.     F5W[16] = binaryReader.readShort();
  1331.     for (F5W[25] = 0; F5W[25] < F5W[16]; F5W[25]++) {
  1332.         map.capZones[F5W[25]] = {"n":"Cap Zone","ty":1,"l":10,"i":-1};
  1333.         map.capZones[F5W[25]].n = binaryReader.readUTF();
  1334.         map.capZones[F5W[25]].l = binaryReader.readDouble();
  1335.         map.capZones[F5W[25]].i = binaryReader.readShort();
  1336.         if (map.v >= 6) {
  1337.         map.capZones[F5W[25]].ty = binaryReader.readShort();
  1338.         }
  1339.     }
  1340.     F5W[98] = binaryReader.readShort();
  1341.     for (F5W[19] = 0; F5W[19] < F5W[98]; F5W[19]++) {
  1342.         F5W[31] = binaryReader.readShort();
  1343.         if (F5W[31] == 1) {
  1344.         map.physics.joints[F5W[19]] =  {"type":"rv","d":{"la":0,"ua":0,"mmt":0,"ms":0,"el":false,"em":false,"cc":false,"bf":0,"dl":true},"aa":[0,0]};
  1345.         F5W[20] = map.physics.joints[F5W[19]];
  1346.         F5W[20].d.la = binaryReader.readDouble();
  1347.         F5W[20].d.ua = binaryReader.readDouble();
  1348.         F5W[20].d.mmt = binaryReader.readDouble();
  1349.         F5W[20].d.ms = binaryReader.readDouble();
  1350.         F5W[20].d.el = binaryReader.readBoolean();
  1351.         F5W[20].d.em = binaryReader.readBoolean();
  1352.         F5W[20].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1353.         }
  1354.         if (F5W[31] == 2) {
  1355.         map.physics.joints[F5W[19]] = {"type":"d","d":{"fh":0,"dr":0,"cc":false,"bf":0,"dl":true},"aa":[0,0],"ab":[0,0]};
  1356.         F5W[87] = map.physics.joints[F5W[19]];
  1357.         F5W[87].d.fh = binaryReader.readDouble();
  1358.         F5W[87].d.dr = binaryReader.readDouble();
  1359.         F5W[87].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1360.         F5W[87].ab = [binaryReader.readDouble(), binaryReader.readDouble()];
  1361.         }
  1362.         if (F5W[31] == 3) {
  1363.         map.physics.joints[F5W[19]] = {"type":"lpj","d":{"cc":false,"bf":0,"dl":true},"pax":0,"pay":0,"pa":0,"pf":0,"pl":0,"pu":0,"plen":0,"pms":0};
  1364.         F5W[90] = map.physics.joints[F5W[19]];
  1365.         F5W[90].pax = binaryReader.readDouble();
  1366.         F5W[90].pay = binaryReader.readDouble();
  1367.         F5W[90].pa = binaryReader.readDouble();
  1368.         F5W[90].pf = binaryReader.readDouble();
  1369.         F5W[90].pl = binaryReader.readDouble();
  1370.         F5W[90].pu = binaryReader.readDouble();
  1371.         F5W[90].plen = binaryReader.readDouble();
  1372.         F5W[90].pms = binaryReader.readDouble();
  1373.         }
  1374.         if (F5W[31] == 4) {
  1375.         map.physics.joints[F5W[19]] = {"type":"lsj","d":{"cc":false,"bf":0,"dl":true},"sax":0,"say":0,"sf":0,"slen":0};
  1376.         F5W[44] = map.physics.joints[F5W[19]];
  1377.         F5W[44].sax = binaryReader.readDouble();
  1378.         F5W[44].say = binaryReader.readDouble();
  1379.         F5W[44].sf = binaryReader.readDouble();
  1380.         F5W[44].slen = binaryReader.readDouble();
  1381.         }
  1382.         if(F5W[31] == 5){
  1383.             map.physics.joints[F5W[19]] = {type:"g",n:"",ja:-1,jb:-1,r:1};
  1384.             F5W[91] = map.physics.joints[F5W[19]];
  1385.             F5W[91].n = binaryReader.readUTF();
  1386.             F5W[91].ja = binaryReader.readShort();
  1387.             F5W[91].jb = binaryReader.readShort();
  1388.             F5W[91].r = binaryReader.readDouble();
  1389.  
  1390.         }
  1391.         if(F5W[31]!=5){
  1392.             map.physics.joints[F5W[19]].ba = binaryReader.readShort();
  1393.             map.physics.joints[F5W[19]].bb = binaryReader.readShort();
  1394.             map.physics.joints[F5W[19]].d.cc = binaryReader.readBoolean();
  1395.             map.physics.joints[F5W[19]].d.bf = binaryReader.readDouble();
  1396.             map.physics.joints[F5W[19]].d.dl = binaryReader.readBoolean();
  1397.         }
  1398.        
  1399.     }
  1400.     return map;
  1401.     };
  1402.    
  1403. scope.updateWssLog = function(){
  1404.     if(!wsslogpaused){
  1405.         if(logmenutable.children.length < wsssendrecievelog.length){
  1406.             var bottomscroll = logmenutable.clientHeight + logmenutable.scrollTop >= logmenutable.scrollHeight-1;
  1407.             while (logmenutable.children.length>1000) {
  1408.                 logmenutable.removeChild(logmenutable.firstChild);
  1409.                 logmenutable2.removeChild(logmenutable2.firstChild);
  1410.             }
  1411.             var loopthro = wsssendrecievelog.slice(packetcount);
  1412.             for(var i = 0; i < loopthro.length;i++){
  1413.                 packetcount++;
  1414.                 var row = document.createElement("tr");
  1415.                 var row2 = document.createElement("tr");
  1416.  
  1417.                 var cell1 = document.createElement("td");
  1418.                 cell1.style["overflow-x"] = "scroll";
  1419.                 cell1.style["padding"] = "0px";
  1420.                 cell1.style["width"] = "100000px";
  1421.  
  1422.                 var cell2 = document.createElement("td");
  1423.                 cell2.style["overflow-x"] = "scroll";
  1424.                 cell2.style["padding"] = "0px";
  1425.                 cell2.style["width"] = "100000px";
  1426.                
  1427.                 if(debuggercount){
  1428.                     cell1.style["background"] = "rgb(178, 185, 189)";
  1429.                     debuggercount = false;
  1430.                 }
  1431.                 else{
  1432.                     cell2.style["background"] = "rgb(178, 185, 189)";
  1433.                     debuggercount = true;
  1434.                 }
  1435.                 cell1.textContent = loopthro[i][1];
  1436.                 cell2.textContent = loopthro[i][1];
  1437.                 if(loopthro[i][0] == 0){
  1438.                     cell2.style["color"] = "transparent";
  1439.                     cell1.onclick = function(){debuggerinput.value = this.textContent};
  1440.                 }
  1441.                 else{
  1442.                     cell1.style["color"] = "transparent";
  1443.                     cell2.onclick = function(){debuggerinput.value = this.textContent};
  1444.                 }
  1445.                 row.appendChild(cell1);
  1446.                 row2.appendChild(cell2);
  1447.                 logmenutable.appendChild(row);
  1448.                 logmenutable2.appendChild(row2);
  1449.             }
  1450.             while (logmenutable.children.length>1000) {
  1451.                 logmenutable.removeChild(logmenutable.firstChild);
  1452.                 logmenutable2.removeChild(logmenutable2.firstChild);
  1453.             }
  1454.             if(bottomscroll){
  1455.                 logmenutable.scrollTop = logmenutable.scrollHeight;
  1456.                 logmenutable2.scrollTop = logmenutable.scrollHeight;
  1457.             }
  1458.         }
  1459.     }
  1460. };
  1461. Gdocument.getElementById("maploadwindowmapscontainer").appendChild = function(args){
  1462.  
  1463.     var checkbox = Gdocument.createElement("input");
  1464.     checkbox.type = "checkbox";
  1465.     checkbox.style["position"]="absolute";
  1466.     checkbox.style["margin-top"] = "135px";
  1467.     checkbox.style["margin-left"] = "140px";
  1468.     checkbox.style["scale"] = "2";
  1469.     checkbox.style["display"] = "none";
  1470.     checkbox.className = "quickplaycheckbox quickplayunchecked";
  1471.     if(ishost && stopquickplay==0){
  1472.         checkbox.style["display"] = "block";
  1473.         checkbox.className = "quickplaycheckbox quickplaychecked";
  1474.     }
  1475.     checkbox.checked = true;
  1476.     checkbox.onclick = function(e){e.stopPropagation();};
  1477.     args.appendChild(checkbox);
  1478.     originalMapLoad.call(this,args);
  1479. };
  1480. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  1481.     if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1482.         if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  1483.             var kickedorbanned = "banned";
  1484.             if(onlykicked){
  1485.                 kickedorbanned = "kicked";
  1486.             }
  1487.             args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game ";
  1488.         }
  1489.     }
  1490.     setTimeout(function(){
  1491.     if(args.textContent.startsWith("* ") && args.children.length>=5){
  1492.         var newarg = args.cloneNode();
  1493.         for(var i = 0;i<args.children.length;i++){
  1494.             var newarg2 = args.children[i].cloneNode();
  1495.             newarg2.textContent = args.children[i].textContent;
  1496.             newarg2.style.color = '#ffffffd6';
  1497.             newarg2.onclick = args.children[i].onclick;
  1498.             newarg2.suggestID = args.children[i].suggestID;
  1499.             newarg.appendChild(newarg2);
  1500.         }
  1501.         Gdocument.getElementById("ingamechatcontent").appendChild(newarg);
  1502.         Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  1503.     }},0);
  1504.     originalLobbyChat.call(this,args);
  1505. };
  1506. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  1507.     if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1508.         if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  1509.             var kickedorbanned = "banned";
  1510.             if(onlykicked){
  1511.                 kickedorbanned = "kicked";
  1512.             }
  1513.             args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game.";
  1514.         }
  1515.     }
  1516.     if(recordedTimeStamp+100>Date.now() && args.children.length>0){
  1517.         if(args.children[0].textContent.includes("seconds") && args.children[0].textContent.startsWith("* ")){
  1518.             args.children[0].textContent = args.children[0].textContent + " - " + playerids[recordedId].userName;
  1519.         }
  1520.     }
  1521.     originalIngameChat.call(this,args);
  1522. };  
  1523. Gwindow.Date.now = function(){
  1524.     if(overideDate[0]){
  1525.         return overideDate[1];
  1526.     }
  1527.     else if(causelag){
  1528.         return originalDatenow.call(this,...arguments)-causelag2;
  1529.     }
  1530.     return originalDatenow.call(this,...arguments);
  1531. };
  1532. Gwindow.XMLHttpRequest.prototype.open = function(_, url) {
  1533.     if (url.includes("scripts/map_get") || url.includes("scripts/map_b1_get") || url.includes("scripts/hotmaps/")) {
  1534.         if(searchrequested==1){
  1535.             Gdocument.getElementById("maploadtypedropdowntitle").click();
  1536.             Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  1537.             dropdownrequested.style["display"] = "none";
  1538.             clearmaprequests.style["display"] = "block";
  1539.             refreshmaprequests.style["display"] = "block";
  1540.             Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  1541.             Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  1542.             searchrequested = 0;
  1543.             this.isSearchMap = true;
  1544.         }
  1545.     }
  1546.     else if(url.includes("getrooms.php")){
  1547.         this.isGetRooms = true;
  1548.     }
  1549.     else if(url.includes("getroomaddress.php")){
  1550.         this.isGetRoomAddress = true;
  1551.     }
  1552.     originalXMLOpen.call(this, ...arguments);
  1553. };
  1554.    
  1555. Gwindow.XMLHttpRequest.prototype.send = function(data) {
  1556.     if(this.isGetRoomAddress){
  1557.         currentroomaddress = parseInt(data.slice(3));
  1558.     }
  1559.     else if(this.isGetRooms && inroom){
  1560.         this.onreadystatechange = function(){
  1561.             if(this.readyState == 4){
  1562.                 lastrooms = JSON.parse(this.response)["rooms"];
  1563.                 if(lastrooms){
  1564.                     var keys = Object.keys(savedroomsdata);
  1565.                     for(var i = 0;i<lastrooms.length;i++){
  1566.                         if(savedrooms.includes(lastrooms[i].id)){
  1567.                             exists = true;
  1568.                             savedroomsdata[lastrooms[i].id] = lastrooms[i];
  1569.                             savedroomsdata[lastrooms[i].id].exists = true;
  1570.                             savedroomsdata[lastrooms[i].id].exists2 = true;
  1571.                             if(lastrooms[i].maxplayers>lastrooms[i].players){
  1572.                                 if(inroom){
  1573.                                     if(lastrooms[i].id!=currentroomaddress){
  1574.                                         displayInChat('The room '+JSON.stringify(lastrooms[i].roomname)+' is now open with '+lastrooms[i].players+"/"+lastrooms[i].maxplayers+" players.","#DA0808","#1EBCC1");
  1575.                                         savedrooms.splice(savedrooms.indexOf(lastrooms[i].id),1);
  1576.                                         delete savedroomsdata[lastrooms[i].id];
  1577.                                         keys.splice(keys.indexOf((lastrooms[i].id).toString()),1);
  1578.                                     }
  1579.                                     else{
  1580.                                         savedrooms.splice(savedrooms.indexOf(lastrooms[i].id),1);
  1581.                                         delete savedroomsdata[lastrooms[i].id];
  1582.                                         keys.splice(keys.indexOf((lastrooms[i].id).toString()),1);
  1583.                                     }
  1584.                                 }
  1585.                             }
  1586.                         }
  1587.                     }
  1588.                     for(var i = 0;i<keys.length;i++){
  1589.                         if(!savedroomsdata[keys[i]].exists2){
  1590.                             savedroomsdata[keys[i]].exists = false;
  1591.                         }
  1592.                         savedroomsdata[keys[i]].exists2 = false;
  1593.                        
  1594.                     }
  1595.                     for(var i = 0;i<keys.length;i++){
  1596.                         if(!savedroomsdata[keys[i]].exists){
  1597.                             savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])),1);
  1598.                             displayInChat('The room '+JSON.stringify(savedroomsdata[keys[i]].roomname)+" does not exist anymore.","#DA0808","#1EBCC1");
  1599.                             delete savedroomsdata[keys[i]];
  1600.                         }
  1601.                     }
  1602.                 }
  1603.             }
  1604.         }
  1605.     }
  1606.     else if (this.isSearchMap) {
  1607.         this.onreadystatechange = function () {
  1608.             if (this.readyState == 4){
  1609.                
  1610.                 var jsonargs = {r:"success",maps:[],more:true};
  1611.                
  1612.                 for(var i = 0; i<requestedmaps.length; i++){
  1613.                     var dec = requestedmaps[i][0];
  1614.                     var undec = requestedmaps[i][1];
  1615.                     var map = {};
  1616.                     map.id = dec["m"]["dbid"];
  1617.                     map.name = dec["m"]["n"];
  1618.                     map.authorname = dec["m"]["a"];
  1619.                     map.leveldata = undec;
  1620.                     map.publisheddate = dec["m"]["date"];
  1621.                     map.remixauthor = dec["m"]["rxa"];
  1622.                     map.remixdb = dec["m"]["rxdb"];
  1623.                     map.remixid = dec["m"]["rxid"];
  1624.                     map.remixname = dec["m"]["rxn"];
  1625.                     map.vd = dec["m"]["vd"];
  1626.                     map.vu = dec["m"]["vu"];
  1627.                     jsonargs.maps.push(map);
  1628.                        
  1629.                 }
  1630.                 jsonargs2 = JSON.stringify(jsonargs);
  1631.                 function stringifyjsonargs(){
  1632.                     return jsonargs2;
  1633.                 }
  1634.                 this.__defineGetter__("responseText", stringifyjsonargs);
  1635.                 this.__defineGetter__("response", stringifyjsonargs);
  1636.                
  1637.                
  1638.             }
  1639.         }
  1640.     }
  1641.     originalXMLSend.call(this, ...arguments);
  1642. };
  1643. scope.STB = function(x){
  1644.     if(x == "0"){
  1645.         return 0;
  1646.     }
  1647.     else{
  1648.         return 1;
  1649.     }
  1650. };
  1651. scope.BTS = function(x){
  1652.     if(x == 0){
  1653.         return "0";
  1654.     }
  1655.     else{
  1656.         return "1";
  1657.     }
  1658. };
  1659. scope.GET_KEYS = function(x){
  1660.     var x2 = ((x+64)>>>0).toString(2).substring(1).split("");
  1661.     return {"left":STB(x2[5]),"right":STB(x2[4]),"up":STB(x2[3]),"down":STB(x2[2]),"heavy":STB(x2[1]),"special":STB(x2[0])}
  1662. };
  1663. scope.MAKE_KEYS = function(x){
  1664.     return x.special*32+x.heavy*16+x.down*8+x.up*4+x.right*2+x.left
  1665. };
  1666.  
  1667. Gwindow.PIXI.Graphics.prototype.drawCircle = function(...args){
  1668.    
  1669.     var This = this;
  1670.     var Args = [...args];
  1671.     setTimeout(function(){
  1672.         if(This.parent){
  1673.             var childs = This.parent.children;
  1674.             var user = 0;
  1675.             for(var i = 0;i<childs.length;i++){
  1676.                 if(childs[i]._text){
  1677.                     user = childs[i]._text;
  1678.                 }
  1679.                 if(i==2 && childs[i]!=This){
  1680.                     return;
  1681.                 }
  1682.             }
  1683.             var keys = Object.keys(playerids);
  1684.             for(var i = 0;i<keys.length;i++){
  1685.                 if(playerids[keys[i]].userName == user){
  1686.                     playerids[keys[i]].playerData = This.parent;
  1687.                     if(!playerids[keys[i]].playerData2){
  1688.                         playerids[keys[i]].playerData2 = {alive:true,radius:12,timeStamp:0,timeStamp2:0,px:0,py:0,pvx:0,pvy:0,xacc:0,yacc:0,xvel:0,yvel:0,balance:0};
  1689.                     }
  1690.                     playerids[keys[i]].playerData2.radius = Args[2];
  1691.                     parentDraw = This.parent;
  1692.                     while(parentDraw.parent){
  1693.                         parentDraw = parentDraw.parent;
  1694.                     }
  1695.                 }
  1696.             }
  1697.         }
  1698.     },0);
  1699.     return originalDrawCircle.call(this,...args);
  1700. };    
  1701.    
  1702. Gwindow.requestAnimationFrame = function(...args){
  1703.     if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1704.         while(parentDraw.parent){
  1705.             parentDraw = parentDraw.parent;
  1706.         }
  1707.         var canv = 0;
  1708.         for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  1709.             if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  1710.                 canv = Gdocument.getElementById("gamerenderer").children[i];
  1711.                 break;
  1712.             }
  1713.         }
  1714.         var width = parseInt(canv.style["width"]);
  1715.         var height = parseInt(canv.style["height"]);
  1716.         scale = (parseInt(canv.style["width"])/730);
  1717.         var now = Date.now();
  1718.         var keys = Object.keys(playerids);
  1719.         addto = {"children":[]};
  1720.         for(var i = 0;i<parentDraw.children.length;i++){
  1721.             if(parentDraw.children[i].constructor.name == "e"){
  1722.                 addto = parentDraw.children[i];
  1723.                 break;
  1724.             }
  1725.         }
  1726.         if(pan_enabled && Gdocument.getElementById("gamerenderer")?.childElementCount>0 && (keys_being_held["ShiftLeft"] || keys_being_held["ShiftRight"])){
  1727.             var temp_zoom = zoom;
  1728.             if(keys_being_held["ArrowUp"]){
  1729.                 pan.y+=pan_speed/temp_zoom;
  1730.             }
  1731.             if(keys_being_held["ArrowDown"]){
  1732.                 pan.y-=pan_speed/temp_zoom;
  1733.             }
  1734.             if(keys_being_held["ArrowRight"]){
  1735.                 pan.x-=pan_speed/temp_zoom;
  1736.             }
  1737.             if(keys_being_held["ArrowLeft"]){
  1738.                 pan.x+=pan_speed/temp_zoom;
  1739.             }
  1740.         }
  1741.         var panx = 0;
  1742.         var pany = 0;
  1743.         if(pan){
  1744.             panx = pan.x;
  1745.             pany = pan.y;
  1746.         }
  1747.         if(autocam){
  1748.             var autocamx = 365*scale;
  1749.             var autocamy = 250*scale;
  1750.             if(FollowCam && playerids[myid].playerData?.transform){
  1751.                 autocamx =  playerids[myid].playerData.transform.position.x;
  1752.                 autocamy =  playerids[myid].playerData.transform.position.y;
  1753.             }
  1754.             var distances = {};
  1755.             for(var i = 0;i<keys.length;i++){
  1756.                 if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2){
  1757.                     if(playerids[keys[i]].playerData.transform){
  1758.                         var ypos = playerids[keys[i]].playerData.transform.position.y;
  1759.                         if(ypos>460*scale && ypos< 500 * scale){
  1760.                             ypos = scale * 460;
  1761.                         }
  1762.                         distances[keys[i]] = [playerids[keys[i]].playerData.transform.position.x-autocamx,ypos-autocamy];
  1763.                     }
  1764.                 }
  1765.             }
  1766.        
  1767.             distances["topleft"] = [autocamx-40,autocamy-40];
  1768.             distances["topright"] = [690*scale-autocamx,autocamy-40];
  1769.             distances["bottomleft"] = [autocamx-40,460*scale-autocamy];
  1770.             distances["bottomright"] = [690*scale-autocamx,460*scale-autocamy];
  1771.             var lowestD = [-1,-1];
  1772.             var keys2 = Object.keys(distances);
  1773.             for(var i = 0;i<keys2.length;i++){
  1774.                
  1775.                 if(Math.abs(distances[keys2[i]][0]/scale)>lowestD[0]){
  1776.                     lowestD[0] = Math.abs(distances[keys2[i]][0]/scale);
  1777.                 }
  1778.                 if(Math.abs(distances[keys2[i]][1]/scale)>lowestD[1]){
  1779.                     lowestD[1] = Math.abs(distances[keys2[i]][1]/scale);
  1780.                 }
  1781.            
  1782.             }
  1783.            
  1784.             var horizontal = (lowestD[0])/345;
  1785.             var vertical = (lowestD[1])/230;
  1786.             newzoom = Math.min(Math.abs(1/Math.max(horizontal,vertical)),1);
  1787.            
  1788.         }
  1789.         else{
  1790.             newzoom = 1;
  1791.         }
  1792.  
  1793.         newzoom2 = newzoom2 + 0.15*(newzoom-newzoom2);
  1794.         zoom2 = zoom2 + 0.15*(zoom-zoom2);
  1795.         addto.scale.x = newzoom2 * zoom2;
  1796.         addto.scale.y = newzoom2 * zoom2;
  1797.  
  1798.        
  1799.         if(holdheavy>0){
  1800.             if(holdheavy==1){
  1801.                 holdheavy = -1;
  1802.             }
  1803.             else{
  1804.                 holdheavy-=1;
  1805.             }
  1806.         }
  1807.         if(playerids[myid].playerData?.children){
  1808.             for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1809.                 if(playerids[myid].playerData.children[i].alpha!=1){
  1810.                     heavyid = i;
  1811.                 }
  1812.                 if(playerids[myid].playerData.children[i].vertextData){
  1813.                     if(playerids[myid].playerData.children[i].vertextData.length == 0){
  1814.                         specialid = i;  
  1815.                     }
  1816.                 }
  1817.             }
  1818.         }
  1819.         for(var i = 0;i<keys.length;i++){
  1820.             if(allstyles[playerids[keys[i]].userName]){
  1821.                 var isadmin = [false,0];
  1822.                 for(var i3 = 0;i3<admins.length;i3++){
  1823.                     if(admins[i3][0] == playerids[keys[i]].userName && !playerids[keys[i].guest]){
  1824.                         isadmin = [true,i3];
  1825.                         break;
  1826.                     }
  1827.                 }
  1828.                
  1829.                 if(playerids[keys[i]].playerData?.children){
  1830.                         for(var i2 = 0;i2<playerids[keys[i]].playerData.children.length;i2++){
  1831.                            
  1832.                             if(playerids[keys[i]].playerData.children[i2].text){
  1833.                                 if(allstyles[playerids[keys[i]].userName][0]==0 && allstyles[playerids[keys[i]].userName][1]==0 && allstyles[playerids[keys[i]].userName][2]==0){
  1834.                                     playerids[keys[i]].playerData.children[i2].tint = 255*256**3-1;
  1835.                                 }
  1836.                                 else{
  1837.                                     playerids[keys[i]].playerData.children[i2].tint = allstyles[playerids[keys[i]].userName][0]*256**2 + allstyles[playerids[keys[i]].userName][1]*256 + allstyles[playerids[keys[i]].userName][2];
  1838.                                 }
  1839.                             }
  1840.                         }
  1841.                     }
  1842.                 if(isadmin[1]<=3){
  1843.                 if(isadmin[0]){
  1844.                     if(playerids[keys[i]].playerData?.children && playerids[keys[i]].guest==false){
  1845.                         for(var i2 = 0;i2<playerids[keys[i]].playerData.children.length;i2++){
  1846.                             if(playerids[keys[i]].playerData.children[i2].text && (allstyles[playerids[keys[i]].userName][0]==0 && allstyles[playerids[keys[i]].userName][1]==0 && allstyles[playerids[keys[i]].userName][2]==0)){
  1847.                                 playerids[keys[i]].playerData.children[i2].tint = (75+Math.abs(180-admins[isadmin[1]][1][0]))*256**2 + (75+Math.abs(180-admins[isadmin[1]][1][1]))*256 + 75+Math.abs(180-admins[isadmin[1]][1][2]);
  1848.                             }
  1849.                             if(!Array.isArray(playerids[keys[i]].playerData.children[i2].filters)){
  1850.                                 playerids[keys[i]].playerData.children[i2].filters = [new Gwindow.PIXI.filters.ColorMatrixFilter()];
  1851.                                 playerids[keys[i]].playerData.children[i2].filters[0].resolution = 3;
  1852.                             }
  1853.                             var rotatevalue = 0;
  1854.                             if(admins[isadmin[1]][1][3]<90){
  1855.                                 rotatevalue = admins[isadmin[1]][1][3]/2;
  1856.                             }
  1857.                             else if(admins[isadmin[1]][1][3]<270){
  1858.                                 rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  1859.                             }
  1860.                             else if(admins[isadmin[1]][1][3]<360){
  1861.                                 rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  1862.                             }
  1863.                            
  1864.                             playerids[keys[i]].playerData.children[i2].filters[0].hue(rotatevalue);
  1865.                         }
  1866.                     }
  1867.                 }
  1868.                 }
  1869.             }
  1870.         }
  1871.        
  1872.         parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1873.         parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1874.         parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1875.         parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1876.         if(canvasWidth!=width){
  1877.             canvasWidth = width;
  1878.             pixiCircle.clear();
  1879.             pixiCircle.x = parseInt(canv.style["width"])/2;
  1880.             pixiCircle.y = parseInt(canv.style["height"])/2;
  1881.             pixiCircle.lineStyle(3, 0x8B8000);
  1882.             pixiCircle.drawRect(-parseInt(canv.style["width"])/2,-parseInt(canv.style["height"])/2,parseInt(canv.style["width"]),parseInt(canv.style["height"]));
  1883.             pixiCircle.lineStyle(3, 0xFF0000);
  1884.             pixiCircle.arc(0, 0, 850*scale,Math.atan2(250,-100*Math.sqrt(66)),Math.atan2(250,100*Math.sqrt(66)));
  1885.             pixiCircle.lineTo(-100*Math.sqrt(66)*scale,250*scale);
  1886.             parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1887.             parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1888.             parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1889.             parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1890.         }
  1891.  
  1892.         if(!addto.children.includes(container)){
  1893.             addto.addChild(container);
  1894.         }
  1895.         if(keys.length>0){
  1896.             if(playerids[myid].playerData && playerids[myid].playerData2){
  1897.                 if(aimbot || heavybot || staystill){
  1898.                     var targetid = -1;
  1899.                     var distances = {};
  1900.                     if(Gdocument.getElementById("ingamecountdown").style["visibility"] == "hidden"){
  1901.                         if(playerids[myid].playerData.transform){
  1902.                             var teamok = true;
  1903.                             if(playerids[myid].team>1){
  1904.                                 teamok = false;
  1905.                             }
  1906.                             for(var i = 0;i<keys.length;i++){
  1907.                                 if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2 && keys[i]!=myid){
  1908.                                     if(playerids[keys[i]].playerData.transform && (playerids[keys[i]].team != playerids[myid].team || teamok || FFA)){
  1909.                                         distances[keys[i]] = Math.sqrt((playerids[keys[i]].playerData.transform.position.x-playerids[myid].playerData.transform.position.x)**2+(playerids[keys[i]].playerData.transform.position.y-playerids[myid].playerData.transform.position.y)**2);
  1910.                                     }
  1911.                                 }
  1912.                             }
  1913.                         }
  1914.                     }
  1915.                     var lowestD = [-1,-1];
  1916.                     var keys2 = Object.keys(distances);
  1917.                     for(var i = 0;i<keys2.length;i++){
  1918.                         if(myid != keys2[i]){
  1919.                             if(lowestD[1] == -1){
  1920.                                 lowestD[1] = distances[keys2[i]];
  1921.                                 lowestD[0] = keys2[i];
  1922.                             }
  1923.                             else if(distances[keys2[i]]<lowestD[1]){
  1924.                                 lowestD[1] = distances[keys2[i]];
  1925.                                 lowestD[0] = keys2[i];
  1926.                             }
  1927.                         }
  1928.                     }
  1929.                     targetid = lowestD[0];
  1930.                     if(playerids[myid].playerData?.transform && playerids[myid].playerData2){
  1931.                         if(staystill & staystillpos[0]!=null){
  1932.                             var playerpos = playerids[myid].playerData.transform.position;
  1933.                             if(Math.abs(staystillpos[0]-playerpos.x/scale)<3){
  1934.                                 if(playerids[myid].playerData2.xvel/scale>0){
  1935.                                     fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1936.                                     fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1937.                                 }
  1938.                                 else if(playerids[myid].playerData2.xvel/scale<0){
  1939.                                     fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1940.                                     fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1941.                                 }
  1942.                                 else{
  1943.                                     fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1944.                                     fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1945.                                 }
  1946.                             }
  1947.                             else{
  1948.                                 if(staystillpos[0]>playerpos.x/scale){
  1949.                                     if(playerids[myid].playerData2.xvel/scale>10){
  1950.                                         fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1951.                                         fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1952.                                     }
  1953.                                     else{
  1954.                                         fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1955.                                         fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1956.                                     }
  1957.                                 }
  1958.                                 else if(staystillpos[0]<playerpos.x/scale){
  1959.                                     if(playerids[myid].playerData2.xvel/scale<-10){
  1960.                                         fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1961.                                         fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1962.                                     }
  1963.                                     else{
  1964.                                         fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1965.                                         fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1966.                                     }
  1967.                                 }
  1968.                             }
  1969.                         }
  1970.                     }
  1971.                     if(targetid != -1 && playerids[myid].playerData?.transform){
  1972.                         if(playerids[myid].playerData.children.length >= 7 && playerids[targetid].playerData && playerids[targetid].playerData.transform && playerids[targetid].playerData2 && aimbot){
  1973.                             var indexE = -1;
  1974.                             for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1975.                                 if(playerids[myid].playerData.children[i].constructor.name == "e"){
  1976.                                     indexE = i;
  1977.                                     break;
  1978.                                 }
  1979.                             }
  1980.                             if(indexE != -1 && playerids[myid].playerData.children[indexE].visible){
  1981.                                 if(started == 0){
  1982.                                     started = now;
  1983.                                 }
  1984.                                 var scale2=1/(parseInt(canv.style["width"])/730);
  1985.                                 scale2 /= scale/(1 + playerids[myid].playerData2.balance*0.0088)*(playerids[myid].playerData2.radius/12);
  1986.                                 var Dstarted = (Math.min((now-started)/1000,10/3)/(10/3));
  1987.                                 var v = multiplier * (Dstarted*100+15)*scale2;
  1988.                                 var g = gravity;
  1989.                                 var mypos = playerids[myid].playerData.transform.position;
  1990.                                 var targetpos = playerids[targetid].playerData.transform.position;
  1991.                                 var deltapos = [(targetpos.x-mypos.x)*scale2,(targetpos.y-mypos.y)*scale2];
  1992.                                 var dis = (Math.sqrt(deltapos[0]**2 + deltapos[1]**2))/v*prediction;
  1993.                                 deltapos[0]+=(playerids[targetid].playerData2.xvel*scale2*dis+(playerids[targetid].playerData2.xacc*scale2*(dis))**2/2);
  1994.                                 deltapos[1]+=(playerids[targetid].playerData2.yvel*scale2*dis+(playerids[targetid].playerData2.yacc*scale2*(dis))**2/2);
  1995.                                 deltapos[1] = -deltapos[1];
  1996.                                 var angle = positive(-Math.atan2(deltapos[1],deltapos[0]));
  1997.                                 var rot = playerids[myid].playerData.children[indexE].transform.rotation;
  1998.                                 rot = positive(rot);
  1999.                                 angle = positive(angle);
  2000.  
  2001.                                 var alpha = deltapos[0];
  2002.                                 var beta = deltapos[1];
  2003.                                 var v_squared = v**2;
  2004.                                 var eff = 2*v_squared/g;
  2005.                                 var rootterm = eff*(eff-2*beta)-2*alpha**2;
  2006.                                 if(rootterm < 0) {
  2007.                                 } else {
  2008.                                     gamma_first = (eff + Math.sqrt(rootterm));
  2009.                                     gamma_second = (eff - Math.sqrt(rootterm));
  2010.                                     theta_first = positive(-Math.atan2(gamma_first, alpha));
  2011.                                     theta_second = positive(-Math.atan2(gamma_second, alpha));
  2012.                                     if(angle_between(angle,theta_first)<angle_between(angle,theta_second)){
  2013.                                         angle = theta_first;
  2014.                                     }
  2015.                                     else{
  2016.                                         angle = theta_second;
  2017.                                     }
  2018.                                 }
  2019.                                 var min = angle_between(angle,rot);
  2020.                                 if(angle_between2(angle,rot)<0){
  2021.                                     fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  2022.                                     fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  2023.                                 }
  2024.                                 else{
  2025.                                     fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  2026.                                     fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  2027.                                 }
  2028.                                 if(min<0.05){
  2029.                                     fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  2030.                                     fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  2031.                                 }
  2032.                             }
  2033.                             else if(started>0){
  2034.                                 started = 0;
  2035.                                 fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  2036.                                 fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  2037.                             }
  2038.                         }
  2039.                     }
  2040.                     if(playerids[myid].playerData?.transform && heavybot && mode!="f" && mode!="bs"){
  2041.                         var myradius = playerids[myid].playerData2.radius / scale;
  2042.                         var mypos = playerids[myid].playerData.transform.position;
  2043.                         var breakout = false;
  2044.                         for(var i = 0;i<keys2.length;i++){
  2045.                             var targetradius = playerids[keys2[i]].playerData2.radius / scale;
  2046.                             var targetpos = playerids[keys2[i]].playerData.transform.position;
  2047.                             var deltapos = [(targetpos.x-mypos.x)/scale,(targetpos.y-mypos.y)/scale];
  2048.                             for(var i2 = 0;i2<160;i2++){
  2049.                                 deltapos2 = [...deltapos];
  2050.                                 var i3 = i2*0.5;
  2051.                                 deltapos2[0]+=((playerids[keys2[i]].playerData2.xvel-playerids[myid].playerData2.xvel)/scale*i3);
  2052.                                 deltapos2[1]+=((playerids[keys2[i]].playerData2.yvel-playerids[myid].playerData2.yvel)/scale*i3);
  2053.                                 var dis = Math.sqrt(deltapos2[0]**2+deltapos2[1]**2);
  2054.                                 if(dis<myradius+targetradius){
  2055.                                     breakout = true;
  2056.                                     holdheavy = 20;
  2057.                                     break;
  2058.                                 }
  2059.                             }
  2060.                             if(breakout){
  2061.                                 break;
  2062.                             }
  2063.                         }
  2064.                        
  2065.                         if(holdheavy>0){
  2066.                             if(!heavyheld2){
  2067.                                 heavyheld = playerids[myid].playerData.children[heavyid].alpha>0;
  2068.                             }
  2069.                             fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  2070.                             heavyheld2 = true;
  2071.                             if(mode == "sp"){
  2072.                                 if(!grappleheld2){
  2073.                                     grappleheld = playerids[myid].playerData.children[specialid].vertexData?.length>0;
  2074.                                 }
  2075.                                 if(grappleheld){
  2076.                                     fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  2077.                                 }
  2078.                                 grappleheld2 = true;
  2079.                             }
  2080.                         }
  2081.                         else if(holdheavy<0){
  2082.                             holdheavy = 0;
  2083.                             heavyheld2 = false;
  2084.                             grappleheld2 = false;
  2085.                             if(!heavyheld){
  2086.                                 heavyheld = false;
  2087.                                 fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  2088.                             }
  2089.                             if(grappleheld && mode == "sp"){
  2090.                                 grappleheld = false;
  2091.                                 fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  2092.                             }
  2093.                         }
  2094.                         else{
  2095.                             heavyheld2 = false;
  2096.                             heavyheld = false;
  2097.                             grappleheld2 = false;
  2098.                             grappleheld = false;
  2099.                         }
  2100.                     }
  2101.  
  2102.                 }
  2103.                 if(FollowCam){
  2104.                     if(playerids[myid].playerData?.transform){
  2105.  
  2106.                         pixiCircle.visible = true;
  2107.  
  2108.                         parentDraw.x = -playerids[myid].playerData.x*addto.scale.x+parseInt(width)/2;
  2109.                         parentDraw.y = -playerids[myid].playerData.y*addto.scale.y+parseInt(height)/2;
  2110.                         parentDraw.children[0].x = playerids[myid].playerData.x*addto.scale.x-parseInt(width)/2;
  2111.                         parentDraw.children[0].y = playerids[myid].playerData.y*addto.scale.y-parseInt(height)/2;
  2112.                     }
  2113.                     else{
  2114.                         parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  2115.                         parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  2116.                         parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  2117.                         parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  2118.                         if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  2119.                             pixiCircle.visible = false;
  2120.                         }
  2121.                         else{
  2122.                             pixiCircle.visible = true;
  2123.                         }
  2124.                     }
  2125.                 }
  2126.             }
  2127.         }
  2128.         if(!FollowCam){
  2129.             if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !pan_enabled){
  2130.                 pixiCircle.visible = false;
  2131.             }
  2132.             else{
  2133.                 pixiCircle.visible = true;
  2134.             }
  2135.         }
  2136.         parentDraw.x+=panx*addto.scale.x;
  2137.         parentDraw.y+=pany*addto.scale.y;
  2138.         parentDraw.children[0].x-=panx*addto.scale.x;
  2139.         parentDraw.children[0].y-=pany*addto.scale.y;
  2140.     }
  2141.     if(maxfps){
  2142.         return setTimeout.call(this,...args);
  2143.     }
  2144.     return requestAnimationFrameOriginal.call(this,...args);
  2145. };    
  2146.    
  2147.    
  2148. scope.SENDFUNCTION = function(args){return args;};
  2149. scope.RECIEVEFUNCTION = function(args){return args;};
  2150. scope.EVENTLOOPFUNCTION = function(){};
  2151.  
  2152. Gwindow.WebSocket.prototype.send = function(args) {
  2153.     if(this.url.includes("socket.io/?EIO=3&transport=websocket&sid=")){
  2154.         if(typeof(args) == "string" && !bonkwssextra.includes(this)){
  2155.             args = SENDFUNCTION(args);
  2156.             wsssendlog.push(args);
  2157.             wsssendrecievelog.push([0,args]);
  2158.             if(!bonkwss){
  2159.                 bonkwss = this;
  2160.             }
  2161.             if(args.startsWith('42[26,')){
  2162.                 var jsonargs = JSON.parse(args.substring(2));
  2163.                 if(sandboxon){
  2164.                     if(typeof(sandboxplayerids[jsonargs[1]["targetID"]])!='undefined'){
  2165.                         var packet = '42[18,'+jsonargs[1]["targetID"]+','+jsonargs[1]["targetTeam"]+']';
  2166.                         RECIEVE(packet);
  2167.                         SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  2168.                     }
  2169.                 }
  2170.             }
  2171.             if(args.startsWith('42[9,')){
  2172.                 var jsonargs = JSON.parse(args.substring(2));
  2173.                 if(sandboxon){
  2174.                    
  2175.                     if(typeof(sandboxplayerids[jsonargs[1]["banshortid"]])!='undefined'){
  2176.                         if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  2177.                             var packet = '42[24,'+jsonargs[1]["banshortid"].toString()+','+jsonargs[1]["kickonly"]+']';
  2178.                             var packet2 = '42[5,'+jsonargs[1]["banshortid"].toString()+',0]';
  2179.                             RECIEVE(packet);
  2180.                             RECIEVE(packet2);
  2181.                             SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet,packet2],to:[-1]}]));
  2182.                         }
  2183.                         else{
  2184.                             displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  2185.                         }
  2186.                     }
  2187.                 }
  2188.             }
  2189.             if(args.startsWith('42[1,')){
  2190.                 return;
  2191.             }
  2192.  
  2193.             if(args.startsWith('42[4,')){
  2194.                 var jsonargs = JSON.parse(args.substring(2));
  2195.                
  2196.                 if(sandboxcopyme==myid && typeof(jsonargs[1]["i"])!="undefined"){
  2197.                     var jsonkeys = Object.keys(sandboxplayerids);
  2198.                     var jsonargs2 = jsonargs[1];
  2199.                     for(var i = 0; i<jsonkeys.length;i++){
  2200.                         jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2201.                         var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2202.                         RECIEVE(packet);
  2203.                     }
  2204.                     jsonargs2["c"] = "CVALUE";
  2205.                     jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2206.                     SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2207.                 }
  2208.                 if(typeof(jsonargs[1]["i"]) != "undefined"){
  2209.                     if(playerids[myid].movecount>=jsonargs[1]["c"]){
  2210.                         jsonargs[1]["c"] = playerids[myid].movecount;
  2211.                         playerids[myid].movecount+=1;
  2212.                     }
  2213.                     else{
  2214.                         playerids[myid].movecount = jsonargs[1]["c"]+1;
  2215.                     }
  2216.                 }
  2217.                 if(recording && typeof(jsonargs[1]["i"])!="undefined"){
  2218.                     if(myid.toString() == recordingid){
  2219.                         if(recordingdata.length == 0){
  2220.                             recordingdata.push([jsonargs[1]["i"],jsonargs[1]["f"]]);
  2221.                         }
  2222.                         else{
  2223.                             recordingdata.push([jsonargs[1]["i"],jsonargs[1]["f"]-recordingdata[0][1]]);
  2224.                         }
  2225.                     }
  2226.                 }
  2227.                 playerids[myid].lastmove = Date.now();
  2228.                 if(ishost && typeof(jsonargs[1]["i"])!="undefined"){
  2229.                     for(var i = 0;i<disabledkeys.length;i++){
  2230.                         if(GET_KEYS(jsonargs[1]["i"])[disabledkeys[i]]){
  2231.                             if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(myid)){
  2232.                                 killedids.push(myid);
  2233.                                 currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2234.                                 SEND('42[25,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2235.                                 RECIEVE('42[31,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2236.                                 break;
  2237.                             }
  2238.                         }
  2239.                     }
  2240.                 }
  2241.                 args = "42"+JSON.stringify(jsonargs);
  2242.             }
  2243.             if(args.startsWith('42[29,')){
  2244.                 var jsonargs = JSON.parse(args.substring(2));
  2245.                 playerids[jsonargs[1]["sid"]].playerData2.balance = jsonargs[1]["bal"];
  2246.                 if(sandboxon){
  2247.                     if(typeof(sandboxplayerids[jsonargs[1]["sid"]])!='undefined'){
  2248.                         var packet = '42[36,'+jsonargs[1]["sid"]+','+jsonargs[1]["bal"]+']';
  2249.                         RECIEVE(packet);
  2250.                         SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  2251.                     }
  2252.                 }
  2253.             }
  2254.             if(args.startsWith('42[12,')){
  2255.                 playerids = {};
  2256.                 var jsonargs2 = JSON.parse(args.substring(2));
  2257.                 var jsonargs = jsonargs2[1];
  2258.                 playerids["0"] = {"peerID":jsonargs["peerID"],"userName":username,"level":Gdocument.getElementById("pretty_top_level").textContent == "Guest" ? 0 : parseInt(Gdocument.getElementById("pretty_top_level").textContent.substring(3)),"guest":typeof(jsonargs.token)=="undefined","team":1,"avatar":jsonargs["avatar"],"movecount":0,"commands":true,"ratelimit":{"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now(),"style":0},"vote":{"poll":-1}};
  2259.                 allstyles[username] = [0,0,0];
  2260.                 myid = 0;
  2261.                 bonkwss = this;
  2262.                 hostid = 0;
  2263.                 inroom = true;
  2264.                 if(savedrooms.length>0){
  2265.                     Gdocument.getElementById("roomlistrefreshbutton").click();
  2266.                 }
  2267.             }
  2268.             if(args.startsWith('42[10')){
  2269.                 var jsonargs = JSON.parse(args.substring(2));
  2270.                 if(jsonargs[2]){
  2271.                     args = "42"+JSON.stringify([10,jsonargs[1]]);
  2272.                 }
  2273.                 else if(translating2[0]){
  2274.                     text = translate(jsonargs[1]["message"],"auto",translating2[1]).then(function(r){SEND("42"+JSON.stringify([10,{"message":r},true]))});
  2275.                     return;
  2276.                 }
  2277.             }
  2278.             if (args.startsWith('42[23,')) {
  2279.                 var jsonargs = JSON.parse(args.substring(2));
  2280.                 var map = decodeFromDatabase(jsonargs[1]["m"]);
  2281.                 currentmap.push(map);
  2282.             }
  2283.             if(args.startsWith('42[23,') && recteams){
  2284.                 var jsonargs = JSON.parse(args.substring(2));
  2285.                 var map = decodeFromDatabase(jsonargs[1]["m"]);
  2286.                 var spawns = map["spawns"];
  2287.                 var teamsneeded = true;
  2288.                 var excludedindexes = [];
  2289.                 var ffaspawns = false;
  2290.                 var ffaforsure = false;
  2291.                 for(var i = 0; i<spawns.length;i++){
  2292.                     var currentSpawn = spawns[i];
  2293.                     if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 || currentSpawn.y>250){
  2294.                         excludedindexes.push(i);
  2295.                     }
  2296.                     else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  2297.                         excludedindexes.push(i);
  2298.                     }
  2299.                     else if(currentSpawn.f){
  2300.                         ffaspawns = true;
  2301.                         if(!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  2302.                             excludedindexes.push(i);
  2303.                             ffaforsure = true
  2304.                         }
  2305.                     }
  2306.                 }
  2307.                 if(!ffaspawns && !ffaforsure){
  2308.                     teamsneeded = true;
  2309.                 }
  2310.                 else{
  2311.                     teamsneeded = false;
  2312.                 }
  2313.                 if(teamsneeded){
  2314.                     var newspawns = [];
  2315.                     for(var i = 0; i<spawns.length;i++){
  2316.                         if(!excludedindexes.includes(i)){
  2317.                             newspawns.push({"r":spawns[i]["r"],"g":spawns[i]["gr"],"b":spawns[i]["b"],"y":spawns[i]["ye"],"total":spawns[i]["r"]+spawns[i]["ye"]+spawns[i]["gr"]+spawns[i]["b"],"priority":spawns[i]["priority"]});
  2318.                         }
  2319.                     }
  2320.                    
  2321.                     if(newspawns.length>0){
  2322.                        
  2323.                         var teamletters = ["r","g","b","y"];
  2324.                         var ratios = {"r":0,"g":0,"b":0,"y":0};
  2325.                         for(var i = 0; i < newspawns.length;i++){
  2326.                             for(var i2 = 0; i2<teamletters.length;i2++){
  2327.                                 var ct = teamletters[i2];
  2328.                                 if(newspawns[i]["priority"]!=0){
  2329.                                     ratios[ct]+=(newspawns[i][ct])/newspawns[i]["total"]*newspawns[i]["priority"];
  2330.                                 }
  2331.                             }
  2332.                         }
  2333.                         var highest = ["",0];
  2334.                         for(var i = 0; i<teamletters.length;i++){
  2335.                             var ct = teamletters[i];
  2336.                             if(ratios[ct]>0 && highest[1]<ratios[ct]){
  2337.                                 highest = [ct,ratios[ct]];
  2338.                             }
  2339.                         }
  2340.                         if(highest[0]!=""){
  2341.                             for(var i = 0; i<teamletters.length;i++){
  2342.                                 var ct = teamletters[i];
  2343.                                 ratios[ct] = ratios[ct]/highest[1];
  2344.                             }
  2345.                         }
  2346.                         var playerids3 = Object.keys(playerids);
  2347.                         var playerids2 = [];
  2348.                         for(var i = 0; i<playerids3.length;i++){
  2349.                             if(playerids[playerids3[i]].team>0){
  2350.                                 playerids2.push(playerids3[i]);
  2351.                             }
  2352.                         }
  2353.                        
  2354.                         var pi2l = playerids2.length;
  2355.                         var ratios2 = {"r":0,"r1":0,"g":0,"g1":0,"b":0,"b1":0,"y":0,"y1":0};
  2356.                         var items = Object.entries(ratios);
  2357.                         items.sort(function(a,b){return a[1]-b[1];});
  2358.                         var items = items.map(function(e){return e[0];});
  2359.                         var highest2 = ["",0];
  2360.                         while(pi2l>0){
  2361.                             var done = false;
  2362.                             for(var i2 = 0; i2<items.length;i2++){
  2363.                                 var ci = items[i2];
  2364.                                 var ci2 = items[i2]+"1";
  2365.                                 for(var i = 0; i<teamletters.length;i++){
  2366.                                     var ct = teamletters[i];
  2367.                                     if(ratios2[ct]>0 && highest2[1]<ratios2[ct]){
  2368.                                         highest2 = [ct,ratios2[ct]];
  2369.                                     }
  2370.                                 }
  2371.                                 if(highest2[0]!=""){
  2372.                                     for(var i = 0; i<teamletters.length;i++){
  2373.                                         var ct = teamletters[i];
  2374.                                         ratios2[ct+"1"] = ratios2[ct]/highest2[1];
  2375.                                     }
  2376.                                 }
  2377.                                 if(ratios[ci]>0 && ratios[ci]>=ratios2[ci2] && pi2l>0){
  2378.                                     ratios2[ci]+=1;
  2379.                                     pi2l--;
  2380.                                     done = true;
  2381.                                 }
  2382.                             }
  2383.                             if(pi2l>0 && !done){
  2384.                                 ratios2[highest2[0]]+=1;
  2385.                                 pi2l--;
  2386.                             }
  2387.                         }
  2388.                         SEND('42[32,{"t":true}]');
  2389.                         RECIEVE('42[39,true]');
  2390.                         for(var i = 0; i<ratios2["r"];i++){
  2391.                             var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2392.                             SEND('42[26,{"targetID":'+pid+',"targetTeam":2}]');
  2393.                             if(playerids[pid].peerID!="sandbox"){
  2394.                                 RECIEVE('42[18,'+pid+',2]');
  2395.                             }
  2396.                         }
  2397.                         for(var i = 0; i<ratios2["g"];i++){
  2398.                             var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2399.                             SEND('42[26,{"targetID":'+pid+',"targetTeam":4}]');
  2400.                             if(playerids[pid].peerID!="sandbox"){
  2401.                                 RECIEVE('42[18,'+pid+',4]');
  2402.                             }
  2403.                         }
  2404.                         for(var i = 0; i<ratios2["b"];i++){
  2405.                             var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2406.                             SEND('42[26,{"targetID":'+pid+',"targetTeam":3}]');
  2407.                             if(playerids[pid].peerID!="sandbox"){
  2408.                                 RECIEVE('42[18,'+pid+',3]');
  2409.                             }
  2410.                         }
  2411.                         for(var i = 0; i<ratios2["y"];i++){
  2412.                             var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2413.                             SEND('42[26,{"targetID":'+pid+',"targetTeam":5}]');
  2414.                             if(playerids[pid].peerID!="sandbox"){
  2415.                                 RECIEVE('42[18,'+pid+',5]');
  2416.                             }
  2417.                         }
  2418.                        
  2419.                     }
  2420.                 }
  2421.                 else{
  2422.                     SEND('42[32,{"t":false}]');
  2423.                     RECIEVE('42[39,false]');
  2424.                 }
  2425.                
  2426.                
  2427.             }
  2428.  
  2429.             if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden && !qppaused){
  2430.                 roundsperqp2++;
  2431.                 if(roundsperqp2>=roundsperqp){
  2432.                     if(shuffle){
  2433.                         var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2434.                         var available = [];
  2435.                         var availableindexes = [];
  2436.                         var notempty = false;
  2437.                         for(var i = 0; i<e2.length;i++){
  2438.                             var a = false;
  2439.                             [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2440.                             available.push(a);
  2441.                             if(a){
  2442.                                 availableindexes.push(i);
  2443.                                 notempty = true;
  2444.                             }
  2445.                         }
  2446.                         if(notempty){
  2447.  
  2448.                             if(availableindexes.length!=1){
  2449.                                 availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2450.                             }
  2451.                             quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2452.                         }
  2453.                     }
  2454.                     else{
  2455.                         var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2456.                         var available = [];
  2457.                         var availableindexes = [];
  2458.                         var notempty = false;
  2459.                         for(var i = 0; i<e2.length;i++){
  2460.                             var a = false;
  2461.                             [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2462.                             available.push(a);
  2463.                             if(a){
  2464.                                 availableindexes.push(i);
  2465.                                 notempty = true;
  2466.                             }
  2467.                         }
  2468.                         if(notempty){
  2469.                             var above = [];
  2470.                             for(var i = 0;i<availableindexes.length;i++){
  2471.                                 if(availableindexes[i]>quicki && !reverseqp){
  2472.                                     above.push(availableindexes[i]);  
  2473.                                 }
  2474.                                 else if(availableindexes[i]<quicki && reverseqp){
  2475.                                     above.push(availableindexes[i])
  2476.                                 }
  2477.                             }
  2478.                             if(above.length>0){
  2479.                                 quicki = above[0];
  2480.                                 if(reverseqp){
  2481.                                     quicki = above[above.length-1];
  2482.                                 }
  2483.                             }
  2484.                             else{
  2485.                                 quicki = availableindexes[0];
  2486.                                 if(reverseqp){
  2487.                                     quicki = availableindexes[availableindexes.length-1];
  2488.                                 }
  2489.                             }
  2490.                         }
  2491.                     }
  2492.                 }
  2493.                 canceled = false;
  2494.                 startedinqp = true;
  2495.                 window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  2496.                
  2497.             }
  2498.             if(args.startsWith('42[32,')){
  2499.                 var jsonargs = JSON.parse(args.substring(2));
  2500.                 var keys = Object.keys(playerids);
  2501.                 if(!jsonargs[1]["t"]){
  2502.                     FFA = true;
  2503.                     for(var i = 0;i<keys.length;i++){
  2504.                         if(playerids[keys[i]].team!=0){
  2505.                             playerids[keys[i]].team = 1;
  2506.                         }
  2507.                     }
  2508.                 }
  2509.                 else{
  2510.                     FFA = false;
  2511.                 }
  2512.             }
  2513.            
  2514.             if(args.startsWith('42[5,')){
  2515.                 var jsonargs = JSON.parse(args.substring(2));
  2516.                
  2517.                 if(stopquickplay!=1 && startedinqp){
  2518.                     startedinqp = false;
  2519.                     jsonargs[1]["gs"]["wl"] = 999;
  2520.                     if(!instaqp){
  2521.                         var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  2522.                         jsonargs2["ftu"] = 60;
  2523.                         if(jsonargs2["mm"]["rxa"] != ""){
  2524.                             jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  2525.                             jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  2526.                         }
  2527.                         jsonargs2 = encodeIS(jsonargs2);
  2528.                         jsonargs[1]["is"] = jsonargs2;
  2529.                        
  2530.                         var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  2531.                         if(jsonargs3["m"]["rxa"] != ""){
  2532.                             jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  2533.                             jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  2534.                         }
  2535.  
  2536.                         jsonargs3 = encodeToDatabase(jsonargs3);
  2537.                         jsonargs[1]["gs"]["map"] = jsonargs3;
  2538.                     }
  2539.                    
  2540.                    
  2541.                 }
  2542.  
  2543.                 args = "42"+JSON.stringify(jsonargs);
  2544.             }
  2545.         }
  2546.  
  2547.     }
  2548.     else{
  2549.         if(args.includes("rport")){
  2550.             return;
  2551.         }
  2552.     }
  2553.     if(this.url.includes("socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  2554.         this.injected = true;
  2555.  
  2556.         var originalRecieve = this.onmessage;
  2557.         this.onmessage = function(args){
  2558.             if(!bonkwssextra.includes(this)){
  2559.                 if (typeof (args.data) == "string" && args.data.startsWith("42[")) {
  2560.                     args = { "data": args.data };
  2561.                     var args2 = JSON.parse(args.data.substring(2));
  2562.                     args2[0] = parseInt(args2[0]);
  2563.                     args.data = "42"+JSON.stringify(args2);
  2564.                 }
  2565.             wssrecievelog.push(args.data);
  2566.             wsssendrecievelog.push([1,args.data]);
  2567.             if(typeof(args.data)=="string"){
  2568.             args = {"data":RECIEVEFUNCTION(args.data)};
  2569.             if(args.data.startsWith('42[1,')){
  2570.                 var jsonargs = JSON.parse(args.data.substring(2));
  2571.                 originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  2572.             }
  2573.             if(args.data.startsWith('42[36,')){
  2574.                 var jsonargs = JSON.parse(args.data.substring(2));
  2575.                 playerids[jsonargs[1]].playerData2.balance = jsonargs[2];
  2576.             }
  2577.            
  2578.             if(args.data.startsWith('42[24,')){
  2579.                 beenKickedTimeStamp = Date.now();
  2580.                 onlykicked = JSON.parse(args.data.substring(2))[2];
  2581.             }
  2582.             if(args.data.startsWith('42[21,')){
  2583.                 recievedinitdata = true;
  2584.                 var jsonargs = JSON.parse(args.data.substring(2));
  2585.                 currentmap.push(jsonargs[1]["map"]);
  2586.             }
  2587.             if(args.data.startsWith('42[48,')){
  2588.                 recievedinitdata = true;
  2589.             }
  2590.             if(args.data.startsWith('42[23,')){
  2591.                 var jsonargs = JSON.parse(args.data.substring(2));
  2592.                 if(causelag){
  2593.                     jsonargs[1]["result"]-=causelag2;
  2594.                 }
  2595.                 args.data = '42'+JSON.stringify(jsonargs);
  2596.             }
  2597.             if(args.data.startsWith('42[16,')){
  2598.                 var jsonargs = JSON.parse(args.data.substring(2));
  2599.                 var now = Date.now();
  2600.                 if(jsonargs[1]=="chat_rate_limit"){
  2601.                     if(pollactive[1]+100>now){
  2602.                         pollactive = [false,0,0,[]];
  2603.                         displayInChat("Your poll failed due to chat rate limit.","#DA0808","#1EBCC1");
  2604.                         displayInChat("Please try again.","#DA0808","#1EBCC1");
  2605.                     }
  2606.                 }
  2607.                 else if(jsonargs[1]=="room_full"){
  2608.                     if(!savedrooms.includes(currentroomaddress)){
  2609.                         savedroombutton.className = "brownButton brownButton_classic buttonShadow";
  2610.                     }
  2611.                 }
  2612.             }
  2613.             if(args.data.startsWith('42[6,')){
  2614.                 var jsonargs = JSON.parse(args.data.substring(2));
  2615.                 if(typeof(playerids[jsonargs[1]])!='undefined'){
  2616.                     delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2617.                     delete playerids[jsonargs[1]];
  2618.                 }
  2619.                 hostid = jsonargs[2];
  2620.             }
  2621.             if(args.data.startsWith('42[39,')){
  2622.                 var jsonargs = JSON.parse(args.data.substring(2));
  2623.                 var keys = Object.keys(playerids);
  2624.                 if(!jsonargs[1]){
  2625.                     FFA = true;
  2626.                     for(var i = 0;i<keys.length;i++){
  2627.                         if(playerids[keys[i]].team!=0){
  2628.                             playerids[keys[i]].team = 1;
  2629.                         }
  2630.                     }
  2631.                 }
  2632.                 else{
  2633.                     FFA = false;
  2634.                 }
  2635.             }
  2636.             if(args.data.startsWith('42[41,')){
  2637.                 var jsonargs = JSON.parse(args.data.substring(2));
  2638.                 hostid = jsonargs[1]["newHost"];
  2639.             }
  2640.             if (args.data.startsWith('42[29,')) {
  2641.                 var jsonargs = JSON.parse(args.data.substring(2));
  2642.                 currentmap.push(decodeFromDatabase(jsonargs[1]));
  2643.             }
  2644.             if(args.data.startsWith('42[20,')){
  2645.                 var jsonargs = JSON.parse(args.data.substring(2));
  2646.                 if(translating[0]){
  2647.                     translate(jsonargs[2],"auto",translating[1]).then(function(r){if(r==jsonargs[2]){return;} displayInChat(playerids[jsonargs[1]].userName+": "+r,"#DA0808","#1EBCC1")});
  2648.                 }
  2649.                 if(echo_list.includes(playerids[jsonargs[1]].userName)){
  2650.                     chat(flag_manage(echotext.replaceAll("username",playerids[jsonargs[1]].userName).replaceAll("message",jsonargs[2])));
  2651.                 }
  2652.                 if(randomchat){
  2653.                     var isin = false;
  2654.                     for(var i = 0;i<randomchatpriority[1].length;i++){
  2655.                         if(randomchatpriority[1][i][0] == jsonargs[2]){
  2656.                             isin = true;
  2657.                             if(myid!=jsonargs[1]){
  2658.                                 randomchatpriority[1][i][1]+=2;
  2659.                                 randomchatpriority[0]+=2;
  2660.                             }
  2661.                             break;
  2662.                         }
  2663.                     }
  2664.                     if(!isin){
  2665.                         randomchatpriority[1].push([jsonargs[2],Math.max(35-Math.abs(35-jsonargs[2].length),1)]);
  2666.                         randomchatpriority[0]+=Math.max(35-Math.abs(35-jsonargs[2].length),1);
  2667.                     }
  2668.                 }
  2669.                 if(pollactive[0] || pollactive2[0]){
  2670.                     var chatmessage = jsonargs[2].toUpperCase().trim().replace(")","");
  2671.                     var lettersindex = letters.indexOf(chatmessage);
  2672.                     if(ishost){
  2673.                         if(pollactive[3].length>0 && lettersindex!=-1 && lettersindex<pollactive[3].length){
  2674.                             playerids[jsonargs[1]].vote.poll = lettersindex;
  2675.                         }
  2676.                     }
  2677.                     else{
  2678.                         if(pollactive2[2].length>0 && lettersindex!=-1 && lettersindex<pollactive2[2].length){
  2679.                             playerids[jsonargs[1]].vote.poll = lettersindex;
  2680.                         }
  2681.                     }
  2682.                 }
  2683.             }
  2684.             if(args.data.startsWith('42[32')){
  2685.                 SEND('42[4,{"type":"inactive kick counter"}]');
  2686.             }
  2687.             if(args.data.startsWith('42[18')){
  2688.                 var jsonargs = JSON.parse(args.data.substring(2));
  2689.                 playerids[jsonargs[1]].team = jsonargs[2];
  2690.             }
  2691.             if(args.data.startsWith('42[40,')){
  2692.                 recordedTimeStamp = Date.now();
  2693.                 recordedId = JSON.parse(args.data.substring(2))[1];
  2694.             }
  2695.            
  2696.             if(args.data.startsWith('42[3,')){
  2697.                 playerids = {};
  2698.                 var jsonargs = JSON.parse(args.data.substring(2));
  2699.                 var jsonargs2 = JSON.parse(args.data.substring(2));
  2700.                 for(var i = 0; i<jsonargs[3].length;i++){
  2701.                     if(jsonargs[3][i]!=null){
  2702.                         if(jsonargs[3][i].userName == "Juice1313" && jsonargs[3][i].level > 0){
  2703.                             jsonargs2[3][i].userName = "Piss1313";
  2704.                             jsonargs[3][i].userName = "Piss1313";
  2705.                         }
  2706.                         if(jsonargs[3][i].userName == "LEGENDBOSS123" && jsonargs[3][i].level > 0){
  2707.                             jsonargs2[3][i].level = -jsonargs2[3][i].level;
  2708.                         }
  2709.                         playerids[i.toString()] = jsonargs[3][i];
  2710.                         playerids[i.toString()].commands = false;
  2711.                         playerids[i.toString()].ratelimit = {"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now(),"style":0};
  2712.                         playerids[i.toString()].vote = {"poll":-1};
  2713.                         allstyles[playerids[i.toString()].userName] = [0,0,0];
  2714.                     }
  2715.                 }
  2716.                 if(playerids[jsonargs[1]].userName.startsWith(Gdocument.getElementById("pretty_top_name").textContent)){
  2717.                     myid = jsonargs[1];
  2718.                     bonkwss = this;
  2719.                     playerids[myid].commands = true;
  2720.                     /*setTimeout(function(){var me = playerids[myid];RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));});*/
  2721.                 }
  2722.                 else{
  2723.                     bonkwssextra.push(this);
  2724.                 }
  2725.                 inroom = true;
  2726.                 hostid = jsonargs[2];
  2727.                 SEND('42[4,{"type":"commands"}]');
  2728.                 SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":mystyle}]));
  2729.                 allstyles[playerids[myid].userName] = [...mystyle];
  2730.                 ghostroomwss = bonkwss;
  2731.                 Gdocument.getElementById("roomlistrefreshbutton").click();
  2732.                
  2733.                 setTimeout(function(){if(bonkwss == ghostroomwss && !sandboxon && !recievedinitdata && myid!=0){RECIEVE('42[21,{"map":{"v":13,"s":{"re":false,"nc":false,"pq":1,"gd":25,"fl":false},"physics":{"shapes":[],"fixtures":[],"bodies":[],"bro":[],"joints":[],"ppm":12},"spawns":[],"capZones":[],"m":{"a":"","n":"","dbv":0,"dbid":0,"authid":-1,"date":"","rxid":0,"rxn":"","rxa":"","rxdb":0,"cr":[],"pub":false,"mo":"","vu":0,"vd":0}},"gt":2,"wl":3,"q":false,"tl":false,"tea":false,"ga":"b","mo":"b","bal":[]}]');displayInChat("You have joined a ghost room.","#DA0808","#1EBCC1");}},6000);
  2734.                 args.data = "42"+JSON.stringify(jsonargs2);
  2735.             }
  2736.             if(args.data.startsWith('42[21,')){
  2737.                 var jsonargs = JSON.parse(args.data.substring(2));
  2738.                 mode = jsonargs[1]["mo"];
  2739.                 FFA = !jsonargs[1]["tea"];
  2740.             }
  2741.             if(args.data.startsWith('42[48,')){
  2742.                 var jsonargs = JSON.parse(args.data.substring(2));
  2743.                 currentmap.push(decodeFromDatabase(jsonargs[1]["gs"]["map"]));
  2744.                 mode = jsonargs[1]["gs"]["mo"];
  2745.                 FFA = !jsonargs[1]["gs"]["tea"];
  2746.             }
  2747.             if(args.data.startsWith('42[49,')){
  2748.                 /*
  2749.                 var me = playerids[myid];
  2750.                 RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));
  2751.                 */
  2752.             }
  2753.             if(args.data.startsWith('42[15,')){
  2754.                 var jsonargs = JSON.parse(args.data.substring(2));
  2755.                 dontswitch = false;
  2756.                 mode = jsonargs[3]["mo"];
  2757.                 gameStartTimeStamp = jsonargs[1];
  2758.                 killedids = [];
  2759.                 Gdocument.getElementById("newbonklobby").style["z-index"] = "unset";
  2760.                 Gdocument.getElementById("mapeditorcontainer").style["z-index"] = "unset";
  2761.                 currentmap.push(decodeFromDatabase(jsonargs[3]["map"]));
  2762.             }
  2763.             if(args.data.startsWith('42[33,')){
  2764.                 var jsonargs = JSON.parse(args.data.substring(2));
  2765.                 var decodedmap = decodeFromDatabase(jsonargs[1]);
  2766.                 if(decodedmap!=0){
  2767.                     requestedmaps = [[decodedmap,jsonargs[1]]].concat(requestedmaps);
  2768.                 }
  2769.             }
  2770.             if(args.data.startsWith('42[7,')){
  2771.                 var jsonargs2 = JSON.parse(args.data.substring(2));
  2772.                 var idofpacket = jsonargs2[1];
  2773.                 jsonargs = jsonargs2[2];
  2774.                 if(typeof(jsonargs["i"]) == "undefined"){
  2775.                    
  2776.                     if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  2777.                         from = jsonargs["from"];
  2778.                         if(Object.keys(playerids).includes(idofpacket.toString())){
  2779.                             from = playerids[idofpacket].userName;
  2780.                         }
  2781.                         if(!ignorepmlist.includes(from)){
  2782.                             if(typeof(jsonargs["message"])=="string"){
  2783.                                 var now = Date.now();
  2784.                                 if(playerids[idofpacket].ratelimit.pm+500<now){
  2785.                                     playerids[idofpacket].ratelimit.pm = now;
  2786.                                     DECRYPT_MESSAGE(private_key,jsonargs["message"]).then(function(e){
  2787.                                         var encodedtext = e;
  2788.                                         var code = 'Gwindow.private_chat = "'+from+'"; Gwindow.SEND("42"+JSON.stringify([4,{"type":"request public key","from":Gwindow.username,"to":Gwindow.private_chat}])); Gwindow.request_public_key_time_stamp = Date.now(); setTimeout(function(){if(Gwindow.private_chat_public_key[0]!=Gwindow.private_chat){Gwindow.displayInChat("Failed to connect to "+Gwindow.private_chat+".","#DA0808","#1EBCC1");Gwindow.private_chat = Gwindow.private_chat_public_key[0];}},1600);';
  2789.                                         displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+sanitize(from)+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  2790.  
  2791.                                         Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  2792.                                         Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  2793.                                        
  2794.                                         Laster_message = lastmessage();
  2795.                                     }).catch(function(){EXPORT_KEY(public_key).then(function(e){SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":e}]));});});
  2796.                                 }
  2797.                             }
  2798.                         }
  2799.                     }
  2800.                    
  2801.                     if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  2802.                         EXPORT_KEY(public_key).then(function(e){SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":e}]));});
  2803.                        
  2804.                     }
  2805.                     if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  2806.                        
  2807.                         if(typeof(jsonargs["from"])!='undefined'){
  2808.                             from = jsonargs["from"];
  2809.                             if(Object.keys(playerids).includes(idofpacket.toString())){
  2810.                                 from = playerids[idofpacket].userName;
  2811.                             }
  2812.                             if(!pmusers.includes(from) && username == jsonargs["to"]){
  2813.                                 pmusers.push(from);
  2814.                             }
  2815.                         }
  2816.                     }
  2817.                     if(jsonargs["type"]=="style" && playerids[idofpacket].ratelimit["style"]+3000<Date.now()){
  2818.                         playerids[idofpacket].ratelimit["style"] = Date.now();
  2819.                         if(Array.isArray(jsonargs["style"])){
  2820.                             if(jsonargs["style"].length == 3){
  2821.                                 var valid = true;
  2822.                                
  2823.                                 for(var i = 0;i<jsonargs["style"].length;i++){
  2824.                                     if(Number.isInteger(jsonargs["style"][i])){
  2825.                                         if(jsonargs["style"][i]>255 || jsonargs["style"][i]<0){
  2826.                                             valid = false;
  2827.                                             break;
  2828.                                         }
  2829.                                     }
  2830.                                     else{
  2831.                                         valid = false;
  2832.                                         break;
  2833.                                     }
  2834.                                 }
  2835.                                 if(valid){
  2836.                                     allstyles[playerids[idofpacket].userName] = jsonargs["style"];
  2837.                                 }
  2838.                             }
  2839.                         }
  2840.                     }
  2841.                     if(jsonargs["type"]=="request private chat users"){
  2842.                         if(typeof(jsonargs["from"])!='undefined'){
  2843.                             from = jsonargs["from"];
  2844.                             if(Object.keys(playerids).includes(idofpacket.toString())){
  2845.                                 from = playerids[idofpacket].userName;
  2846.                             }
  2847.                             SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  2848.                         }
  2849.                     }
  2850.                     if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  2851.                         from = jsonargs["from"];
  2852.                         if(Object.keys(playerids).includes(idofpacket.toString())){
  2853.                             from = playerids[idofpacket].userName;
  2854.                         }
  2855.                         if(from == private_chat){
  2856.                             IMPORT_KEY(jsonargs["public key"]).then(function(key){private_chat_public_key = [private_chat,key];displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");});
  2857.                         }
  2858.                     }
  2859.                     if(jsonargs["type"]=="fakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2860.                         for(var i = 0;i<jsonargs["packet"].length;i++){
  2861.                             if(!jsonargs["packet"][i].trim().startsWith("42[20,") && !jsonargs["packet"][i].trim().startsWith("41")){
  2862.                                 RECIEVE(sanitize(jsonargs["packet"][i]));
  2863.                             }
  2864.                         }
  2865.                     }
  2866.                     if(jsonargs["type"]=="customfakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2867.                         for(var i2 = 0;i2<jsonargs["packet"].length;i2++){
  2868.                             var keys = Object.keys(sandboxplayerids);
  2869.                             for(var i = 0;i<keys.length;i++){
  2870.                                 if(jsonargs["packet"][i2].startsWith("42[7,")){
  2871.                                     originalRecieve.call(this,{data:jsonargs["packet"][i2].replace("ID",keys[i].toString()).replace("CVALUE",playerids[keys[i]].movecount.toString())});
  2872.                                     playerids[keys[i]].movecount+=1;
  2873.                                 }
  2874.                             }
  2875.                         }
  2876.                     }
  2877.                     if(jsonargs["type"]=="commands"){
  2878.                         playerids[idofpacket].commands = true;
  2879.                     }
  2880.                     if(jsonargs["type"]=="sandboxid" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2881.                         sandboxid = jsonargs["lastid"];
  2882.                     }
  2883.                     if(jsonargs["type"]=="sandboxon" && idofpacket == hostid){
  2884.                         if(!sandboxon){
  2885.                             displayInChat("This is a sandbox lobby.","#DA0808","#1EBCC1");
  2886.                             sandboxon = true;
  2887.                         }
  2888.                     }
  2889.                     if(jsonargs["type"]=="vote poll"){
  2890.                         from = jsonargs["from"];
  2891.                         if(Object.keys(playerids).includes(idofpacket.toString())){
  2892.                             from = playerids[idofpacket].userName;
  2893.                         }
  2894.                         if(typeof(jsonargs["vote"]) == 'number' && idofpacket!=hostid){
  2895.                             var now = Date.now();
  2896.                             if(ishost && pollactive[3].length>1 && pollactive[0]){
  2897.                                 if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive[3].length){
  2898.                                     playerids[idofpacket].vote.poll = jsonargs["vote"];
  2899.                                 }
  2900.                             }
  2901.                             else if(pollactive2[0] && pollactive2[2].length>1){
  2902.                                 if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive2[2].length){
  2903.                                     playerids[idofpacket].vote.poll = jsonargs["vote"];
  2904.                                 }
  2905.                             }
  2906.                         }
  2907.  
  2908.                     }
  2909.                     if(jsonargs["type"]=="poll end"){
  2910.                         from = jsonargs["from"];
  2911.                         if(Object.keys(playerids).includes(idofpacket.toString())){
  2912.                             from = playerids[idofpacket].userName;
  2913.                         }
  2914.                         var now = Date.now();
  2915.                         if(hostid == idofpacket && playerids[idofpacket].ratelimit.poll+5000<now){
  2916.                             playerids[idofpacket].ratelimit.poll = now;
  2917.                             var count = [0,0,0,0];
  2918.                             var keys = Object.keys(playerids);
  2919.                             for(var i = 0;i<keys.length;i++){
  2920.                                 if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  2921.                                     count[playerids[keys[i]].vote.poll]++;
  2922.                                 }
  2923.                                 playerids[keys[i]].vote.poll = -1;
  2924.                             }
  2925.                             displayInChat("The poll ended.","#DA0808","#1EBCC1");
  2926.                             for(var i = 0;i<count.length;i++){
  2927.                                 if(count[i]>1){
  2928.                                     displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2929.                                 }
  2930.                                 if(count[i]==1){
  2931.                                     displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2932.                                 }
  2933.                             }
  2934.                             pollactive2 = [false,0,[]];
  2935.                         }
  2936.  
  2937.                     }
  2938.                     if(jsonargs["type"] == "video player" && idofpacket == hostid && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2939.                         changeJukeboxURL(jsonargs["url"],jsonargs["timestamp"]);
  2940.                     }
  2941.                     if(jsonargs["type"]=="poll" && idofpacket == hostid){
  2942.                         from = jsonargs["from"];
  2943.                         if(Object.keys(playerids).includes(idofpacket.toString())){
  2944.                             from = playerids[idofpacket].userName;
  2945.                         }
  2946.                         if(Array.isArray(jsonargs["poll"])){
  2947.                             var propperpoll = true;
  2948.                             var pollifproper = [];
  2949.                             if(jsonargs["poll"].length>5){
  2950.                                 propperpoll = false;
  2951.                             }
  2952.                             else{
  2953.                                 for(var i = 0;i<jsonargs["poll"].length;i++){
  2954.                                     if(typeof(jsonargs["poll"][i]) == 'string'){
  2955.                                         if(jsonargs["poll"][i].length>50){
  2956.                                             propperpoll = false;
  2957.                                             break;
  2958.                                         }
  2959.                                         else{
  2960.                                             pollifproper.push(jsonargs["poll"][i]);
  2961.                                         }
  2962.                                     }
  2963.                                     else{
  2964.                                         propperpoll = false;
  2965.                                         break;
  2966.                                     }
  2967.                                 }
  2968.                             }
  2969.                             if(propperpoll){
  2970.                                 var now = Date.now();
  2971.                                 var keys = Object.keys(playerids);
  2972.                                 for(var i = 0;i<keys.length;i++){
  2973.                                     playerids[keys[i]].vote.poll = -1;
  2974.                                 }
  2975.                                 pollactive2 = [true,now,pollifproper];
  2976.                                 playerids[idofpacket].ratelimit.poll = now;
  2977.                                 displayInChat(from+" started a poll:","#DA0808","#1EBCC1");
  2978.                                 for(var i = 0;i<pollifproper.length;i++){
  2979.                                     var code = 'Gwindow.displayInChat("You voted for option '+letters[i]+'.","#DA0808","#1EBCC1",{sanitize:false},"",true);Gwindow.SEND("42"+JSON.stringify([4,{"type":"vote poll","from":Gwindow.username,"vote":'+i+'}]));Gwindow.playerids[Gwindow.myid].vote.poll='+i+';Gwindow.Gdocument.getElementById("newbonklobby_chat_content").children[Gwindow.Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;Gwindow.Gdocument.getElementById("ingamechatcontent").children[Gwindow.Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;Gwindow.Laster_message = Gwindow.lastmessage();';
  2980.                                    
  2981.                            
  2982.                                     displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+letters[i]+')</a>',"#DA0808","#1EBCC1",{sanitize:false}," "+pollifproper[i]);
  2983.                                 }
  2984.                                
  2985.                             }
  2986.                         }
  2987.                     }
  2988.                     if(jsonargs["type"]=="request mode" && playerids[idofpacket].ratelimit.mode+1000<Date.now()){
  2989.                         playerids[idofpacket].ratelimit.mode = Date.now();
  2990.                         from = jsonargs["from"];
  2991.                         if(Object.keys(playerids).includes(idofpacket.toString())){
  2992.                             from = playerids[idofpacket].userName;
  2993.                         }
  2994.                         var req_mode = jsonargs["mode"];
  2995.                         var req_mode2 = "";
  2996.                         if(req_mode){
  2997.                             if(req_mode == "b"){
  2998.                                 req_mode2 = "Classic";
  2999.                             }
  3000.                             else if(req_mode == "sp"){
  3001.                                 req_mode2 = "Grapple";
  3002.                             }
  3003.                             else if(req_mode == "ar"){
  3004.                                 req_mode2 = "Arrows";
  3005.                             }
  3006.                             else if(req_mode == "ard"){
  3007.                                 req_mode2 = "Death Arrows";
  3008.                             }
  3009.                         }
  3010.                         if(req_mode2){
  3011.                             var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+req_mode+'")}';
  3012.                            
  3013.                             displayInChat('> '+playerids[idofpacket].userName+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+req_mode2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  3014.                         }
  3015.  
  3016.                     }
  3017.                     if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  3018.                         from = jsonargs["from"];
  3019.                         if(Object.keys(playerids).includes(idofpacket.toString())){
  3020.                             from = playerids[idofpacket].userName;
  3021.                         }
  3022.                         if(from == private_chat){
  3023.                             IMPORT_KEY(jsonargs["public key"]).then(function(public_key){private_chat_public_key = [private_chat,public_key]; ENCRYPT_MESSAGE(private_chat_public_key[1],pmlastmessage).then(function(e){
  3024.                                 setTimeout(function(){SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"message":e}]))},500);
  3025.                             });});
  3026.                            
  3027.                         }
  3028.                     }
  3029.                 }
  3030.                 else{
  3031.                     var now = Date.now();
  3032.                     if(playerids[idofpacket.toString()]){
  3033.                         playerids[idofpacket.toString()].lastmove = now;
  3034.                     }
  3035.                     if(idofpacket!=myid){
  3036.                         playerids[idofpacket.toString()].movecount+=1;
  3037.                     }
  3038.                     if(Math.abs(gameStartTimeStamp - (now-1000*jsonargs["f"]/30))>1000 && idofpacket!=myid){
  3039.                         gameStartTimeStamp = now-1000*jsonargs["f"]/30;
  3040.                     }
  3041.                     if(recording){
  3042.                         if(idofpacket.toString() == recordingid){
  3043.                             if(recordingdata.length == 0){
  3044.                                 recordingdata.push([jsonargs["i"],jsonargs["f"]]);
  3045.                             }
  3046.                             recordingdata.push([jsonargs["i"],jsonargs["f"]-recordingdata[0][1]]);
  3047.                         }
  3048.                     }
  3049.                     if(ishost){
  3050.                         if(sandboxon && idofpacket == sandboxcopyme){
  3051.                             var jsonkeys = Object.keys(sandboxplayerids);
  3052.                             if(!jsonkeys.includes(sandboxcopyme.toString())){
  3053.                                 var jsonargs2 = jsonargs;
  3054.                                 for(var i = 0; i<jsonkeys.length;i++){
  3055.                                     jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  3056.                                     var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  3057.                                     RECIEVE(packet);
  3058.                                 }
  3059.                                 jsonargs2["c"] = "CVALUE";
  3060.                                 jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  3061.                                 SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  3062.                             }
  3063.                         }
  3064.                         for(var i = 0;i<disabledkeys.length;i++){
  3065.                             var get_keys_var = GET_KEYS(jsonargs["i"]);
  3066.                             if(get_keys_var[disabledkeys[i]]){
  3067.                                 if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  3068.                                     killedids.push(idofpacket);
  3069.                                     currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3070.                                     SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3071.                                     RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  3072.                                     break;
  3073.                                 }
  3074.                             }
  3075.                         }
  3076.                     }
  3077.                 }
  3078.             }
  3079.  
  3080.             if(args.data.startsWith('42[4,')){
  3081.                 var jsonargs = JSON.parse(args.data.substring(2));
  3082.                 if(jsonargs[3] == "Juice1313" && jsonargs[5] > 0){
  3083.                     jsonargs[3] = "Piss1313";
  3084.                 }
  3085.                
  3086.                 playerids[jsonargs[1]] = {"peerID":jsonargs[2],"userName":jsonargs[3],"guest":jsonargs[4],"level":jsonargs[5],"team":jsonargs[6],"avatar":jsonargs[7],"movecount":0,"ratelimit":{"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now(),"style":0},"vote":{"poll":-1}};
  3087.                 if(jsonargs[2]!="sandbox"){
  3088.                     SEND('42[4,{"type":"commands"}]');
  3089.                     if(!Object.keys(allstyles).includes(jsonargs[3])){
  3090.                         allstyles[jsonargs[3]] = [0,0,0];
  3091.                         SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":allstyles[playerids[myid].userName]}]));
  3092.                     }
  3093.                 }
  3094.                 if(sandboxon){
  3095.                     var sandboxkeys = Object.keys(sandboxplayerids);
  3096.                     if(sandboxkeys.includes(jsonargs[1].toString())){
  3097.                         delete sandboxplayerids[jsonargs[1]];
  3098.                     }
  3099.                     if(jsonargs[2]=="sandbox"){
  3100.                         sandboxplayerids[jsonargs[1]] = jsonargs[3];
  3101.                         if(jsonargs[1]>sandboxid){
  3102.                             sandboxid = parseInt(jsonargs[1])+1;
  3103.                         }
  3104.                     }
  3105.                     else{
  3106.                         if(ishost){
  3107.                             SEND('42[4,{"type":"sandboxon"}]');
  3108.                             var sandboxkeys = Object.keys(sandboxplayerids);
  3109.                             var packets = [];
  3110.                             for(var i = 0;i<sandboxkeys.length;i++){
  3111.                                 var p = playerids[sandboxkeys[i]];
  3112.                                 var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  3113.                                 packets.push(packet);
  3114.                             }
  3115.                             SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[jsonargs[1]]}]));
  3116.                             SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[jsonargs[1]]}]));
  3117.                        
  3118.                         }
  3119.                     }
  3120.                 }
  3121.                 if(ishost){
  3122.                     if(jointext!="" && jsonargs[2]!="sandbox"){
  3123.                         chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  3124.                     }
  3125.                     if(jointeam!=-1 && jsonargs[2]!="sandbox"){
  3126.                         SEND('42[26,{"targetID":'+jsonargs[1].toString()+',"targetTeam":'+jointeam.toString()+'}]');
  3127.                         setTimeout(function(){RECIEVE('42[18,'+jsonargs[1].toString()+','+jointeam.toString()+']');});
  3128.                     }
  3129.                     if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  3130.                         SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[jsonargs[1]]}]));
  3131.                     }
  3132.                     if(freejoin){
  3133.                         var count = 0;
  3134.                         var keys = Object.keys(playerids);
  3135.                         for(var i = 0; i<keys.length;i++){
  3136.                             if(playerids[keys[i]].team!=0){
  3137.                                 count++;
  3138.                             }
  3139.                         }
  3140.                         if(count <= 2 && jsonargs[6]!=0){
  3141.                             setTimeout(function(){
  3142.                                 Gdocument.getElementById("newbonklobby_editorbutton").click();
  3143.                                 Gdocument.getElementById("mapeditor_close").click();
  3144.                                 Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3145.                                 Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3146.                                 if(transitioning == true){
  3147.                                     canceled = true;
  3148.                                 }
  3149.                             },150);
  3150.                         }
  3151.                     }
  3152.                 }
  3153.                 if(jsonargs[3] == "LEGENDBOSS123" && jsonargs[5] > 0){
  3154.                     jsonargs[5] = -jsonargs[5];
  3155.                 }
  3156.                 args.data = "42" + JSON.stringify(jsonargs);
  3157.             }
  3158.             if(args.data.startsWith('42[5,')){
  3159.                 var jsonargs = JSON.parse(args.data.substring(2));
  3160.                 if(typeof(playerids[jsonargs[1]])!='undefined'){
  3161.                     delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  3162.                     delete allstyles[playerids[jsonargs[1]].userName];
  3163.                     delete playerids[jsonargs[1]];
  3164.                 }
  3165.                 if(sandboxon && typeof(sandboxplayerids[jsonargs[1]])!='undefined'){
  3166.                     delete sandboxplayerids[jsonargs[1]];
  3167.                 }
  3168.             }
  3169.             }}
  3170.             return originalRecieve.call(this,args);
  3171.         };
  3172.  
  3173.         var originalClose = this.onclose;
  3174.         this.onclose = function () {
  3175.            
  3176.             if(bonkwssextra.includes(this)){
  3177.                 bonkwssextra.splice(bonkwssextra.indexOf(this),1)
  3178.             }
  3179.             else{
  3180.                 window.bonkwss = 0;
  3181.             }
  3182.             return originalClose.call(this);
  3183.         }
  3184.  
  3185.     }
  3186.     return originalSend.call(this,args);
  3187. };
  3188.  
  3189. scope.SEND = function(args){
  3190.     if(bonkwss!=0){
  3191.         bonkwss.send(args);
  3192.     }
  3193. };
  3194. scope.RECIEVE = function(args){
  3195.     if(bonkwss!=0){
  3196.         bonkwss.onmessage({data:args});
  3197.     }
  3198. };
  3199.  
  3200.  
  3201.  
  3202. scope.dontswitch = false;
  3203. scope.username = 0;
  3204. scope.timedelay = 1400;
  3205. scope.ishost = false;
  3206. scope.checkboxhidden = true;
  3207. scope.quicki=0;
  3208. scope.defaultmode = "d";
  3209. scope.recmodebool = false;
  3210. scope.shuffle = false;
  3211. scope.startedinqp = false;
  3212. scope.instaqp = false;
  3213. scope.freejoin = false;
  3214. scope.recordedTimeStamp = 0;
  3215. scope.recordedId = 0;
  3216. scope.smartteams = false;
  3217. scope.beenKickedTimeStamp = 0;
  3218. scope.stopquickplay = 1;
  3219. scope.currentFrame = 0;
  3220. scope.text2speech = false;
  3221. scope.canceled = false;
  3222. scope.wintext = "";
  3223. scope.banned = [];
  3224. scope.transitioning = false;
  3225. scope.echo_list = [];
  3226. scope.echoAppend = "";
  3227. scope.message = "";
  3228. scope.private_chat = "";
  3229. scope.private_chat_public_key = ["",[0,0]];
  3230. scope.disabledkeys = [];
  3231. scope.actuallyhost = false;
  3232. scope.pmusers = [];
  3233. scope.pmlastmessage = "";
  3234. scope.pmuserstimestamp = 0;
  3235. scope.ignorepmlist = [];
  3236. scope.scroll = false;
  3237. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  3238. scope.npermissions = 1;
  3239. scope.space_flag = false;
  3240. scope.rcaps_flag = false;
  3241. scope.number_flag = false;
  3242. scope.reverse_flag = false;
  3243. scope.autocorrect = false;
  3244. scope.request_public_key_time_stamp = 0;
  3245. scope.sandboxcopyme = -1;
  3246. scope.recteams = false;
  3247. scope.chatheight = 128;
  3248. scope.onlykicked = false;
  3249. scope.killedids = [];
  3250. scope.jointext = "";
  3251. scope.randomchat = false;
  3252. scope.randomchatpriority = [0,[]];
  3253. scope.randomchatlastmessage = ["",0];
  3254. scope.afkkill = -1;
  3255. scope.tournament_mode = "";
  3256. scope.tournament_scores = [];
  3257. scope.tournament_in_and_out = {"in":[],"out":[]};
  3258. scope.echotext = "message";
  3259. scope.nextafter = 0;
  3260. scope.nextafterbuffer = -1;
  3261. scope.roundsperqp = 1;
  3262. scope.roundsperqp2 = 0;
  3263. scope.autorecord = false;
  3264. scope.poll = [];
  3265. scope.letters = ["A","B","C","D","E"];
  3266. scope.qppaused = false;
  3267. scope.FollowCam = false;
  3268. scope.autocam = false;
  3269. scope.gravity = 20;
  3270. scope.randomchat = false;
  3271. scope.randomchat_randomtimestamp = 0;
  3272. scope.randomchat_timestamp = 0;
  3273. scope.multiplier = 3.65;
  3274. scope.aimbot = false;
  3275. scope.recievedinitdata = false;
  3276. scope.heavybot = false;
  3277. scope.zoom = 1;
  3278. scope.prediction = 350;
  3279. scope.started = 0;
  3280. scope.holdheavy = 0;
  3281. scope.maxfps = false;
  3282. scope.grappleheld = false;
  3283. scope.grappleheld2 = false;
  3284. scope.heavyheld = false;
  3285. scope.reverseqp = false;
  3286. scope.jointeam = -1;
  3287. scope.heavyheld2 = false;
  3288. scope.heavyid = 3;
  3289. scope.specialid = 0;
  3290. scope.keyCodes = {"BACK_SPACE":8,"TAB":9,"SHIFT":16,"ALT":18,"LEFT ARROW":37,"RIGHT ARROW":39,"DOWN ARROW":40,"UP ARROW":38,"CONTROL":17,"SPACE":32};
  3291. scope.leftRight = [37,39];
  3292. scope.upDown = [38,40];
  3293. scope.heavy = 88;
  3294. scope.special = 90;
  3295. scope.newzoom2 = 1;
  3296. scope.staystill = false;
  3297. scope.staystillpos = [0,0];
  3298. scope.zoom2 = 1;
  3299. scope.admins = [["LEGENDBOSS123",[0,0,0,0]],["iNeonz",[0,0,0,0]],["left paren",[0,0,0,0]],["OG_New_Player",[0,0,0,0]],["An Admin",[0,0,0,0]],["L armee d LS",[0,0,0,0]],["Pixelmelt",[0,0,0,0]],["pro9905",[0,0,0,0]],["JustANameForMe",[0,0,0]],["nefarious mouse",[0,0,0,0]],["Annihilate Red",[0,0,0,0]],["Ghost_mit",[0,0,0,0]],["Neptune_1",[0,0,0,0]]];
  3300.  
  3301. scope.letters2 = Array.from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
  3302. scope.superscript_letters = Array.from("ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖᑫʳˢᵗᵘᵛʷˣʸᶻᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾQᴿˢᵀᵁⱽᵂˣʸᶻ");
  3303. scope.hollow_letters = Array.from("𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛𝕜𝕝𝕞𝕟𝕠𝕡𝕢𝕣𝕤𝕥𝕦𝕧𝕨𝕩𝕪𝕫𝔸𝔹ℂ𝔻𝔼𝔽𝔾ℍ𝕀𝕁𝕂𝕃𝕄ℕ𝕆ℙℚℝ𝕊𝕋𝕌𝕍𝕎𝕏𝕐ℤ");
  3304. scope.block_letters = Array.from("🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉");
  3305. scope.bold_letters = Array.from("𝐚𝐛𝐜𝐝𝐞𝐟𝐠𝐡𝐢𝐣𝐤𝐥𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐭𝐮𝐯𝐰𝐱𝐲𝐳𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙");
  3306. scope.italicized_letters = Array.from("𝘢𝘣𝘤𝘥𝘦𝘧𝘨𝘩𝘪𝘫𝘬𝘭𝘮𝘯𝘰𝘱𝘲𝘳𝘴𝘵𝘶𝘷𝘸𝘹𝘺𝘻𝘈𝘉𝘊𝘋𝘌𝘍𝘎𝘏𝘐𝘑𝘒𝘓𝘔𝘕𝘖𝘗𝘘𝘙𝘚𝘛𝘜𝘝𝘞𝘟𝘠𝘡");
  3307. scope.glitched_letters = Array.from("ⱥƀȼđēӻꞡħīɉҟłᵯꞥꝋꝑꝗɍꞩⱦᵾꝟⱳӿɏƶȺɃȻĐɆӺ₲ĦĪɈҞŁᛗꞤꝊꝐꝖꞦꞨȾɄꝞⱲӾɎƵ");
  3308. scope.cursive_letters = Array.from("𝒶𝒷𝒸𝒹𝑒𝒻𝑔𝒽𝒾𝒿𝓀𝓁𝓂𝓃𝑜𝓅𝓆𝓇𝓈𝓉𝓊𝓋𝓌𝓍𝓎𝓏𝒜𝐵𝒞𝒟𝐸𝐹𝒢𝐻𝐼𝒥𝒦𝐿𝑀𝒩𝒪𝒫𝒬𝑅𝒮𝒯𝒰𝒱𝒲𝒳𝒴𝒵");
  3309.  
  3310. scope.letter_dictionary = {};
  3311. for(var i = 0;i<letters2.length;i++){
  3312.     letter_dictionary[letters2[i]] = [superscript_letters[i],hollow_letters[i],block_letters[i],bold_letters[i],italicized_letters[i],glitched_letters[i],cursive_letters[i]];
  3313. }
  3314. scope.textmode = -1;
  3315. scope.changeColor = function(x,operation1, operation2, operation3){
  3316.     for(var f of x.physics.fixtures){
  3317.         var r = Math.floor(f.f/256/256);
  3318.         var g = Math.floor(f.f/256)%256;
  3319.         var b = f.f%256;
  3320.         r = operation1(r, 0);
  3321.         g = operation2(g, 1);
  3322.         b = operation3(b, 2);
  3323.         f.f = Math.floor(r%256) * 256 * 256 + Math.floor(g%256) * 256 + Math.floor(b%256);
  3324.     }
  3325.     return x;
  3326. };
  3327. scope.autokickban = 0;
  3328. scope.ghostroomwss = -1;
  3329. scope.autokickbantimestamp = 0;
  3330. scope.getroomslastcheck = 0;
  3331. scope.causelag = false;
  3332. scope.causelag2 = 0;
  3333. scope.overideDate = [false,0];
  3334. scope.scale = 1;
  3335. scope.translating = [false,""];
  3336. scope.translating2 = [false,""];
  3337. scope.translatingkeys = {"english":"en","chinese":"zh","japanese":"ja","dutch":"nl","hindi":"hi","spanish":"es","portugese":"pt","french":"fr","arabic":"ar","russian":"ru","korean":"ko"};
  3338. scope.translate = function(text,fromL,toL) {
  3339.     var fL = fromL || 'en';
  3340.     var tL = toL || 'de';
  3341.     var url = 'https://translate.googleapis.com/translate_a/single?client=gtx&sl='+ fL + "&tl=" + tL + "&dt=t&q=" + encodeURI(text);
  3342.     var parseJSON = txt => JSON.parse(txt.split(',').map( x => x || 'null').join(',')) ;
  3343.     var joinSnippets = json => json[0].map( x => x[0] ).join('');
  3344.     return fetch(url).then(function(res){
  3345.         return res.text();
  3346.     }).then(function(text){
  3347.         return joinSnippets(parseJSON(text));
  3348.     });
  3349. };
  3350. scope.positive = function(angle){
  3351.     if(angle<0){
  3352.         angle += 2*Math.PI;
  3353.     }
  3354.     return angle%(Math.PI*2);
  3355. };
  3356. scope.angle_between = function(angle,angle2){
  3357.     return Math.min(Math.abs(positive(angle)-positive(angle2)),Math.PI*2-Math.abs(positive(angle)-positive(angle2)));
  3358. };
  3359. scope.angle_between2 = function(angle,angle2){
  3360.     if(angle_between(angle,angle2+Math.PI/2)<Math.PI/2){
  3361.         return 1;
  3362.     }
  3363.     return -1;
  3364. };
  3365.  
  3366. scope.stringdistance = function(s1,s2){
  3367.     s1 = s1.toLowerCase();
  3368.     s2 = s2.toLowerCase();
  3369.     var matrix = Array(s1.length+1);
  3370.     for(var i = 0;i<matrix.length;i++){
  3371.         matrix[i] = Array(s2.length+1);
  3372.         matrix[i][0] = i;
  3373.     }
  3374.     for(var i = 0;i<matrix[0].length;i++){
  3375.         matrix[0][i] = i;
  3376.     }
  3377.     for(var i = 1;i<s1.length+1;i++){
  3378.         for(var i2 = 1;i2<s2.length+1;i2++){
  3379.             if(s1[i-1]==s2[i2-1]){  
  3380.                 matrix[i][i2] = matrix[i-1][i2-1];
  3381.             }
  3382.             else{
  3383.                 matrix[i][i2] = Math.min(matrix[i][i2-1],matrix[i-1][i2],matrix[i-1][i2-1])+1;
  3384.             }
  3385.         }
  3386.     }
  3387.     return matrix[s1.length][s2.length];
  3388. };
  3389. scope.closestWord = function(word){
  3390.     if(word.length>20 || word.length<2){
  3391.         return word;
  3392.     }
  3393.     var distances = [word.length,""];
  3394.     var playernamelist = [];
  3395.     var keys = Object.keys(playerids);
  3396.     for(var i = 0;i<keys.length;i++){
  3397.         playernamelist.push(playerids[keys[i]].userName);
  3398.     }
  3399.     var wordlist2 = playernamelist.concat(wordlist);
  3400.     for(var i = 0;i<wordlist2.length;i++){
  3401.         var distance = stringdistance(word,wordlist2[i]);
  3402.         if(distance<=distances[0]){
  3403.             distances[0] = distance;
  3404.             distances[1] = wordlist2[i];
  3405.             if(distance == 0){
  3406.                 return wordlist2[i];
  3407.             }
  3408.         }
  3409.     };
  3410.     if(distances[1] == ""){
  3411.         return word;
  3412.     }
  3413.     return distances[1];
  3414. };
  3415.  
  3416.  
  3417.  
  3418. scope.replay = function(){
  3419.     var frame = getCurrentFrame();
  3420.     /*var replaycounter = 0;
  3421.     while(1){
  3422.         if(replaycounter != recordingdata.length-1){
  3423.             for(var i = 0;i<recordingdata[replaycounter+1][1]-recordingdata[replaycounter][1];i++){
  3424.                 RECIEVE('42[7,'+myid+',{"i":'+recordingdata[replaycounter][0]+',"f":'+(frame+i+recordingdata[replaycounter][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3425.                 playerids[myid].movecount+=1;
  3426.             }
  3427.             replaycounter+=1;
  3428.         }
  3429.         else{
  3430.             break;
  3431.         }
  3432.     }*/
  3433.    
  3434.     for(var i = 0;i<recordingdata.length;i++){
  3435.         SEND('42[4,{"i":'+recordingdata[i][0]+',"f":'+(frame+recordingdata[i][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3436.     }
  3437. };
  3438. scope.presskeys = function(x,y){
  3439.     if(!x.left && y.left){
  3440.         fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3441.     }
  3442.     else if(x.left && !y.left){
  3443.         fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3444.     }
  3445.     if(!x.right && y.right){
  3446.         fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3447.     }
  3448.     else if(x.right && !y.right){
  3449.         fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3450.     }
  3451.     if(!x.up && y.up){
  3452.         fire("keydown",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3453.     }
  3454.     else if(x.up && !y.up){
  3455.         fire("keyup",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3456.     }
  3457.     if(!x.down && y.down){
  3458.         fire("keydown",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3459.     }
  3460.     else if(x.down && !y.down){
  3461.         fire("keyup",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3462.     }
  3463.     if(!x.heavy && y.heavy){
  3464.         fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3465.     }
  3466.     else if(x.heavy && !y.heavy){
  3467.         fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3468.     }
  3469.     if(!x.special && y.special){
  3470.         fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3471.     }
  3472.     else if(x.special && !y.special){
  3473.         fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3474.     }
  3475.    
  3476. };
  3477. scope.getplayerkeys = function(){
  3478.     var keykeys = Object.keys(keyCodes);
  3479.     var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  3480.     var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  3481.     var keyslist3 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[3].children).slice(1);
  3482.     var keyslist4 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[4].children).slice(1);
  3483.     var keyslist5 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  3484.     var keyslist6 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  3485.     for(var i = 0;i<keyslist.length;i++){
  3486.         if(keykeys.includes(keyslist[i].textContent)){
  3487.             leftRight[0] = keyCodes[keyslist[i].textContent];
  3488.             break;
  3489.         }
  3490.         else{
  3491.             leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  3492.             break
  3493.         }
  3494.     }
  3495.     for(var i = 0;i<keyslist2.length;i++){
  3496.         if(keykeys.includes(keyslist2[i].textContent)){
  3497.             leftRight[1] = keyCodes[keyslist2[i].textContent];
  3498.             break;
  3499.         }
  3500.         else{
  3501.             leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  3502.             break
  3503.         }
  3504.     }
  3505.     for(var i = 0;i<keyslist3.length;i++){
  3506.         if(keykeys.includes(keyslist3[i].textContent)){
  3507.             upDown[0] = keyCodes[keyslist3[i].textContent];
  3508.             break;
  3509.         }
  3510.         else{
  3511.             upDown[0] = keyslist3[i].textContent.charCodeAt(0);
  3512.             break
  3513.         }
  3514.     }
  3515.     for(var i = 0;i<keyslist4.length;i++){
  3516.         if(keykeys.includes(keyslist4[i].textContent)){
  3517.             upDown[1] = keyCodes[keyslist4[i].textContent];
  3518.             break;
  3519.         }
  3520.         else{
  3521.             upDown[1] = keyslist4[i].textContent.charCodeAt(0);
  3522.             break
  3523.         }
  3524.     }
  3525.     for(var i = 0;i<keyslist5.length;i++){
  3526.         if(keykeys.includes(keyslist5[i].textContent)){
  3527.             heavy = keyCodes[keyslist5[i].textContent];
  3528.             break;
  3529.         }
  3530.         else{
  3531.             heavy = keyslist5[i].textContent.charCodeAt(0);
  3532.             break
  3533.         }
  3534.     }
  3535.     for(var i = 0;i<keyslist6.length;i++){
  3536.         if(keykeys.includes(keyslist6[i].textContent)){
  3537.             special = keyCodes[keyslist6[i].textContent];
  3538.             break;
  3539.         }
  3540.         else{
  3541.             special = keyslist6[i].textContent.charCodeAt(0);
  3542.             break
  3543.         }
  3544.     }
  3545. };
  3546. scope.changeJukeboxURL = function(url,timestamp = 0){
  3547.     if(pipedurllist.length == 0){
  3548.         displayInChat("The jukebox is still being set up.","#DA0808","#1EBCC1");
  3549.         return;
  3550.     }
  3551.     if(url == ""){
  3552.         jukeboxplayer.pause();
  3553.         jukeboxplayer.src = '';
  3554.         displayInChat("The jukebox has been paused.","#DA0808","#1EBCC1");
  3555.     }
  3556.     else if(url == jukeboxplayerURL && Date.now()-timestamp >= 2000){
  3557.         jukeboxplayer.volume = jukeboxplayervolume/100;
  3558.         displayInChat("The jukebox has been unpaused or reset.","#DA0808","#1EBCC1",{sanitize:false});
  3559.         jukeboxplayer.play();
  3560.         jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3561.     }
  3562.     else{
  3563.         var id = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/)[0].split("?v=");
  3564.         id = id[id.length-1];
  3565.         var loaded = false;
  3566.         var loaded2 = 0;
  3567.         for(var inst = 0;inst<pipedindexes.length;inst++){
  3568.             checkJukeboxStream(pipedindexes[inst],id).then(function(value){
  3569.                 loaded2+=1;
  3570.                 if(value!=-1 && !loaded){
  3571.                     loaded = true;
  3572.                     jukeboxplayer.src = value[0];
  3573.                     jukeboxplayer.volume = jukeboxplayervolume/100;
  3574.                     jukeboxplayerURL = url;
  3575.                     jukeboxplayer.oncanplaythrough = function(){
  3576.                         displayInChat("The jukebox has been changed to: ","#DA0808","#1EBCC1",{sanitize:false},url);
  3577.                         displayInChat("Jukebox is now playing: "+value[1]+" by "+value[2]+".","#DA0808","#1EBCC1");
  3578.                         jukeboxplayer.play();
  3579.                         jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3580.                         jukeboxplayer.oncanplaythrough = null;
  3581.                     };
  3582.                     jukeboxplayer.onerror = function(){
  3583.                         displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3584.                     };
  3585.                 }
  3586.             });
  3587.         }
  3588.         new Promise(function(r){
  3589.             var interv = setInterval(function(){
  3590.                 if(loaded2>=pipedindexes.length){
  3591.                     if(!loaded){
  3592.                         displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3593.                     }
  3594.                     clearInterval(interv);
  3595.                 }
  3596.             },60)
  3597.         });
  3598.     }
  3599. };
  3600. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/autocorrect","/translateto [language]","/translate [language]","/randomchat","/speech","/savedroom","/clearsavedroom","/pan","/resetpan","/style [R G B]","/maxfps","/textmode [1-7]","/followcam","/autocam","/zoom [in/out/reset]","/xray","/aimbot","/heavybot","/still","/echo [username]","/clearecho","/remove [username]","/echotext [text]","/chatw [username]","/msg [text]","/ignorepm [username]","/record [username]","/replay","/stoprecord","/loadrecording [text]","/saverecording [text]","/delrecording [text]","/volume [0-100]","/pmusers","/pollstat","/lobby","/score","/team [letter]","/mode [mode]","/scroll","/hidechat","/showchat","/notify","/stopnotify","/support","Host commands are:","/startqp","/stopqp","/pauseqp","/revqp","/next","/nextafter [seconds]","/previous","/shuffle","/instaqp","/jukebox [link]","/pausejukebox","/resetjukebox","/playjukebox","/freejoin","/recmode","/recteam","/defaultmode [mode]","/start","/balanceA [number]","/colorshift [number]","/brighten [number]","/moveA [letter]","/moveT [letter] [letter]","/balanceT [letter] [number]","/killA","/rounds [number]","/roundsperqp [number]","/disablekeys [keys]","/jointext [text]","/jointeam [letter]","/wintext [text]","/autorecord","/afkkill [number]","/ban [username]","/kill [username]","/resetpoll","/addoption [text]","/deloption [letter]","/startpoll [seconds]","/endpoll","/autokick","/autoban","/sandbox","Sandbox commands are:","/addplayer [number]","/addname [text]","/delplayer [number]","/copy [username]","Debugging commands are:","/eval [code]","/debugger","Hotkeys are:","Alt L","Alt B","Alt C","Alt I","Alt <","Alt >","Alt N","Alt V","Alt G","Alt H","Alt J","Alt W","Host hotkeys are:","Alt S","Alt P","Alt T","Alt E","Alt K","Alt M","Alt Q","Alt A","Alt D","Alt F","Alt R","Alt [","Alt ]"];
  3601.  
  3602. scope.adv_help = {"help":"Shows all command names.",
  3603.                 "?":"Shows all command names.",
  3604.                 "advhelp":"Shows a command in detail.",
  3605.                 "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  3606.                 "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  3607.                 "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  3608.                 "speech":"Turns on text to speech for the chat.",
  3609.                 "savedroom":"Displays all the rooms you have saved, you can remove individual ones from the saved rooms by clicking \"Remove\".",
  3610.                 "maxfps":"Toggles maxfps. When maxfps is on, your fps will be increased.",
  3611.                 "clearsavedroom":"Clears all the saved rooms.",
  3612.                 "echo":"Echoes a username. It copies the username's chat messages.",
  3613.                 "echotext":"Sets a message when someone who is echoed chats. \"message\" will get replaced by the person's message. \"username\" will get replaced by the person's username.",
  3614.                 "remove":"Removes username from echo list. You will not echo that username anymore.",
  3615.                 "clearecho":"Clears echo list. You will not echo anyone anymore.",
  3616.                 "chatw":"It private chats with username. Type /msg to message that username.",
  3617.                 "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  3618.                 "ignorepm":"Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
  3619.                 "pmusers":"Dispays who you can private chat with.",
  3620.                 "pollstat":"Displays the current poll and its votes.",
  3621.                 "textmode":"Changes the text font.",
  3622.                 "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  3623.                 "debugger":"Opens debugger.",
  3624.                 "style":"Change the color of your username, level, and background. For example, '/style 255 0 0' will make your username red.",
  3625.                 "translate":"Translates peoples texts to the chosen language.",
  3626.                 "translateto":"You will now speak the chosen language.",
  3627.                 "autocorrect":"Fixes spelling mistakes.",
  3628.                 "randomchat":"Spams random chat messages from the past.",
  3629.                 "lobby":"Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
  3630.                 "score":"Displays the current score while ingame. Type '/score' again to hide the score.",
  3631.                 "pan":"Toggles pan mode. Use Shift+Arrow Keys to move the camera around.",
  3632.                 "resetpan":"Resets pan.",
  3633.                 "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3634.                 "scroll":"Toggles a scrollbar in ingame chat.",
  3635.                 "followcam":"Enables follow camera. Your character will be centered on the screen.",
  3636.                 "autocam":"Zooms in/out enough for you to see everyone on the screen.",
  3637.                 "zoom":"Zooms in, out, or resets zoom.",
  3638.                 "xray":"Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3639.                 "aimbot":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3640.                 "heavybot":"Enables heavy bot. Heavy bot will heavy right before collision. Turn this off when player collision is off, because heavy bot will still function.",
  3641.                 "still":"Saves your position, and tries to reach it constantly. This is useful in parkour if you want to go afk. Use Alt+W instead, because this feature will fail when you are in chat.",
  3642.                 "lagbot":"Makes your movements very laggy. Type '/lagbot 0' to turn it off.",
  3643.                 "hidechat":"Hides ingame chat. Type '/showchat' to show it again.",
  3644.                 "showchat":"Shows ingame chat. '/hidechat' hides the chat.",
  3645.                 "notify":"You will be notified if a person types @username",
  3646.                 "stopnotify":"You will not be notified if a person types @username",
  3647.                 "support":"Displays all the people who have supported this mod.",
  3648.                 "startqp":"Starts cycling maps in your map menu.",
  3649.                 "stopqp":"Stops cycling maps in your map menu.",
  3650.                 "revqp":"Reverses the order of quickplay. '/next', '/previous' will be inverted.",
  3651.                 "pauseqp":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3652.                 "next":"Skips the map. Usable only with '/startqp'.",
  3653.                 "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  3654.                 "previous":"Goes to previous map. Usable only with '/startqp'.",
  3655.                 "shuffle":"Makes quickplay play random maps instead of in order.",
  3656.                 "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3657.                 "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  3658.                 "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  3659.                 "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  3660.                 "start":"Starts game instantly.",
  3661.                 "instaqp":"Rounds will instantly start without a countdown.",
  3662.                 "balanceA":"Balances everyone with balance number.",
  3663.                 "colorshift": "Shifts the color of the map.",
  3664.                 "brighten": "Brightens the map by the number.",
  3665.                 "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3666.                 "balanceT":"Sets everyones balance to the number. The team is 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3667.                 "killA":"Kills everyone.",
  3668.                 "jointeam":"Sets the team of anyone who joins. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3669.                 "moveT":"Sets everyone in one team to another team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3670.                 "rounds":"Sets rounds to win.",
  3671.                 "replay":"Replays the movements that were recorded",
  3672.                 "record":"Records movements of the username",
  3673.                 "delrecording":"Deletes the recording with the name.",
  3674.                 "saverecording":"Saves the recording with the name.",
  3675.                 "loadrecording":"Loads the recording with the name. Type '/replay' to replay it.",
  3676.                 "stoprecord":"Stops recording the player. Type '/saverecording [text]' to save it.",
  3677.                 "jukebox":"Sets the jukebox to a link. That link will play for everyone who has this mod.",
  3678.                 "volume":"Sets the volume of the jukebox.",
  3679.                 "pausejukebox":"If the jukebox is playing, it pauses it.",
  3680.                 "resetjukebox":"Resets the jukebox, so it starts from the very beginning.",
  3681.                 "playjukebox":"If the jukebox is paused, it plays it.",
  3682.                 "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  3683.                 "autorecord":"After a round ends, automatically records the last 15 seconds.",
  3684.                 "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  3685.                 "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  3686.                 "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  3687.                 "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  3688.                 "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  3689.                 "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  3690.                 "kill":"Kills the person ingame.",
  3691.                 "resetpoll":"Clears the poll.",
  3692.                 "addoption":"Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
  3693.                 "deloption":"Removes the option with that letter.",
  3694.                 "startpoll":"Starts a poll that lasts for at least 10 seconds. Type '/endpoll' to end it early.",
  3695.                 "endpoll":"Ends the poll early if the poll lasted for at least 10 seconds.",
  3696.                 "addplayer":"In sandbox, it adds bots.",
  3697.                 "addname":"Adds a bot with a specific name. If that name already exists, it will copy the skin of that player to the bot.",
  3698.                 "delplayer":"In sandbox, it deletes bots.",
  3699.                 "copy":"In sandbox, it makes all bots copy the username's movements.",
  3700.                 "sandbox":"Turns a normal lobby into a sandbox lobby. You cannot turn a sandbox lobby back into a normal lobby.",
  3701.                 "autokick":"Automatically kicks everyone who is not using this mod.",
  3702.                 "autoban":"Automatically bans everyone who is not using this mod.",
  3703.                 "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  3704.                 "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  3705.                 "Alt S":"Starts game instantly.",
  3706.                 "Alt T":"Toggles teams.",
  3707.                 "Alt N":"Enables follow camera. Your character will be centered on the screen.",
  3708.                 "Alt G":"Zooms in.",
  3709.                 "Alt H":"Resets zoom.",
  3710.                 "Alt J":"Zooms out.",
  3711.                 "Alt Y":"Enables xray. Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3712.                 "Alt E":"Toggles editor.",
  3713.                 "Alt K":"Exits ingame and returns to lobby.",
  3714.                 "Alt M":"Switches modes.",
  3715.                 "Alt V":"Toggles autocam. Autocam zooms in/out enough for you to see everyone on the screen.",
  3716.                 "Alt Q":"Toggles quickplay.",
  3717.                 "Alt B":"Displays the current score while ingame. Press Alt B again to hide the score.",
  3718.                 "Alt A":"Skips the map if quickplay is on.",
  3719.                 "Alt D":"Goes to previous map if quickplay is on.",
  3720.                 "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3721.                 "Alt O":"Enables heavy bot. Heavy bot will heavy right before collision. Turn this off when player collision is off, because heavy bot will still function.",
  3722.                 "Alt U":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3723.                 "Alt P":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3724.                 "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  3725.                 "Alt I":"Opens debugger.",
  3726.                 "Alt W":"Saves your position, and tries to reach it constantly. This is useful in parkour if you want to go afk.",
  3727.                 "Alt <":"Lowers ingame chat height.",
  3728.                 "Alt >":"Highers ingame chat height.",
  3729.                 "Alt [":"Toggles pan mode. Use Shift+Arrow Keys to move the camera around.",
  3730.                 "Alt ]":"Resets pan."
  3731.                  };
  3732. scope.displayadvhelp = function(command){
  3733.     displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  3734. };
  3735. scope.changemode = function(mode){
  3736.     SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  3737.     RECIEVE('42[26,"b","'+mode+'"]');
  3738. };
  3739. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  3740. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3741. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3742. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3743.  
  3744. document.getElementById('adboxverticalCurse').style["display"] = "none";
  3745. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  3746. elem.onclick=function(e){
  3747.     if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  3748.         quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3749.         if(reverseqp){
  3750.             quicki+=2;
  3751.             quicki = quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3752.         }
  3753.     }
  3754. };
  3755. scope.getCurrentFrame = function(){
  3756.     currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3757.     return currentFrame;
  3758. };
  3759. scope.urlify = function(text) {
  3760.     if(!Gdocument.getElementById('bl_Menu')){
  3761.     return text.replace(/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:;%.\-_\+~#=]{2,256}\.[\-a-z]{2,6}\b([\-a-zA-Z0-9@:;%_\+.~#?&//=]*)/ig, function(url) {
  3762.         var extratext = "";
  3763.         var matches = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/);
  3764.         if(matches){
  3765.             var button = Gdocument.createElement("a");
  3766.             button.style["color"] = "green";
  3767.             button.textContent = "Play";
  3768.             button.href = "javascript:void(0)";
  3769.             button.setAttribute("onclick",function(){
  3770.                 if(Gwindow.ishost){
  3771.                     Gwindow.SEND("42"+JSON.stringify([4,{"type":"video player","from":Gwindow.username,"url":"URL INSERT HERE","timestamp":Gwindow.Date.now()+2000,"to":[-1]}]));
  3772.                     Gwindow.displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  3773.                     Gwindow.changeJukeboxURL("URL INSERT HERE",Gwindow.Date.now()+2000);
  3774.                 }
  3775.                 else{
  3776.                     Gwindow.displayInChat("You need to be host.","#DA0808","#1EBCC1");
  3777.                 }
  3778.             });
  3779.            
  3780.             button.attributes["onclick"].nodeValue = button.attributes["onclick"].nodeValue.slice(11,-1).replaceAll("URL INSERT HERE","https://www."+matches[0]);
  3781.            
  3782.             var extratext = ' ['+button.outerHTML+']';
  3783.         }
  3784.         if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3785.         else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3786.   })}return text;
  3787. };
  3788. scope.fire = function(type,options,d = Gdocument){
  3789.      var event= document.createEvent("HTMLEvents");
  3790.      event.initEvent(type,true,false);
  3791.      for(var p in options){
  3792.          event[p]=options[p];
  3793.      }
  3794.      d.dispatchEvent(event);
  3795. };
  3796.  
  3797. scope.chat = function(message){
  3798.     SEND('42[10,{"message":'+JSON.stringify(message)+'}]');
  3799. };
  3800. scope.chat2 = function(message,enteragain=false){
  3801.     mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  3802.     mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  3803.     Gdocument.getElementById("newbonklobby_chat_input").value = message;
  3804.     Gdocument.getElementById("ingamechatinputtext").value = message;
  3805.     fire("keydown",{keyCode:13});
  3806.     if(!enteragain){
  3807.         fire("keydown",{keyCode:13});
  3808.     }
  3809.     Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  3810.     Gdocument.getElementById("ingamechatinputtext").value = mess2;
  3811. };
  3812. scope.sanitize = function(message){
  3813.     return message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;');
  3814. };
  3815. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown) {
  3816.             options = options ?? {};
  3817.             BringDown = BringDown ?? false;
  3818.             message2 = message2 ?? "";            
  3819.             LobbyColor = LobbyColor ?? "#8800FF";
  3820.             InGameColor = InGameColor ?? "#AA88FF";
  3821.             var A = Gdocument.createElement("div");
  3822.             var B = Gdocument.createElement("span");
  3823.             B.className = "newbonklobby_chat_status";
  3824.             B.style.color = LobbyColor;
  3825.             A.appendChild(B);
  3826.             B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3827.             B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3828.             var C = Gdocument.createElement("div");
  3829.             var D = Gdocument.createElement("span");
  3830.             D.style.color = InGameColor;
  3831.             C.appendChild(D);
  3832.             D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3833.             D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3834.             var a = BringDown;
  3835.             if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  3836.                 a = true;
  3837.             }
  3838.             var b = BringDown;
  3839.             if(Gdocument.getElementById("ingamechatcontent").clientHeight + Gdocument.getElementById("ingamechatcontent").scrollTop >= Gdocument.getElementById("ingamechatcontent").scrollHeight-1) {
  3840.                 b = true;
  3841.             }
  3842.             A.style["parsed"] = true;
  3843.             C.style["parsed"] = true;
  3844.             Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  3845.             Gdocument.getElementById("ingamechatcontent").appendChild(C);
  3846.             if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Gdocument.getElementById("newbonklobby_chat_content").scrollHeight;};
  3847.             if (b) { Gdocument.getElementById("ingamechatcontent").scrollTop = Gdocument.getElementById("ingamechatcontent").scrollHeight;};
  3848.             if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"]!="auto" && !Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  3849.                 chat2("");
  3850.             }
  3851. };
  3852.  
  3853. scope.lobby = function(){
  3854.     if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  3855.  
  3856.         Gdocument.getElementById("newbonklobby_editorbutton").click();
  3857.         Gdocument.getElementById("mapeditor_close").click();
  3858.         if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  3859.             Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  3860.             Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  3861.             Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  3862.             Gdocument.getElementById("pretty_top").style["z-index"]=3;
  3863.             Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  3864.             Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  3865.             Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  3866.             debuggermenu.style["z-index"] = 2;
  3867.         }
  3868.         else{
  3869.             Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3870.             Gdocument.getElementById("newbonklobby").style["display"]="none";
  3871.             Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3872.  
  3873.         }
  3874.  
  3875.     }
  3876.     else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3877.         Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3878.         Gdocument.getElementById("newbonklobby").style["display"]="none";
  3879.         Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3880.  
  3881.     }
  3882. };
  3883.  
  3884. scope.lastmessage = function(){
  3885.     if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  3886.         var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  3887.         var lm2 = "";
  3888.         for(var i = 0; i<lm.length;i++){
  3889.             lm2+="  "+lm[i].textContent.trim();
  3890.         }
  3891.         lm2 = lm2.trim();
  3892.         if(lm2.startsWith("*")){
  3893.             return lm2;
  3894.         }
  3895.     }
  3896.     if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  3897.         var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  3898.         var lm2 = "";
  3899.         for(var i = 0; i<lm.length;i++){
  3900.             lm2+="  "+lm[i].textContent.trim();
  3901.         }
  3902.         return lm2.trim();
  3903.     }
  3904.     return "";
  3905.  
  3906. };
  3907. scope.map = function(e,t=timedelay){
  3908.     if(e<0){
  3909.         displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3910.         quicki = 0;
  3911.         return;
  3912.     }
  3913.     if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3914.         displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3915.         return;
  3916.     }
  3917.  
  3918.     setTimeout(function(){if(!canceled){
  3919.                           startedinqp = true;
  3920.                           if(roundsperqp2>=roundsperqp){
  3921.                               roundsperqp2 = 0;
  3922.                           }
  3923.                           Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3924.                           Gdocument.getElementById("newbonklobby_editorbutton").click();
  3925.                           if(recmodebool && ishost){
  3926.                               var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3927.                               if(mode == "" && defaultmode!="d"){
  3928.                                       mode = defaultmode;
  3929.                               }
  3930.                               if(mode != ""){
  3931.                                   RECIEVE('42[26,"b","'+mode+'"]');
  3932.                               }
  3933.                           }
  3934.                           var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3935.                           Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3936.                           Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3937.                           if(displayblock){
  3938.                               Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3939.                           }
  3940.                           Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  3941.                           canceled = false;
  3942.                           transitioning = false;
  3943.                          },t);
  3944.  
  3945. };
  3946.  
  3947. scope.gotonextmap = function(e){
  3948.     if(e<0){
  3949.         displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3950.         quicki = 0;
  3951.         return;
  3952.     }
  3953.     if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3954.         displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3955.         return;
  3956.     }
  3957.     Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3958.     Gdocument.getElementById("newbonklobby_editorbutton").click();
  3959.     if(recmodebool && ishost){
  3960.         var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3961.         if(mode == "" && defaultmode!="d"){
  3962.                 mode = defaultmode;
  3963.         }
  3964.         if(mode != ""){
  3965.             RECIEVE('42[26,"b","'+mode+'"]');
  3966.         }
  3967.     }
  3968.     startedinqp = true;
  3969.     if(roundsperqp2>=roundsperqp){
  3970.         roundsperqp2 = 0;
  3971.     }
  3972.     var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3973.     Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3974.     Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3975.     if(displayblock){
  3976.         Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3977.     }
  3978.     Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3979.     Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  3980. };
  3981. scope.commandhandle = function(chat_val){
  3982.     if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3983.         if (chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")==username){
  3984.             displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  3985.             return "";
  3986.         }
  3987.         else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))===-1) {
  3988.  
  3989.             echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  3990.             displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is being echoed.","#DA0808","#1EBCC1");
  3991.             return "";
  3992.         }
  3993.         else{
  3994.             displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is already being echoed.","#DA0808","#1EBCC1");
  3995.             return "";
  3996.         }
  3997.     }
  3998.     else if (chat_val.substring(1,8)=="remove "  && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3999.         if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))!==-1){
  4000.             echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")),1);
  4001.             displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+" is not being echoed.","#DA0808","#1EBCC1");
  4002.             return "";
  4003.         }
  4004.         else{
  4005.             displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  4006.             return "";
  4007.         }
  4008.  
  4009.     }
  4010.     else if (chat_val.substring(1,10)=="echotext "  && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4011.         echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4012.         displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  4013.         displayInChat("Type '/echotext' to reset echotext.","#DA0808","#1EBCC1");
  4014.         return "";
  4015.  
  4016.     }
  4017.     else if (chat_val.substring(1,9)=="echotext"){
  4018.         echotext = "message";
  4019.         displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  4020.         return "";
  4021.  
  4022.     }
  4023.     else if (chat_val.substring(1,10)=="clearecho"){
  4024.         echo_list = [];
  4025.         displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  4026.         return "";
  4027.     }
  4028.     else if (chat_val.substring(1,11)=="randomchat"){
  4029.         if(randomchat == true){
  4030.             displayInChat("Random chat is now off.","#DA0808","#1EBCC1");
  4031.             randomchat = false;
  4032.         }
  4033.         else{
  4034.             displayInChat("Random chat is now on.","#DA0808","#1EBCC1");
  4035.             randomchat = true;
  4036.         }
  4037.         return "";
  4038.     }
  4039.     else if (chat_val.substring(1,12)=="autocorrect"){
  4040.         if(autocorrect == true){
  4041.             displayInChat("Autocorrect is now off.","#DA0808","#1EBCC1");
  4042.             autocorrect = false;
  4043.         }
  4044.         else{
  4045.             displayInChat("Autocorrect is now on.","#DA0808","#1EBCC1");
  4046.             autocorrect = true;
  4047.         }
  4048.         return "";
  4049.     }
  4050.     else if (chat_val.substring(1,13)=="translateto " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  4051.         var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '').toLowerCase();
  4052.         var keys = Object.keys(translatingkeys);
  4053.         if(keys.includes(text)){
  4054.             translating2 = [true,translatingkeys[text]];
  4055.             displayInChat("You will now speak the "+text+" language.","#DA0808","#1EBCC1");
  4056.         }
  4057.         else{
  4058.             displayInChat("Invalid language. Here are the current language options:","#DA0808","#1EBCC1");
  4059.             for(var i = 0;i<keys.length;i++){
  4060.                 displayInChat(keys[i],"#DA0808","#1EBCC1");
  4061.             }
  4062.         }
  4063.         return "";
  4064.     }
  4065.     else if (chat_val.substring(1,12)=="translateto"){
  4066.        translating2 = [false,""];
  4067.        displayInChat("You will not speak another language anymore.","#DA0808","#1EBCC1");
  4068.        return "";
  4069.     }
  4070.     else if (chat_val.substring(1,11)=="translate " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4071.         var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '').toLowerCase();
  4072.         var keys = Object.keys(translatingkeys);
  4073.         if(keys.includes(text)){
  4074.             translating = [true,translatingkeys[text]];
  4075.             displayInChat("Translator has been set to the "+text+" language.","#DA0808","#1EBCC1");
  4076.         }
  4077.         else{
  4078.             displayInChat("Invalid language. Here are the current language options:","#DA0808","#1EBCC1");
  4079.             for(var i = 0;i<keys.length;i++){
  4080.                 displayInChat(keys[i],"#DA0808","#1EBCC1");
  4081.             }
  4082.         }
  4083.         return "";
  4084.     }
  4085.     else if (chat_val.substring(1,10)=="translate"){
  4086.        translating = [false,""];
  4087.        displayInChat("Translator has been turned off.","#DA0808","#1EBCC1");
  4088.        return "";
  4089.     }
  4090.    
  4091.     else if (chat_val.substring(1,6)=="space"){
  4092.         if(space_flag == true){
  4093.             displayInChat("Space is now off.","#DA0808","#1EBCC1");
  4094.             space_flag = false;
  4095.         }
  4096.         else{
  4097.             displayInChat("Space is now on.","#DA0808","#1EBCC1");
  4098.             space_flag = true;
  4099.         }
  4100.         return "";
  4101.     }
  4102.     else if (chat_val.substring(1,6)=="rcaps"){
  4103.         if(rcaps_flag == true){
  4104.             displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  4105.             rcaps_flag = false;
  4106.         }
  4107.         else{
  4108.             displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  4109.             rcaps_flag = true;
  4110.         }
  4111.  
  4112.         return "";
  4113.     }
  4114.     else if (chat_val.substring(1,7)=="number"){
  4115.         if(number_flag == true){
  4116.             displayInChat("Number is now off.","#DA0808","#1EBCC1");
  4117.             number_flag = false;
  4118.         }
  4119.         else{
  4120.             displayInChat("Number is now on.","#DA0808","#1EBCC1");
  4121.             number_flag = true;
  4122.         }
  4123.  
  4124.         return "";
  4125.     }
  4126.     else if (chat_val.substring(1,8)=="reverse"){
  4127.         if(reverse_flag == true){
  4128.             displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  4129.             reverse_flag = false;
  4130.         }
  4131.         else{
  4132.             displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  4133.             reverse_flag = true;
  4134.         }
  4135.  
  4136.         return "";
  4137.     }
  4138.     else if (chat_val.substring(1,7)=="speech"){
  4139.         if(text2speech == true){
  4140.             displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  4141.             text2speech = false;
  4142.         }
  4143.         else{
  4144.             displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  4145.             text2speech = true;
  4146.         }
  4147.  
  4148.         return "";
  4149.     }
  4150.     else if (chat_val.substring(1,7)=="maxfps"){
  4151.         if(maxfps){
  4152.             displayInChat("Max FPS is now off.","#DA0808","#1EBCC1");
  4153.             maxfps = false;
  4154.         }
  4155.         else{
  4156.             displayInChat("Max FPS is now on.","#DA0808","#1EBCC1");
  4157.             maxfps = true;
  4158.         }
  4159.         return "";
  4160.     }
  4161.     else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4162.         var ev = "";
  4163.         try{
  4164.             ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  4165.         }
  4166.         catch(e){
  4167.             displayInChat(e.message,"#DA0808","#1EBCC1");
  4168.         }
  4169.         try{
  4170.             displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  4171.         }
  4172.         catch{
  4173.         }
  4174.  
  4175.         return "";
  4176.  
  4177.     }
  4178.     else if (chat_val.substring(1,10)=="textmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4179.         var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  4180.         var parsed = parseInt(text);
  4181.         if(!isNaN(parsed)){
  4182.             if(parsed<=7 && parsed>=1){
  4183.                 textmode = parsed-1;
  4184.                 displayInChat("Type '/textmode' to reset textmode.","#DA0808","#1EBCC1");
  4185.             }
  4186.             else{
  4187.                 displayInChat("Please enter a integer from 1-7 inclusive.","#DA0808","#1EBCC1");
  4188.             }
  4189.         }
  4190.         else{
  4191.             displayInChat("Please enter a integer from 1-7 inclusive.","#DA0808","#1EBCC1");
  4192.         }
  4193.         return "";
  4194.  
  4195.     }
  4196.     else if (chat_val.substring(1,9)=="textmode"){
  4197.         textmode = -1;
  4198.         displayInChat("Reset textmode.","#DA0808","#1EBCC1");
  4199.         return "";
  4200.     }
  4201.     else if (chat_val.substring(1,10)=="savedroom"){
  4202.         if(savedrooms.length == 0){
  4203.             displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  4204.             return "";
  4205.         }
  4206.         else{
  4207.             var keys = Object.keys(savedroomsdata);
  4208.             for(var i = 0;i<keys.length;i++){
  4209.                 var code = 'this.parentElement.remove();delete Gwindow.savedroomsdata["'+keys[i]+'"];Gwindow.savedrooms.splice(Gwindow.savedrooms.indexOf('+keys[i]+'),1);';
  4210.                 displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">Remove</a>'+' - ',"#DA0808","#1EBCC1",{sanitize:false},JSON.stringify(savedroomsdata[keys[i]].roomname)+" - "+savedroomsdata[keys[i]].players+"/"+savedroomsdata[keys[i]].maxplayers+" players.");
  4211.  
  4212.                 Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  4213.                 Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  4214.                
  4215.                 Laster_message = lastmessage();
  4216.             }
  4217.         }
  4218.         return "";
  4219.     }
  4220.     else if (chat_val.substring(1,15)=="clearsavedroom"){
  4221.         if(savedrooms.length == 0){
  4222.             displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  4223.             return "";
  4224.         }
  4225.         else{
  4226.             var keys = Object.keys(savedroomsdata);
  4227.             for(var i = 0;i<keys.length;i++){
  4228.                 savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])),1);
  4229.                 delete savedroomsdata[keys[i]];
  4230.                
  4231.             }
  4232.         }
  4233.         return "";
  4234.     }
  4235.     else if (chat_val.substring(1,10)=="followcam"){
  4236.         if(FollowCam == true){
  4237.             displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  4238.             FollowCam = false;
  4239.             if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4240.                 var addto = {"children":[]};
  4241.                 for(var i = 0;i<parentDraw.children.length;i++){
  4242.                     if(parentDraw.children[i].constructor.name == "e"){
  4243.                         addto = parentDraw.children[i];
  4244.                         break;
  4245.                     }
  4246.                 }
  4247.                 var canv = 0;
  4248.                 for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4249.                     if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4250.                         canv = Gdocument.getElementById("gamerenderer").children[i];
  4251.                         break;
  4252.                     }
  4253.                 }
  4254.                 var width = parseInt(canv.style["width"]);
  4255.                 var height = parseInt(canv.style["height"]);
  4256.                 parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4257.                 parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4258.                 parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4259.                 parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4260.                 if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  4261.                     pixiCircle.visible = false;
  4262.                 }
  4263.                 else{
  4264.                     pixiCircle.visible = true;
  4265.                 }
  4266.             }
  4267.         }
  4268.         else{
  4269.             displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  4270.             FollowCam = true;
  4271.         }
  4272.  
  4273.         return "";
  4274.     }
  4275.     else if (chat_val.substring(1,8)=="autocam"){
  4276.         if(autocam == true){
  4277.             displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  4278.             autocam = false
  4279.         }
  4280.         else{
  4281.             displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  4282.             autocam = true;
  4283.         }
  4284.  
  4285.         return "";
  4286.     }
  4287.     else if (chat_val.substring(1,4)=="pan"){
  4288.         if(pan_enabled == true){
  4289.             displayInChat("Pan is now off.","#DA0808","#1EBCC1");
  4290.             pan_enabled = false;
  4291.             pan = {"x":0,"y":0};
  4292.         }
  4293.         else{
  4294.             displayInChat("Pan is now on. Shift + Arrow Keys to pan.","#DA0808","#1EBCC1");
  4295.             pan_enabled = true;
  4296.         }
  4297.         return "";
  4298.     }
  4299.     else if (chat_val.substring(1,9)=="resetpan"){
  4300.         pan = {"x":0,"y":0};
  4301.         displayInChat("Reset pan.","#DA0808","#1EBCC1");
  4302.         return "";
  4303.     }
  4304.     else if (chat_val.substring(1,7)=="aimbot"){
  4305.         if(aimbot == true){
  4306.             displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  4307.             aimbot = false;
  4308.         }
  4309.         else{
  4310.             displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  4311.             aimbot = true;
  4312.             getplayerkeys();
  4313.         }
  4314.  
  4315.         return "";
  4316.     }
  4317.     else if (chat_val.substring(1,8)=="volume " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4318.         var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4319.         if(!isNaN(parseInt(text))){
  4320.             int_text = parseInt(text);
  4321.             if(int_text>=0 && int_text<=100){
  4322.                 jukeboxplayer.volume = int_text/100;
  4323.                 jukeboxplayervolume = int_text;
  4324.                 displayInChat("Jukebox volume set to: "+int_text.toString()+" percent.","#DA0808","#1EBCC1");
  4325.             }
  4326.             else{
  4327.                 displayInChat("Volume must be between 0 and 100 percent.","#DA0808","#1EBCC1");
  4328.             }
  4329.         }
  4330.         return "";
  4331.     }
  4332.     else if (chat_val.substring(1,6)=="still"){
  4333.         if(staystill == true){
  4334.             displayInChat("Still is now off.","#DA0808","#1EBCC1");
  4335.             staystill = false;
  4336.             staystillpos = [0,0];
  4337.             fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  4338.             fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  4339.         }
  4340.         else{
  4341.             if(playerids[myid].playerData?.transform){
  4342.                 displayInChat("Still is now on.","#DA0808","#1EBCC1");
  4343.                 staystill = true;
  4344.                 staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  4345.                 getplayerkeys();
  4346.                 fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  4347.                 fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  4348.             }
  4349.             else{
  4350.                 displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  4351.             }
  4352.         }
  4353.  
  4354.         return "";
  4355.     }
  4356.     else if (chat_val.substring(1,9)=="heavybot"){
  4357.         if(heavybot == true){
  4358.             displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  4359.             heavybot = false;
  4360.         }
  4361.         else{
  4362.             displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  4363.             heavybot = true;
  4364.             getplayerkeys();
  4365.         }
  4366.  
  4367.         return "";
  4368.     }
  4369.     else if (chat_val.substring(1,5)=="xray"){
  4370.         Gdocument.getElementById("pretty_top_settings").click();
  4371.         Gdocument.getElementById("settings_close").click();
  4372.         if(Gdocument.getElementById("settings_graphicsquality").value==1){
  4373.             displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  4374.             return "";
  4375.         }
  4376.  
  4377.  
  4378.         if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4379.             var addto = {"children":[]};
  4380.             for(var i = 0;i<parentDraw.children.length;i++){
  4381.                 if(parentDraw.children[i].constructor.name == "e"){
  4382.                     addto = parentDraw.children[i];
  4383.                     break;
  4384.                 }
  4385.             }
  4386.             var addto2 = {"children":[]};
  4387.             for(var i = 0;i<addto.children.length;i++){
  4388.                 if(addto.children[i].constructor.name == "e"){
  4389.                     addto2 = addto.children[i];
  4390.                     break;
  4391.                 }
  4392.             }
  4393.             var checkxray = addto2.children[0];
  4394.             var addto3 = addto2.children[0].children;
  4395.             if(addto3.length==1){
  4396.                 checkxray = checkxray.children[0];
  4397.                 addto3 = addto3[0].children;
  4398.             }
  4399.             var xrayon = false;
  4400.             if(checkxray.xrayon){
  4401.                 checkxray.xrayon = false;
  4402.                 xrayon = false;
  4403.             }
  4404.             else{
  4405.                 checkxray.xrayon = true;
  4406.                 xrayon = true;
  4407.             }
  4408.             if(xrayon){
  4409.                 displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  4410.                 for(var i = 0;i<addto3.length;i++){
  4411.                     if(addto3[i].children.length>0){
  4412.                         var ids = [];
  4413.                         var ids2 = [];
  4414.                         for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4415.                             addto3[i].children[i3].visible = false;
  4416.                             if(addto3[i].children[i3].children.length>0){
  4417.                                 for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  4418.                                     if(addto3[i].children[i3].children[i4].geometry?.id){
  4419.                                         ids.push(addto3[i].children[i3].children[i4].geometry.id);
  4420.                                     }
  4421.                                     else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  4422.                                         ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  4423.                                     }
  4424.                                 }
  4425.                             }
  4426.                         }
  4427.                         for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4428.                             if(addto3[i].children[i3].children.length==0){
  4429.                                 if(addto3[i].children[i3].geometry?.id){
  4430.                                     if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  4431.                                         addto3[i].children[i3].visible = true;
  4432.                                         addto3[i].children[i3].alpha = 0.5;
  4433.                                     }
  4434.                                 }
  4435.                                 else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  4436.                                     if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  4437.                                         addto3[i].children[i3].visible = true;
  4438.                                         addto3[i].children[i3].alpha = 0.5;
  4439.                                     }
  4440.                                 }
  4441.                             }
  4442.                         }
  4443.                     }
  4444.                 }
  4445.  
  4446.             }
  4447.             else{
  4448.                 displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  4449.                 for(var i = 0;i<addto3.length;i++){
  4450.                     for(var i2 = 0;i2<addto3[i].children.length;i2++){
  4451.                         addto3[i].children[i2].visible = true;
  4452.                         addto3[i].children[i2].alpha = 1;
  4453.                     }
  4454.                 }
  4455.             }
  4456.         }
  4457.  
  4458.         return "";
  4459.     }
  4460.     else if (chat_val.substring(1,6)=="zoom "){
  4461.         var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4462.         if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4463.             var addto = 0;
  4464.             for(var i = 0;i<parentDraw.children.length;i++){
  4465.                 if(parentDraw.children[i].constructor.name == "e"){
  4466.                     addto = parentDraw.children[i];
  4467.                     break;
  4468.                 }
  4469.             }
  4470.             var canv = 0;
  4471.             for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4472.                 if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4473.                     canv = Gdocument.getElementById("gamerenderer").children[i];
  4474.                     break;
  4475.                 }
  4476.             }
  4477.             var width = parseInt(canv.style["width"]);
  4478.             var height = parseInt(canv.style["height"]);
  4479.             if(addto){
  4480.                 if(text == "in"){
  4481.                     zoom *= 1.1;
  4482.                 }
  4483.                 else if(text == "out"){
  4484.                     zoom /= 1.1;
  4485.                 }
  4486.                 else if(text == "reset"){
  4487.                     zoom = 1;
  4488.                 }
  4489.                 else{
  4490.                     displayInChat("Options for zooming:","#DA0808","#1EBCC1");
  4491.                     displayInChat("in","#DA0808","#1EBCC1");
  4492.                     displayInChat("out","#DA0808","#1EBCC1");
  4493.                     displayInChat("reset","#DA0808","#1EBCC1");
  4494.                     return "";
  4495.                 }
  4496.                 addto.scale.x=zoom;
  4497.                 addto.scale.y=zoom;
  4498.                 parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4499.                 parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4500.                 parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4501.                 parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4502.                 if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  4503.                     pixiCircle.visible = false;
  4504.                 }
  4505.                 else{
  4506.                     pixiCircle.visible = true;
  4507.                 }
  4508.             }
  4509.         }
  4510.         return "";
  4511.     }
  4512.     else if (chat_val.substring(1,9)=="hidechat"){
  4513.         Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  4514.         return "";
  4515.     }
  4516.     else if (chat_val.substring(1,9)=="showchat"){
  4517.         Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4518.         return "";
  4519.     }
  4520.     else if (chat_val.substring(1,6)=="score"){
  4521.         var element = Gdocument.getElementById("ingamewinner_scores");
  4522.         if(element.style["opacity"]<1){
  4523.             element.style["opacity"] = 1;
  4524.             element.style["visibility"] = "visible";
  4525.         }
  4526.         else{
  4527.             element.style["opacity"] = 0;
  4528.             element.style["visibility"] = "unset";
  4529.         }
  4530.         return "";
  4531.     }
  4532.  
  4533.     else if (chat_val.substring(1,7)=="scroll"){
  4534.         if(scroll==false){
  4535.             scroll = true;
  4536.             Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  4537.             Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  4538.         }
  4539.         else if(scroll==true){
  4540.             scroll = false;
  4541.             Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  4542.             Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  4543.         }
  4544.  
  4545.         return "";
  4546.     }
  4547.  
  4548.     else if (chat_val.substring(1,7)=="chatw "){
  4549.         var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4550.  
  4551.         if(username == text){
  4552.             displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  4553.             return "";
  4554.         }
  4555.         private_chat = text;
  4556.  
  4557.         SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  4558.         request_public_key_time_stamp = Date.now();
  4559.         setTimeout(function(){if(private_chat_public_key[0]!=private_chat){displayInChat("Failed to connect to "+private_chat+".","#DA0808","#1EBCC1");private_chat = private_chat_public_key[0];}},1600);
  4560.         return "";
  4561.     }
  4562.     else if (chat_val.substring(1,8)=="lagbot " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4563.         var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4564.         if(!isNaN(parseInt(text))){
  4565.             int_text = parseInt(text);
  4566.             if(int_text == 0){
  4567.                 causelag = false;
  4568.                 causelag2 = 0;
  4569.                 displayInChat("Lagbot is now off.","#DA0808","#1EBCC1");
  4570.                 displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4571.             }
  4572.             else if(int_text>0 && int_text<=10){
  4573.                 causelag = true;
  4574.                 causelag2 = 45*int_text;
  4575.                 displayInChat("Lagbot is now on with a lag setting of "+int_text.toString()+" (~"+(45*int_text).toString()+"MS).","#DA0808","#1EBCC1");
  4576.                 displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4577.             }
  4578.             else{
  4579.                 displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4580.                 displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4581.             }
  4582.             return "";
  4583.         }
  4584.     }
  4585.     else if (chat_val.substring(1,8)=="record " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4586.         var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4587.         var keys = Object.keys(playerids);
  4588.         var recordingid2 = -1;
  4589.         for(var i = 0;i<keys.length;i++){
  4590.             if(playerids[keys[i]].userName == text){
  4591.                 recordingid2 = keys[i];
  4592.             }
  4593.         }
  4594.         if(recordingid2 == -1){
  4595.             displayInChat("Player not found. Please type a valid username.","#DA0808","#1EBCC1");
  4596.             return "";
  4597.         }
  4598.         else{
  4599.             recording = true;
  4600.             recordingid = recordingid2;
  4601.             displayInChat(playerids[recordingid].userName+" is now being recorded.","#DA0808","#1EBCC1");
  4602.             if(recordingdata.length>0){
  4603.                 displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4604.             }
  4605.             recordingdata = [];
  4606.         }
  4607.         return "";
  4608.     }
  4609.     else if (chat_val.substring(1,11)=="stoprecord"){
  4610.         if(recording){
  4611.             displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4612.             displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4613.             recording = false;
  4614.             recordingid = -1;
  4615.             recordingdata[0][1] = 0;
  4616.         }
  4617.         else{
  4618.             displayInChat("No one is being recorded.","#DA0808","#1EBCC1");
  4619.         }
  4620.         return "";
  4621.     }
  4622.     else if (chat_val.substring(1,15)=="saverecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4623.         var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4624.         if(Object.keys(recorddata).includes(text)){
  4625.             displayInChat("This recording already exists. Please use a different name or type '/delrecording "+text+"'.","#DA0808","#1EBCC1");
  4626.         }
  4627.         else if(recordingdata.length>0){
  4628.             recorddata[text] = JSON.parse(JSON.stringify(recordingdata));
  4629.             displayInChat("Recording saved as: "+text,"#DA0808","#1EBCC1");
  4630.         }
  4631.         else{
  4632.             displayInChat("There is no recording data to save. Please record data using '/record [username]'","#DA0808","#1EBCC1");
  4633.         }
  4634.         return "";
  4635.     }
  4636.     else if (chat_val.substring(1,14)=="delrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=15){
  4637.         var text = chat_val.substring(14).replace(/^\s+|\s+$/g, '');
  4638.         if(Object.keys(recorddata).includes(text)){
  4639.             displayInChat("Recording deleted.","#DA0808","#1EBCC1");
  4640.             delete recorddata[text];
  4641.         }
  4642.         else{
  4643.             displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4644.         }
  4645.         return "";
  4646.     }
  4647.     else if (chat_val.substring(1,15)=="loadrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4648.         var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4649.         if(!Object.keys(recorddata).includes(text)){
  4650.             displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4651.         }
  4652.         else{
  4653.             if(recordingdata.length>0){
  4654.                 displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4655.             }
  4656.             recordingdata = JSON.parse(JSON.stringify(recorddata[text]));
  4657.             displayInChat("Recording data is now loaded.","#DA0808","#1EBCC1");
  4658.         }
  4659.         return "";
  4660.     }
  4661.     else if (chat_val.substring(1,7)=="replay"){
  4662.         if(recording){
  4663.             displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4664.             displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4665.             recordingid = -1;
  4666.             recording = false;
  4667.             recordingdata[0][1] = 0;
  4668.         }
  4669.         replay();
  4670.         return "";
  4671.     }
  4672.     else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4673.         if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  4674.             var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  4675.             pmlastmessage = text.slice(0,400);
  4676.             ENCRYPT_MESSAGE(private_chat_public_key[1],text).then(function(e){
  4677.                 SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"message":e}]));
  4678.             });
  4679.             displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  4680.             Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  4681.             Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  4682.             Laster_message = lastmessage();
  4683.  
  4684.         }
  4685.         return "";
  4686.     }
  4687.     else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4688.         var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4689.         if(ignorepmlist.includes(text)){
  4690.             var index = ignorepmlist.indexOf(text);
  4691.             ignorepmlist.splice(index,1);
  4692.             displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4693.  
  4694.         }
  4695.         else{
  4696.             ignorepmlist.push(text);
  4697.             displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4698.         }
  4699.        
  4700.         return "";
  4701.     }
  4702.     else if (chat_val.substring(1,8)=="pmusers"){
  4703.         pmusers = [];
  4704.         SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  4705.         pmuserstimestamp = Date.now();
  4706.        
  4707.         setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  4708. }else{displayInChat("You can private chat with:","#DA0808","#1EBCC1");for(var i = 0;i<pmusers.length;i++){var code = 'Gwindow.private_chat = "'+pmusers[i]+'"; Gwindow.SEND("42"+JSON.stringify([4,{"type":"request public key","from":Gwindow.username,"to":Gwindow.private_chat}])); Gwindow.request_public_key_time_stamp = Date.now(); setTimeout(function(){if(Gwindow.private_chat_public_key[0]!=Gwindow.private_chat){Gwindow.displayInChat("Failed to connect to "+Gwindow.private_chat+".","#DA0808","#1EBCC1");Gwindow.private_chat = Gwindow.private_chat_public_key[0];}},1600);';displayInChat('<a onclick = \''+code+'\' href = "javascript:void(0);" style = "color:green">'+sanitize(pmusers[i])+'</a>',"#DA0808","#1EBCC1",{sanitize:false}); Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true; Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true; Laster_message = lastmessage(); }}},1600);
  4709.         return "";
  4710.     }
  4711.     else if (chat_val.substring(1,6)=="lobby"){
  4712.         lobby();
  4713.         return "";
  4714.     }
  4715.     else if (chat_val.substring(1,7)=="style " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4716.         var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  4717.         var text2 = text.split(" ");
  4718.         var array = [];
  4719.         for(var i = 0;i<text2.length;i++){
  4720.             var parsed = parseInt(text2[i]);
  4721.             if(!isNaN(parsed)){
  4722.                 array.push(parsed);
  4723.             }
  4724.         }
  4725.         if(array[0]+array[1]+array[2] == 0){
  4726.             array = [1,1,1];
  4727.         }
  4728.         if(array.length == 3){
  4729.             SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":array}]));
  4730.             allstyles[username] = array;
  4731.             mystyle = [...array];
  4732.             displayInChat("Set style to ("+array.toString()+"). Type '/style' to reset style.","#DA0808","#1EBCC1");
  4733.         }
  4734.         else{
  4735.             displayInChat("Please enter a valid RGB color code seperated by space. For example, white = '/style 255 255 255'. Type '/style' to reset style.","#DA0808","#1EBCC1");
  4736.         }
  4737.         return "";
  4738.     }
  4739.     else if (chat_val.substring(1,6)=="style"){
  4740.         SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":[0,0,0]}]));
  4741.         allstyles[username] = [0,0,0];
  4742.         mystyle = [0,0,0];
  4743.    
  4744.         displayInChat("Reset style.","#DA0808","#1EBCC1");
  4745.         return "";
  4746.     }
  4747.     else if (chat_val.substring(1,6)=="lobby"){
  4748.         lobby();
  4749.         return "";
  4750.     }
  4751.     else if (chat_val.substring(1,9)=="debugger"){
  4752.         if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  4753.             debuggeropen = true;
  4754.             Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  4755.             Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  4756.             Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  4757.         }
  4758.         else{
  4759.             debuggeropen = false;
  4760.             Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  4761.             Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  4762.             Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  4763.         }
  4764.         return "";
  4765.     }
  4766.     else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4767.         var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4768.         if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  4769.         else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  4770.         else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  4771.         else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  4772.         else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  4773.         else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  4774.         return "";
  4775.     }
  4776.     else if (chat_val.substring(1,7)=="notify"){
  4777.         npermissions = 1;
  4778.         return "";
  4779.     }
  4780.     else if (chat_val.substring(1,11)=="stopnotify"){
  4781.         npermissions = 0;
  4782.         return "";
  4783.     }
  4784.     else if (chat_val.substring(1,8)=="support"){
  4785.         displayInChat("Thanks everyone for helping me make this mod - LEGENDBOSS123","#0000FF","#FFFFFF");
  4786.         displayInChat("mastery3","#0000FF","#FFFFFF");
  4787.         displayInChat("UnmatchedBracket aka Left Paren","#0000FF","#FFFFFF");
  4788.         displayInChat("iNeonz","#0000FF","#FFFFFF");
  4789.         return "";
  4790.     }
  4791.     else if (chat_val.substring(1,9)=="pollstat"){
  4792.         if(pollactive[0] || pollactive2[0]){
  4793.             var count = [0,0,0,0];
  4794.             var keys = Object.keys(playerids);
  4795.             for(var i = 0;i<keys.length;i++){
  4796.                 if(ishost){
  4797.                     if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  4798.                         count[playerids[keys[i]].vote.poll]++;
  4799.                     }
  4800.                 }
  4801.                 else{
  4802.                     if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  4803.                         count[playerids[keys[i]].vote.poll]++;
  4804.                     }
  4805.                 }
  4806.             }
  4807.             for(var i = 0;i<count.length;i++){
  4808.                 if(count[i]>1){
  4809.                     displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4810.                 }
  4811.                 if(count[i]==1){
  4812.                     displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4813.                 }
  4814.             }
  4815.             if(ishost){
  4816.                 displayInChat("The poll will end in: "+((pollactive[2]-Date.now())/1000).toString()+" seconds.","#DA0808","#1EBCC1");
  4817.             }
  4818.             displayInChat("The poll is:","#DA0808","#1EBCC1");
  4819.             if(ishost){
  4820.                 for(var i = 0;i<pollactive[3].length;i++){
  4821.                     displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  4822.                 }
  4823.             }
  4824.             else{
  4825.                 for(var i = 0;i<pollactive2[2].length;i++){
  4826.                     displayInChat(letters[i]+") "+pollactive2[2][i],"#DA0808","#1EBCC1");
  4827.                 }
  4828.             }
  4829.         }
  4830.         else{
  4831.             displayInChat("No poll has been started.","#DA0808","#1EBCC1");
  4832.             if(ishost){
  4833.                 displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  4834.                 if(poll.length>0){
  4835.                     displayInChat("The poll is:","#DA0808","#1EBCC1");
  4836.                     for(var i = 0;i<poll.length;i++){
  4837.                         displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4838.                     }
  4839.                 }
  4840.             }
  4841.         }
  4842.         return "";
  4843.     }
  4844.     else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  4845.         for(var i = 0;i<help.length;i++){
  4846.             if(help[i].startsWith("/")){
  4847.                 var splitted = help[i].substring(1).split(" ");
  4848.                 var command = splitted[0];
  4849.                 var rest = "";
  4850.                 if(splitted.length>1){
  4851.                     rest = " "+splitted.slice(1).join(" ");
  4852.                 }
  4853.                 displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);  
  4854.             }
  4855.             else if(help[i].startsWith("Alt ")){
  4856.                 displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);  
  4857.             }
  4858.             else{
  4859.                 displayInChat(help[i],"#DA0808","#1EBCC1");
  4860.             }
  4861.            
  4862.  
  4863.         }
  4864.         return "";
  4865.     }
  4866.     else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4867.         var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4868.         if(typeof(adv_help[text])!='undefined'){
  4869.             displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  4870.         }
  4871.         return "";
  4872.     }
  4873.     else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4874.         var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4875.         var mode = "";
  4876.         var text2 = text;
  4877.         if(text == "arrows"){
  4878.             text2 = "Arrows";
  4879.             mode = "ar";
  4880.         }
  4881.         else if(text == "death arrows"){
  4882.             mode = "ard";
  4883.             text2 = "Death Arrows";
  4884.         }
  4885.         else if(text == "grapple"){
  4886.             mode = "sp";
  4887.             text2 = "Grapple";
  4888.         }
  4889.         else if(text == "classic"){
  4890.             mode = "b";
  4891.             text2 = "Classic";
  4892.         }
  4893.         else{
  4894.             displayInChat("Mode options:","#DA0808","#1EBCC1");
  4895.             displayInChat("classic","#DA0808","#1EBCC1");
  4896.             displayInChat("arrows","#DA0808","#1EBCC1");
  4897.             displayInChat("death arrows","#DA0808","#1EBCC1");
  4898.             displayInChat("grapple","#DA0808","#1EBCC1");
  4899.         }
  4900.         if(mode != ""){
  4901.             if(ishost){
  4902.                 SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  4903.                 RECIEVE('42[26,"b","'+mode+'"]');
  4904.                 displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  4905.             }
  4906.             else{
  4907.                 if(playerids[myid].ratelimit.mode+1000<Date.now()){
  4908.                     playerids[myid].ratelimit.mode=Date.now();
  4909.                     SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  4910.                     var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';        
  4911.                     displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  4912.  
  4913.                 }
  4914.                 else{
  4915.                     displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  4916.                 }
  4917.             }
  4918.         }
  4919.         return "";
  4920.  
  4921.     }
  4922.     else if(ishost){
  4923.         if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4924.             var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4925.             if(isNaN(text)){
  4926.                 displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4927.                 return "";
  4928.             }
  4929.             else if(text<=0){
  4930.                 displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4931.                 return "";
  4932.             }
  4933.             nextafter = text;
  4934.             displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  4935.             displayInChat("Type '/nextafter' to reset next after.","#DA0808","#1EBCC1");
  4936.             return "";
  4937.  
  4938.         }
  4939.         else if (chat_val.substring(1,10)=="nextafter"){
  4940.             nextafter = 0;
  4941.             displayInChat("Reset next after.","#DA0808","#1EBCC1");
  4942.             return "";
  4943.  
  4944.         }
  4945.         else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  4946.             roundsperqp2 = 0;
  4947.             if(shuffle){
  4948.                 var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4949.                 var available = [];
  4950.                 var availableindexes = [];
  4951.                 var notempty = false;
  4952.                 for(var i = 0; i<e.length;i++){
  4953.                     var a = false;
  4954.                     [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4955.                     available.push(a);
  4956.                     if(a){
  4957.                         availableindexes.push(i);
  4958.                         notempty = true;
  4959.                     }
  4960.                 }
  4961.                 if(notempty){
  4962.  
  4963.                     if(availableindexes.length!=1){
  4964.                         availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4965.                     }
  4966.                     quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4967.                 }
  4968.             }
  4969.             else{
  4970.                 var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4971.                 var available = [];
  4972.                 var availableindexes = [];
  4973.                 var notempty = false;
  4974.                 for(var i = 0; i<e.length;i++){
  4975.                     var a = false;
  4976.                     [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4977.                     available.push(a);
  4978.                     if(a){
  4979.                         availableindexes.push(i);
  4980.                         notempty = true;
  4981.                     }
  4982.                 }
  4983.                 if(notempty){
  4984.                     var above = [];
  4985.                     for(var i = 0;i<availableindexes.length;i++){
  4986.                         if(availableindexes[i]>quicki && !reverseqp){
  4987.                             above.push(availableindexes[i]);  
  4988.                         }
  4989.                         else if(availableindexes[i]<quicki && reverseqp){
  4990.                             above.push(availableindexes[i])
  4991.                         }
  4992.                     }
  4993.                     if(above.length>0){
  4994.                         quicki = above[0];
  4995.                         if(reverseqp){
  4996.                             quicki = above[above.length-1];
  4997.                         }
  4998.                     }
  4999.                     else{
  5000.                         quicki = availableindexes[0];
  5001.                         if(reverseqp){
  5002.                             quicki = availableindexes[availableindexes.length-1];
  5003.                         }
  5004.                     }
  5005.                 }
  5006.             }
  5007.             gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5008.             displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  5009.             return "";
  5010.  
  5011.         }
  5012.         else if (chat_val.substring(1,9)=="freejoin"){
  5013.             if(freejoin == false){
  5014.                 freejoin = true;
  5015.                 displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  5016.  
  5017.             }
  5018.             else{
  5019.                 freejoin = false;
  5020.                 displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  5021.             }
  5022.  
  5023.             return "";
  5024.  
  5025.         }
  5026.         else if (chat_val.substring(1,8)=="instaqp"){
  5027.             if(instaqp == false){
  5028.                 instaqp = true;
  5029.                 displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  5030.  
  5031.             }
  5032.             else{
  5033.                 instaqp = false;
  5034.                 displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  5035.             }
  5036.  
  5037.             return "";
  5038.  
  5039.         }
  5040.  
  5041.         else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  5042.             roundsperqp2 = 0;
  5043.             if(shuffle){
  5044.                 var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5045.                 var available = [];
  5046.                 var availableindexes = [];
  5047.                 var notempty = false;
  5048.                 for(var i = 0; i<e.length;i++){
  5049.                     var a = false;
  5050.                     [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5051.                     available.push(a);
  5052.                     if(a){
  5053.                         availableindexes.push(i);
  5054.                         notempty = true;
  5055.                     }
  5056.                 }
  5057.                 if(notempty){
  5058.  
  5059.                     if(availableindexes.length!=1){
  5060.                         availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5061.                     }
  5062.                     quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5063.                 }
  5064.             }
  5065.             else{
  5066.                 var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5067.                 var available = [];
  5068.                 var availableindexes = [];
  5069.                 var notempty = false;
  5070.                 for(var i = 0; i<e.length;i++){
  5071.                     var a = false;
  5072.                     [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5073.                     available.push(a);
  5074.                     if(a){
  5075.                         availableindexes.push(i);
  5076.                         notempty = true;
  5077.                     }
  5078.                 }
  5079.                 if(notempty){
  5080.                     var above = [];
  5081.                     for(var i = 0;i<availableindexes.length;i++){
  5082.                         if(availableindexes[i]<quicki && !reverseqp){
  5083.                             above.push(availableindexes[i]);  
  5084.                         }
  5085.                         else if(availableindexes[i]>quicki && reverseqp){
  5086.                             above.push(availableindexes[i])
  5087.                         }
  5088.                     }
  5089.                     if(above.length>0){
  5090.                         quicki = above[above.length-1];
  5091.                         if(reverseqp){
  5092.                             quicki = above[0];
  5093.                         }
  5094.                     }
  5095.                     else{
  5096.                         quicki = availableindexes[availableindexes.length-1];
  5097.                         if(reverseqp){
  5098.                             quicki = availableindexes[0];
  5099.                         }
  5100.                     }
  5101.                 }
  5102.             }
  5103.             gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5104.  
  5105.             displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  5106.             return "";
  5107.         }
  5108.         else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  5109.             if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  5110.                 Gdocument.getElementById("newbonklobby_editorbutton").click();
  5111.             }
  5112.             if(recmodebool && ishost){
  5113.                 var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  5114.                 if(mode == "" && defaultmode!="d"){
  5115.                         mode = defaultmode;
  5116.                 }
  5117.                 if(mode != ""){
  5118.                     RECIEVE('42[26,"b","'+mode+'"]');
  5119.                 }
  5120.             }
  5121.             Gdocument.getElementById("mapeditor_close").click();
  5122.             Gdocument.getElementById("newbonklobby").style["display"] = "none";
  5123.             roundsperqp2 = 0;
  5124.             Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  5125.  
  5126.             return "";
  5127.         }
  5128.  
  5129.         else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  5130.             stopquickplay = 0;
  5131.             quicki = 0;
  5132.             qppaused = false;
  5133.             displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  5134.             return "";
  5135.         }
  5136.         else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  5137.             stopquickplay = 1;
  5138.             quicki = 0;
  5139.             qppaused = false;
  5140.             displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  5141.             return "";
  5142.         }
  5143.         else if (chat_val.substring(1,8)=="pauseqp" && stopquickplay == 0){
  5144.             if(qppaused == false){
  5145.                 qppaused = true;
  5146.                 displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  5147.             }
  5148.             else{
  5149.                 qppaused = false;
  5150.                 displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  5151.             }
  5152.             return "";
  5153.         }
  5154.         else if (chat_val.substring(1,6)=="revqp" && stopquickplay == 0){
  5155.             if(reverseqp == false){
  5156.                 reverseqp = true;
  5157.                 displayInChat("Reverseqp is now on..","#DA0808","#1EBCC1");
  5158.             }
  5159.             else{
  5160.                 reverseqp = false;
  5161.                 displayInChat("Reverseqp is now off.","#DA0808","#1EBCC1");
  5162.             }
  5163.             return "";
  5164.         }
  5165.         else if (chat_val.substring(1,9)=="jukebox " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5166.             var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  5167.             SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":text,"timestamp":Date.now()+2000,"to":[-1]}]));
  5168.             displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  5169.             changeJukeboxURL(text,Date.now()+2000);
  5170.             return "";
  5171.         }
  5172.         else if (chat_val.substring(1,13)=="pausejukebox"){
  5173.             if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  5174.                 displayInChat("Jukebox is now paused.","#DA0808","#1EBCC1");
  5175.                 jukeboxplayer.pause();
  5176.                 SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":"","timestamp":Date.now(),"to":[-1]}]));
  5177.             }
  5178.             return "";
  5179.         }
  5180.         else if (chat_val.substring(1,13)=="resetjukebox"){
  5181.             if(jukeboxplayer.src!=""){
  5182.                 jukeboxplayer.currentTime = 0;
  5183.                 displayInChat("Jukebox has reset.","#DA0808","#1EBCC1");
  5184.                 changeJukeboxURL(jukeboxplayerURL,Date.now()+2000);
  5185.                 SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()+2000,"to":[-1]}]));
  5186.             }
  5187.             return "";
  5188.         }
  5189.         else if (chat_val.substring(1,12)=="playjukebox"){
  5190.             if(jukeboxplayer.src!="" && jukeboxplayer.paused){
  5191.                 changeJukeboxURL(jukeboxplayerURL,Date.now()-jukeboxplayer.currentTime*1000);
  5192.                 SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[-1]}]));
  5193.             }
  5194.             return "";
  5195.         }
  5196.         else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  5197.             banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  5198.             displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+".","#DA0808","#1EBCC1");
  5199.             return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + "'";
  5200.         }
  5201.         else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  5202.             var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5203.             var keys = Object.keys(playerids);
  5204.             var killid = undefined;
  5205.             for(var i = 0; i<keys.length; i++){
  5206.                 if(playerids[keys[i]].userName == text){
  5207.                     killid = keys[i];
  5208.                 }
  5209.             }
  5210.             if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  5211.                 currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  5212.                
  5213.                 killedids.push(killid);
  5214.                 SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  5215.                 RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  5216.             }
  5217.            
  5218.             return "";
  5219.         }
  5220.         else if (chat_val.substring(1,6)=="killA"){
  5221.             var keys = Object.keys(playerids);
  5222.             if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5223.                 currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  5224.                 SEND('42[25,{"a":{"playersLeft":['+keys.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  5225.                 RECIEVE('42[31,{"a":{"playersLeft":['+keys.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  5226.             }
  5227.            
  5228.             return "";
  5229.         }
  5230.         else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5231.             var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5232.             if(!isNaN(parseInt(text))){
  5233.                 if(parseInt(text)>=-100 && parseInt(text)<=100){
  5234.                     var keys = Object.keys(playerids);
  5235.                     for(var i = 0; i<keys.length;i++){
  5236.                         SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  5237.                         RECIEVE('42[36,'+keys[i]+','+text+']');
  5238.                     }
  5239.                 }
  5240.             }
  5241.             return "";
  5242.         }
  5243.         else if (chat_val.substring(1, 10) == "brighten " && chat_val.replace(/^\s+|\s+$/g, '').length >= 11) {
  5244.             var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5245.             if (!isNaN(parseFloat(text))) {
  5246.                 var intText = parseFloat(text);
  5247.                 var f = function(x){
  5248.                     return x * intText;
  5249.                 };
  5250.                 loadMap(changeColor(currentmap[currentmap.length-1], f,f,f));
  5251.             }
  5252.             return "";
  5253.         }
  5254.         else if (chat_val.substring(1, 12) == "colorshift " && chat_val.replace(/^\s+|\s+$/g, '').length >= 13) {
  5255.             var text = chat_val.substring(12).replace(/^\s+|\s+$/g, '');
  5256.             if (!isNaN(parseFloat(text))) {
  5257.                 var intText = parseFloat(text);
  5258.                 var seed = [Math.random()-0.5, Math.random()-0.5, Math.random()-0.5, Math.random()-0.5];
  5259.                 var f = function(x, ind){
  5260.                     return x * 1 + seed[ind] * intText;
  5261.                 };
  5262.                 loadMap(changeColor(currentmap[currentmap.length-1], f,f,f));
  5263.             }
  5264.             return "";
  5265.         }
  5266.         else if (chat_val.substring(1,10)=="balanceT " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5267.             var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5268.             var text2 = text.split(" ").filter(function(e){if(e!=""){return true;}return false;});
  5269.             if(text2.length!=2 || isNaN(parseInt(text2[1])) || !["s","r","b","y","g","f"].includes(text2[0])){
  5270.                 displayInChat("Please enter a team letter and a number to balance.","#DA0808","#1EBCC1");
  5271.                 return "";
  5272.             }
  5273.             var teamdict = {"s":0,"f":1,"r":2,"b":3,"g":4,"y":5};
  5274.             if(parseInt(text2[1])>=-100 && parseInt(text2[1])<=100){
  5275.                 var keys = Object.keys(playerids);
  5276.                 for(var i = 0; i<keys.length;i++){
  5277.                     if(playerids[keys[i]].team == teamdict[text2[0]]){
  5278.                         SEND('42[29,{"sid":'+keys[i]+',"bal":'+text2[1]+'}]');
  5279.                         RECIEVE('42[36,'+keys[i]+','+text2[1]+']');
  5280.                     }
  5281.                 }
  5282.             }
  5283.             return "";
  5284.  
  5285.         }
  5286.         else if (chat_val.substring(1,10)=="resetpoll"){
  5287.             poll = [];
  5288.             displayInChat("The poll has been reset.","#DA0808","#1EBCC1");
  5289.             return "";
  5290.         }
  5291.         else if (chat_val.substring(1,11)=="addoption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5292.             var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5293.             if(text.length>50){
  5294.                 displayInChat("Your option is greater than 50 characters.","#DA0808","#1EBCC1");
  5295.                 return "";
  5296.             }
  5297.             if(poll.includes(text)){
  5298.                 displayInChat("This option already exists.","#DA0808","#1EBCC1");
  5299.             }
  5300.             else if(poll.length>=4){
  5301.                 displayInChat("Your poll already has the max 4 amounts of options.","#DA0808","#1EBCC1");
  5302.                 displayInChat("Type '/deloption [letter]' to remove a option.","#DA0808","#1EBCC1");
  5303.                 displayInChat("The poll is:","#DA0808","#1EBCC1");
  5304.                 for(var i = 0;i<poll.length;i++){
  5305.                     displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5306.                 }
  5307.             }
  5308.             else{
  5309.                 poll.push(text);
  5310.                 displayInChat("The poll is now:","#DA0808","#1EBCC1");
  5311.                 for(var i = 0;i<poll.length;i++){
  5312.                     displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5313.                 }
  5314.             }
  5315.             return "";
  5316.         }
  5317.         else if (chat_val.substring(1,11)=="deloption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5318.             var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  5319.             if(text==-1 || text>=poll.length){
  5320.                 if(poll.length>0){
  5321.                     displayInChat("Available options are:","#DA0808","#1EBCC1");
  5322.                     for(var i = 0;i<poll.length;i++){
  5323.                         displayInChat(letters[i],"#DA0808","#1EBCC1");
  5324.                     }
  5325.                 }
  5326.                 else{
  5327.                     displayInChat("Your poll is empty.","#DA0808","#1EBCC1");
  5328.                     displayInChat("Type '/addoption [text]' to add an option.","#DA0808","#1EBCC1");
  5329.                 }
  5330.             }
  5331.             else{
  5332.                 poll.splice(text,1);
  5333.                 displayInChat("The poll is now:","#DA0808","#1EBCC1");
  5334.                 for(var i = 0;i<poll.length;i++){
  5335.                     displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5336.                 }
  5337.             }
  5338.             return "";
  5339.         }
  5340.         else if (chat_val.substring(1,11)=="startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5341.             var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  5342.             if(isNaN(text)){
  5343.                 displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5344.                 return "";
  5345.             }
  5346.             else if(text<=0){
  5347.                 displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5348.                 return "";
  5349.             }
  5350.             else if(text<10){
  5351.                 displayInChat("Your poll has to last for at least 10 seconds.","#DA0808","#1EBCC1");
  5352.                 return "";
  5353.             }
  5354.             if(pollactive[0]){
  5355.                 displayInChat("There is already an ongoing poll.","#DA0808","#1EBCC1");
  5356.                 displayInChat("Type '/endpoll' to end the poll.","#DA0808","#1EBCC1");
  5357.                 return "";
  5358.             }
  5359.             if(poll.length<2){
  5360.                 displayInChat("Your poll needs at least 2 options.","#DA0808","#1EBCC1");
  5361.                 displayInChat("Type '/addoption' to add to the poll.","#DA0808","#1EBCC1");
  5362.                 return "";
  5363.             }
  5364.            
  5365.             var now = Date.now();
  5366.             pollactive = [true,now,now+text*1000,[...poll]];
  5367.             playerids[myid].ratelimit.poll = now;
  5368.             var chatpoll = [...poll];
  5369.             chatpoll.push("Cancel vote.");
  5370.             pollactive[3].push("Cancel vote.");
  5371.             for(var i = 0;i<chatpoll.length;i++){
  5372.                 chatpoll[i] = letters[i]+") "+chatpoll[i];
  5373.             }
  5374.             chat(chatpoll.join("     "));
  5375.             setTimeout(function(){
  5376.                 if(pollactive[0]){
  5377.                     SEND("42"+JSON.stringify([4,{"type":"poll","from":username,"poll":pollactive[3]}]));
  5378.                     var keys = Object.keys(playerids);
  5379.                     for(var i = 0;i<keys.length;i++){
  5380.                         playerids[keys[i]].vote.poll = -1;
  5381.                     }
  5382.                     displayInChat("The poll will end in: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5383.                     displayInChat("Type '/endpoll' to end the poll early.","#DA0808","#1EBCC1");
  5384.                 }
  5385.             },200);
  5386.             return "";
  5387.         }
  5388.         else if (chat_val.substring(1,8)=="endpoll"){
  5389.             if(pollactive[0]){
  5390.                 if(playerids[myid].ratelimit.poll+10000>Date.now()){
  5391.                     displayInChat("Your poll has to be at least 10 seconds.","#DA0808","#1EBCC1");
  5392.                     displayInChat("There are "+((playerids[myid].ratelimit.poll+10000-Date.now())/1000).toString()+" seconds left until you can end the poll early.","#DA0808","#1EBCC1");
  5393.                     return "";
  5394.                 }
  5395.                 playerids[myid].ratelimit.poll = Date.now();
  5396.                 SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  5397.                 displayInChat("The poll ended.","#DA0808","#1EBCC1");
  5398.                 var count = [0,0,0,0];
  5399.                 var keys = Object.keys(playerids);
  5400.                 for(var i = 0;i<keys.length;i++){
  5401.                     if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  5402.                         count[playerids[keys[i]].vote.poll]++;
  5403.                     }
  5404.                     playerids[keys[i]].vote.poll = -1;
  5405.                 }
  5406.                 for(var i = 0;i<count.length;i++){
  5407.                     if(count[i]>1){
  5408.                         displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5409.                     }
  5410.                     if(count[i]==1){
  5411.                         displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5412.                     }
  5413.                 }
  5414.                 displayInChat("The poll was:","#DA0808","#1EBCC1");
  5415.                 for(var i = 0;i<pollactive[3].length;i++){
  5416.                     displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  5417.                 }
  5418.                 pollactive = [false,0,0,[]];
  5419.             }
  5420.             else{
  5421.                 displayInChat("No poll has been started","#DA0808","#1EBCC1");
  5422.                 displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  5423.             }
  5424.             return "";
  5425.         }
  5426.         else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5427.             var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  5428.             var keys = Object.keys(playerids);
  5429.             var t = -1;
  5430.             if(text == "f"){
  5431.                 t = 1;
  5432.             }
  5433.             else if(text == "b"){
  5434.                 t = 3;
  5435.             }
  5436.             else if(text == "g"){
  5437.                 t = 4;
  5438.             }
  5439.             else if(text == "r"){
  5440.                 t = 2;
  5441.             }
  5442.             else if(text == "y"){
  5443.                 t = 5;
  5444.             }
  5445.             else if(text == "s"){
  5446.                 t = 0;
  5447.             }
  5448.             if(t == -1){
  5449.                 displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5450.                 displayInChat("/moveA [letter]","#DA0808","#1EBCC1");
  5451.                 displayInChat("For example: '/moveA r' would move everyone to red team.","#DA0808","#1EBCC1");
  5452.                 return "";
  5453.             }
  5454.             for(var i = 0;i<keys.length;i++){
  5455.                 SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+t.toString()+'}]');
  5456.                 if(playerids[keys[i]].peerID!="sandbox"){
  5457.                     RECIEVE('42[18,'+keys[i].toString()+','+t.toString()+']');
  5458.                 }
  5459.             }
  5460.            
  5461.             return "";
  5462.         }
  5463.         else if (chat_val.substring(1,7)=="moveT " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5464.             var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').split(" ").filter(function(i){if(i==""){return false}else{return true}});
  5465.             if(text.length == 2){
  5466.                 var firstteam = -1;
  5467.                 var secondteam = -1;
  5468.                 for(var i = 0;i<2;i++){
  5469.                     var t = -1;
  5470.                     if(text[i] == "f"){
  5471.                         t = 1;
  5472.                     }
  5473.                     else if(text[i] == "b"){
  5474.                         t = 3;
  5475.                     }
  5476.                     else if(text[i] == "g"){
  5477.                         t = 4;
  5478.                     }
  5479.                     else if(text[i] == "r"){
  5480.                         t = 2;
  5481.                     }
  5482.                     else if(text[i] == "y"){
  5483.                         t = 5;
  5484.                     }
  5485.                     else if(text[i] == "s"){
  5486.                         t = 0;
  5487.                     }
  5488.                     if(t==-1){
  5489.                         displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5490.                         displayInChat("/moveT [letter] [letter]","#DA0808","#1EBCC1");
  5491.                         displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5492.                         return "";
  5493.                     }
  5494.                     else{
  5495.                         if(i == 0){
  5496.                             firstteam = t;
  5497.                         }
  5498.                         else{
  5499.                             secondteam = t;
  5500.                         }
  5501.                     }
  5502.                 }
  5503.                 var keys = Object.keys(playerids);
  5504.                 for(var i = 0;i<keys.length;i++){
  5505.                     if(playerids[keys[i]].team == firstteam){
  5506.                         SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+secondteam.toString()+'}]');
  5507.                         if(playerids[keys[i]].peerID!="sandbox"){
  5508.                             RECIEVE('42[18,'+keys[i].toString()+','+secondteam.toString()+']');
  5509.                         }
  5510.                     }
  5511.                 }
  5512.             }
  5513.             else{
  5514.                 displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5515.                 displayInChat("/moveT [team] [team]","#DA0808","#1EBCC1");
  5516.                 displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5517.                 return "";
  5518.             }
  5519.            
  5520.             return "";
  5521.         }
  5522.         if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5523.             var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  5524.             if(isNaN(text)){
  5525.                 displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5526.                 return "";
  5527.             }
  5528.             else if(text<=0){
  5529.                 displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5530.                 return "";
  5531.             }
  5532.             roundsperqp = text;
  5533.             roundsperqp2 = 0;
  5534.             displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  5535.             displayInChat("Type '/roundsperqp' to reset rounds per quickplay.","#DA0808","#1EBCC1");
  5536.             return "";
  5537.  
  5538.         }
  5539.         else if (chat_val.substring(1,12)=="roundsperqp"){
  5540.             roundsperqp = 1;
  5541.             roundsperqp2 = 0;
  5542.             displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  5543.             return "";
  5544.  
  5545.         }
  5546.         else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  5547.             var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  5548.             if(!isNaN(parseInt(text))){
  5549.                 text = parseInt(text).toString();
  5550.                 SEND('42[21,{"w":'+text+'}]');
  5551.                 RECIEVE('42[27,'+text+']');
  5552.             }
  5553.             return "";
  5554.  
  5555.         }
  5556.         else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5557.             var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5558.             var keys = text.split(" ");
  5559.             var disabledkeys2 = [];
  5560.             var possiblekeys = ["left","right","up","down","heavy","special"];
  5561.             for(var i = 0; i<keys.length; i++){
  5562.                 if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  5563.                     if(possiblekeys.includes(keys[i])){
  5564.                         disabledkeys2.push(keys[i]);
  5565.                     }
  5566.                     else{
  5567.                         displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  5568.                         return "";
  5569.                     }
  5570.                 }
  5571.            
  5572.             }
  5573.             disabledkeys = disabledkeys2;
  5574.             displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  5575.             displayInChat("Type '/disablekeys' to reset disabled keys.","#DA0808","#1EBCC1");
  5576.             return "";
  5577.  
  5578.         }
  5579.         else if (chat_val.substring(1,12)=="disablekeys"){
  5580.             displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  5581.             disabledkeys = [];
  5582.             return "";
  5583.  
  5584.         }
  5585.         else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5586.             jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5587.             displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  5588.             displayInChat("Type '/jointext' to reset jointext.","#DA0808","#1EBCC1");
  5589.             return "";
  5590.  
  5591.         }
  5592.         else if (chat_val.substring(1,9)=="jointext"){
  5593.             jointext = "";
  5594.             displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  5595.             return "";
  5596.  
  5597.         }
  5598.         else if (chat_val.substring(1,10)=="jointeam " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5599.             var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5600.             var keys = Object.keys(playerids);
  5601.             var t = -1;
  5602.             if(text == "f"){
  5603.                 t = 1;
  5604.                 displayInChat("Set jointeam to FFA.","#DA0808","#1EBCC1");
  5605.             }
  5606.             else if(text == "b"){
  5607.                 t = 3;
  5608.                 displayInChat("Set jointeam to blue team.","#DA0808","#1EBCC1");
  5609.             }
  5610.             else if(text == "g"){
  5611.                 t = 4;
  5612.                 displayInChat("Set jointeam to green team.","#DA0808","#1EBCC1");
  5613.             }
  5614.             else if(text == "r"){
  5615.                 t = 2;
  5616.                 displayInChat("Set jointeam to red team.","#DA0808","#1EBCC1");
  5617.             }
  5618.             else if(text == "y"){
  5619.                 t = 5;
  5620.                 displayInChat("Set jointeam to yellow team.","#DA0808","#1EBCC1");
  5621.             }
  5622.             else if(text == "s"){
  5623.                 t = 0;
  5624.                 displayInChat("Set jointeam to spectate.","#DA0808","#1EBCC1");
  5625.             }
  5626.             if(t == -1){
  5627.                 displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5628.                 displayInChat("/jointeam [letter]","#DA0808","#1EBCC1");
  5629.                 displayInChat("For example: '/jointeam r' would move every joined person to red team.","#DA0808","#1EBCC1");
  5630.                 return "";
  5631.             }
  5632.             displayInChat("Type '/jointeam' to reset jointeam.","#DA0808","#1EBCC1");
  5633.             jointeam = t;
  5634.            
  5635.             return "";
  5636.         }
  5637.         else if (chat_val.substring(1,9)=="jointeam"){
  5638.             jointeam = -1;
  5639.             displayInChat("Reset jointeam.","#DA0808","#1EBCC1");
  5640.             return "";
  5641.  
  5642.         }
  5643.         else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5644.             wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  5645.             displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  5646.             displayInChat("Type '/wintext' to reset wintext.","#DA0808","#1EBCC1");
  5647.             return "";
  5648.  
  5649.         }
  5650.         else if (chat_val.substring(1,8)=="wintext"){
  5651.             wintext = "";
  5652.             displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  5653.             return "";
  5654.  
  5655.         }
  5656.         else if (chat_val.substring(1,11)=="autorecord"){
  5657.             if(autorecord){
  5658.                 autorecord = false;
  5659.                 displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  5660.             }
  5661.             else{
  5662.                 autorecord = true;
  5663.                 displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  5664.             }            
  5665.             return "";
  5666.  
  5667.         }
  5668.         else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5669.             var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  5670.             if(!isNaN(text)){
  5671.                 if(text>0){
  5672.                     displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5673.                     displayInChat("Type '/afkkill' to reset afk kill.","#DA0808","#1EBCC1");
  5674.                     var keys = Object.keys(playerids);
  5675.                     var now = Date.now();
  5676.                     for(var i = 0;i<keys.length;i++){
  5677.                         playerids[keys[i]].lastmove = now;
  5678.                     }
  5679.                     afkkill = text;
  5680.                 }
  5681.                 else{
  5682.                      displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5683.                 }
  5684.             }
  5685.             else{
  5686.                 displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5687.             }
  5688.             return "";
  5689.  
  5690.         }
  5691.         else if (chat_val.substring(1,9)=="afkkill"){
  5692.             afkkill = -1;
  5693.             displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  5694.             return "";
  5695.  
  5696.         }
  5697.         else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5698.             var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5699.             if(text == "default"){
  5700.                 defaultmode = "";
  5701.                 displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  5702.             }
  5703.             else if(text == "arrows"){
  5704.                 defaultmode = "ar";
  5705.                 displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  5706.             }
  5707.             else if(text == "death arrows"){
  5708.                 defaultmode = "ard";
  5709.                 displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  5710.             }
  5711.             else if(text == "grapple"){
  5712.                 defaultmode = "sp";
  5713.                 displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  5714.             }
  5715.             else if(text == "classic"){
  5716.                 defaultmode = "b";
  5717.                 displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  5718.  
  5719.             }
  5720.             else{
  5721.                 displayInChat("Default mode options:","#DA0808","#1EBCC1");
  5722.                 displayInChat("default","#DA0808","#1EBCC1");
  5723.                 displayInChat("classic","#DA0808","#1EBCC1");
  5724.                 displayInChat("arrows","#DA0808","#1EBCC1");
  5725.                 displayInChat("death arrows","#DA0808","#1EBCC1");
  5726.                 displayInChat("grapple","#DA0808","#1EBCC1");
  5727.             }
  5728.             return "";
  5729.  
  5730.         }
  5731.         else if (chat_val.substring(1,8)=="recmode"){
  5732.             if(recmodebool == true){
  5733.                 recmodebool = false;
  5734.                 displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  5735.  
  5736.             }
  5737.             else{
  5738.                 recmodebool = true;
  5739.                 displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  5740.  
  5741.             }
  5742.  
  5743.             return "";
  5744.  
  5745.         }
  5746.         else if (chat_val.substring(1,8)=="recteam"){
  5747.             if(recteams == true){
  5748.                 recteams = false;
  5749.                 displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  5750.  
  5751.             }
  5752.             else{
  5753.                 recteams = true;
  5754.                 displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  5755.  
  5756.             }
  5757.             return "";
  5758.         }
  5759.         else if (chat_val.substring(1,8)=="shuffle"){
  5760.             if(shuffle == true){
  5761.                 shuffle = false;
  5762.                 displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  5763.  
  5764.             }
  5765.             else{
  5766.                 shuffle = true;
  5767.                 displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  5768.  
  5769.             }
  5770.  
  5771.             return "";
  5772.  
  5773.         }
  5774.         else if (chat_val.substring(1,9)=="autokick"){
  5775.             if(autokickban == 0){
  5776.                 displayInChat("Autokick is now on.","#DA0808","#1EBCC1");
  5777.                 autokickban = 1;
  5778.             }
  5779.             else if(autokickban == 1){
  5780.                 autokickban = 0;
  5781.                 displayInChat("Autokick is now off.","#DA0808","#1EBCC1");
  5782.             }
  5783.             else{
  5784.                 autokickban = 1;
  5785.                 displayInChat("Autokick is now on, and Autoban is now off.","#DA0808","#1EBCC1");
  5786.             }
  5787.  
  5788.             return "";
  5789.         }
  5790.         else if (chat_val.substring(1,8)=="autoban"){
  5791.             if(autokickban == 0){
  5792.                 displayInChat("Autoban is now on.","#DA0808","#1EBCC1");
  5793.                 autokickban = 2;
  5794.             }
  5795.             else if(autokickban == 2){
  5796.                 autokickban = 0;
  5797.                 displayInChat("Autoban is now off.","#DA0808","#1EBCC1");
  5798.             }
  5799.             else{
  5800.                 autokickban = 2;
  5801.                 displayInChat("Autoban is now on, and Autokick is now off.","#DA0808","#1EBCC1");
  5802.             }
  5803.  
  5804.             return "";
  5805.         }
  5806.         else if (chat_val.substring(1,8)=="sandbox"){
  5807.             if(sandboxon == false){
  5808.                 displayInChat("This room is now a sandbox room.","#DA0808","#1EBCC1");
  5809.                 sandboxon = true;
  5810.                 SEND('42[4,{"type":"sandboxon"}]');
  5811.                 var sandboxkeys = Object.keys(sandboxplayerids);
  5812.                 var packets = [];
  5813.                 for(var i = 0;i<sandboxkeys.length;i++){
  5814.                     var p = playerids[sandboxkeys[i]];
  5815.                     var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  5816.                     packets.push(packet);
  5817.                 }
  5818.                 SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5819.                 SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[-1]}]));
  5820.             }
  5821.             else{
  5822.                 displayInChat("You cannot turn a sandbox room back into a normal room.","#DA0808","#1EBCC1");
  5823.             }
  5824.  
  5825.             return "";
  5826.         }
  5827.         else if(sandboxon){
  5828.             if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5829.                 var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5830.                 if(!isNaN(parseInt(text))){
  5831.                     var text2 = parseInt(text);
  5832.                     if(text2>0){
  5833.                         for(var i = 0;i<text2;i++){
  5834.                             while(playerids[sandboxid]){
  5835.                                 sandboxid+=1;
  5836.                             }
  5837.                             var color = Math.floor(Math.random() * 16777215).toString();
  5838.                             var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",sandboxid.toString(),true,0,0,{"layers":[],"bc":color}]);
  5839.                             RECIEVE(packet);
  5840.                             SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5841.                             sandboxplayerids[sandboxid] = sandboxid.toString();
  5842.                             sandboxid+=1;
  5843.                         }
  5844.  
  5845.                     }
  5846.                 }
  5847.                 return "";
  5848.  
  5849.             }
  5850.             if (chat_val.substring(1,9)=="addname " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5851.                 var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5852.                 while(playerids[sandboxid]){
  5853.                     sandboxid+=1;
  5854.                 }
  5855.                 var keys = Object.keys(playerids);
  5856.                 var addon = "";
  5857.                 var escape = false;
  5858.                 var keysi = -1;
  5859.                 while(!escape){
  5860.                     escape = true;
  5861.                     for(var i = 0;i<keys.length;i++){
  5862.                         if(playerids[keys[i]].userName == text+addon){
  5863.                             addon+="‎";
  5864.                             var escape = false;
  5865.                         }
  5866.                         if(playerids[keys[i]].userName == text){
  5867.                             keysi = keys[i];
  5868.                         }
  5869.                     }
  5870.                 }
  5871.                 if(keysi!=-1){
  5872.                     var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,playerids[keysi].guest,playerids[keysi].level,0,playerids[keysi].avatar]);
  5873.                     RECIEVE(packet);
  5874.                     SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5875.                 }
  5876.                 else{
  5877.                     var color = Math.floor(Math.random() * 16777215).toString();
  5878.                     var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,true,0,0,{"layers":[],"bc":color}]);
  5879.                     RECIEVE(packet);
  5880.                     SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5881.                 }
  5882.                 sandboxplayerids[sandboxid] = sandboxid.toString();
  5883.                 sandboxid+=1;
  5884.                 return "";
  5885.  
  5886.             }
  5887.             else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5888.                 var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5889.                 if(!isNaN(parseInt(text))){
  5890.                     var text2 = parseInt(text);
  5891.                     if(text2>0){
  5892.                         if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  5893.                             var jsonkeys = Object.keys(sandboxplayerids).reverse();
  5894.                             var packets = [];
  5895.                             for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  5896.                                 var packet = '42[5,'+jsonkeys[i]+',0]';
  5897.                                 RECIEVE(packet);
  5898.                                 packets.push(packet);
  5899.                                 delete sandboxplayerids[jsonkeys[i]];
  5900.                             }
  5901.                             SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5902.                         }
  5903.                         else{
  5904.                             displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  5905.                         }
  5906.  
  5907.                     }
  5908.                 }
  5909.                 return "";
  5910.             }
  5911.             else if (chat_val.substring(1,6)=="copy " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  5912.                 var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5913.                 var keys = Object.keys(playerids);
  5914.                 var keys2 = Object.keys(sandboxplayerids);
  5915.                
  5916.                 var copiedperson = -1;
  5917.                 for(var i = 0;i<keys.length;i++){
  5918.                     if(playerids[keys[i]].userName==text){
  5919.                         copiedperson = keys[i];
  5920.                     }
  5921.                 }
  5922.                 if(copiedperson==-1){
  5923.                     displayInChat(playerids[copiedperson].userName + " was not found in this room.","#DA0808","#1EBCC1");
  5924.                     return "";
  5925.                 }
  5926.                 if(keys2.includes(copiedperson.toString())){
  5927.                     displayInChat("Bots cannot copy a bot.","#DA0808","#1EBCC1");
  5928.                     return "";
  5929.                 }
  5930.                 displayInChat("All bots will now copy "+playerids[copiedperson].userName+".","#DA0808","#1EBCC1");
  5931.                 displayInChat("To reset copy, type '/copy'.","#DA0808","#1EBCC1");
  5932.                 sandboxcopyme = copiedperson;
  5933.                
  5934.  
  5935.                 return "";
  5936.             }
  5937.             else if (chat_val.substring(1,5)=="copy"){
  5938.                 sandboxcopyme = -1;
  5939.                 displayInChat("Copy is now off.","#DA0808","#1EBCC1");
  5940.                 return "";
  5941.             }
  5942.            
  5943.         }
  5944.     }
  5945.     return chat_val;
  5946. };
  5947.  
  5948. scope.flag_manage = function(t){
  5949.     var text = t;
  5950.     if(autocorrect == true){
  5951.         var text2 = text.split(" ");
  5952.         for(var i = 0;i<text2.length;i++){
  5953.             text2[i] = closestWord(text2[i]);
  5954.         }
  5955.         text = text2.join(" ");
  5956.     }
  5957.     if(reverse_flag == true){
  5958.         text = text.split("").reverse().join("")
  5959.     }
  5960.     if(rcaps_flag == true){
  5961.         text = text.split('');
  5962.         for(var i = 0; i<text.length;i++){
  5963.             if(Math.floor(Math.random()*2)){
  5964.                 text[i] = text[i].toUpperCase();
  5965.             }
  5966.             else{
  5967.                 text[i] = text[i].toLowerCase();
  5968.             }
  5969.         }
  5970.         text = text.join('');
  5971.     }
  5972.     if(space_flag == true){
  5973.         text = text.split('').join(' ')
  5974.     }
  5975.     if(textmode!=-1){
  5976.         newtext = "";
  5977.         for(var i = 0;i<text.length;i++){
  5978.             if(letter_dictionary[text[i]]){
  5979.                 newtext+=letter_dictionary[text[i]][textmode];
  5980.             }
  5981.             else{
  5982.                 newtext+=text[i];
  5983.             }
  5984.         }
  5985.         text = newtext;
  5986.     }
  5987.     if(number_flag == true){
  5988.         text = text.replace(/[t|T][Oo]+/g,"2");
  5989.         text = text.replace(/[f|F][o|O][r|R]/g,"4");
  5990.         text = text.replace(/[a|A][t|T][e|E]/g,"8");
  5991.         text = text.replace(/[e|E]/g,"3");
  5992.         text = text.replace(/[a|A]/g,"4");
  5993.         text = text.replace(/[o|O]/g,"0");
  5994.         text = text.replace(/[s|S]/g,"5");
  5995.         text = text.replace(/[i|I|l|L]/g,"1");
  5996.     }
  5997.     return text;
  5998. };
  5999. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  6000.     if(e.keyCode==13){
  6001.  
  6002.         var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  6003.  
  6004.         if (chat_val!="" && chat_val[0]=="/"){
  6005.  
  6006.             Gdocument.getElementById("newbonklobby_chat_input").value = "";
  6007.             chat2(commandhandle(chat_val));
  6008.         }
  6009.         else{
  6010.             Gdocument.getElementById("newbonklobby_chat_input").value = "";
  6011.             chat2(flag_manage(chat_val));
  6012.         }
  6013.  
  6014.     }
  6015. };
  6016. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  6017.     if(e.keyCode==13){
  6018.  
  6019.         var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  6020.  
  6021.         if (chat_val!="" && chat_val[0]=="/"){
  6022.  
  6023.             Gdocument.getElementById("ingamechatinputtext").value = "";
  6024.             chat2(commandhandle(chat_val));
  6025.         }
  6026.         else{
  6027.             Gdocument.getElementById("ingamechatinputtext").value = "";
  6028.             chat2(flag_manage(chat_val));
  6029.         }
  6030.     }
  6031. };
  6032. scope.Last_message = "";
  6033. scope.Laster_message = "";
  6034. scope.new_message = false;
  6035. scope.changed_chat = false;
  6036. scope.injectedBonkCommandsScript = setInterval(timeout123,60);
  6037.  
  6038. scope.pan_enabled = false;
  6039. scope.pan = {"x":0,"y":0};
  6040. scope.pan_speed = 5;
  6041. scope.keys_being_held = {};
  6042. scope.hotkeys_keyup = function(e){
  6043.     if(keys_being_held[e.code]){
  6044.         keys_being_held[e.code] = false;
  6045.     }
  6046. };
  6047. Gdocument.onkeyup = hotkeys_keyup;
  6048. scope.hotkeys = function(e){
  6049.    
  6050.    
  6051.     var keycode = e.code;
  6052.     if(!keys_being_held[keycode]){
  6053.         keys_being_held[keycode] = true;
  6054.     }
  6055.     if(!e.altKey && e.shiftKey && !e.ctrlKey && !e.metaKey){
  6056.         if(pan_enabled && Gdocument.getElementById("gamerenderer")?.childElementCount>0){
  6057.             if(keycode == "ArrowUp"){
  6058.                 e.stopPropagation();
  6059.                 e.preventDefault();
  6060.             }
  6061.             else if(keycode == "ArrowDown"){
  6062.                 e.stopPropagation();
  6063.                 e.preventDefault();
  6064.             }
  6065.             else if(keycode == "ArrowLeft"){
  6066.                 e.stopPropagation();
  6067.                 e.preventDefault();
  6068.             }
  6069.             else if(keycode == "ArrowRight"){
  6070.                 e.stopPropagation();
  6071.                 e.preventDefault();
  6072.             }
  6073.         }
  6074.     }
  6075.  
  6076.     if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  6077.         if(keycode == "Period"){
  6078.             if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  6079.                 chatheight+=5;
  6080.                 if(chatheight>600){chatheight = 600;}
  6081.                 Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6082.                 Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  6083.                 Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  6084.             }
  6085.             e.preventDefault();
  6086.         }
  6087.         if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6088.             if(keycode == "KeyG"){
  6089.                 var addto = 0;
  6090.                 for(var i = 0;i<parentDraw.children.length;i++){
  6091.                     if(parentDraw.children[i].constructor.name == "e"){
  6092.                         addto = parentDraw.children[i];
  6093.                         break;
  6094.                     }
  6095.                 }
  6096.                 var canv = 0;
  6097.                 for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  6098.                     if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  6099.                         canv = Gdocument.getElementById("gamerenderer").children[i];
  6100.                         break;
  6101.                     }
  6102.                 }
  6103.                 var width = parseInt(canv.style["width"]);
  6104.                 var height = parseInt(canv.style["height"]);
  6105.                 if(addto){
  6106.                     zoom *= 1.1;
  6107.                 }
  6108.                 addto.scale.x = zoom;
  6109.                 addto.scale.y = zoom;
  6110.                 parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  6111.                 parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  6112.                 parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  6113.                 parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  6114.                 if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  6115.                     pixiCircle.visible = false;
  6116.                 }
  6117.                 else{
  6118.                     pixiCircle.visible = true;
  6119.                 }
  6120.                 e.preventDefault();
  6121.             }
  6122.             if(keycode == "KeyH"){
  6123.                 var addto = 0;
  6124.                 for(var i = 0;i<parentDraw.children.length;i++){
  6125.                     if(parentDraw.children[i].constructor.name == "e"){
  6126.                         addto = parentDraw.children[i];
  6127.                         break;
  6128.                     }
  6129.                 }
  6130.                 var canv = 0;
  6131.                 for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  6132.                     if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  6133.                         canv = Gdocument.getElementById("gamerenderer").children[i];
  6134.                         break;
  6135.                     }
  6136.                 }
  6137.                 var width = parseInt(canv.style["width"]);
  6138.                 var height = parseInt(canv.style["height"]);
  6139.                 if(addto){
  6140.                     zoom = 1;
  6141.                 }
  6142.                 addto.scale.x = zoom;
  6143.                 addto.scale.y = zoom;
  6144.                 parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  6145.                 parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  6146.                 parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  6147.                 parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  6148.                 if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  6149.                     pixiCircle.visible = false;
  6150.                 }
  6151.                 else{
  6152.                     pixiCircle.visible = true;
  6153.                 }
  6154.                 e.preventDefault();
  6155.             }
  6156.             if(keycode == "KeyJ"){
  6157.                 var addto = 0;
  6158.                 for(var i = 0;i<parentDraw.children.length;i++){
  6159.                     if(parentDraw.children[i].constructor.name == "e"){
  6160.                         addto = parentDraw.children[i];
  6161.                         break;
  6162.                     }
  6163.                 }
  6164.                 var canv = 0;
  6165.                 for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  6166.                     if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  6167.                         canv = Gdocument.getElementById("gamerenderer").children[i];
  6168.                         break;
  6169.                     }
  6170.                 }
  6171.                 var width = parseInt(canv.style["width"]);
  6172.                 var height = parseInt(canv.style["height"]);
  6173.                 if(addto){
  6174.                     zoom /= 1.1;
  6175.                 }
  6176.                 addto.scale.x = zoom;
  6177.                 addto.scale.y = zoom;
  6178.                 parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  6179.                 parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  6180.                 parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  6181.                 parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  6182.                 if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  6183.                     pixiCircle.visible = false;
  6184.                 }
  6185.                 else{
  6186.                     pixiCircle.visible = true;
  6187.                 }
  6188.                 e.preventDefault();
  6189.             }
  6190.         }
  6191.         if(keycode == "Comma"){
  6192.             if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  6193.                 chatheight-=5;
  6194.                 if(chatheight<100){chatheight = 100;}
  6195.                 Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6196.                 Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  6197.                 Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  6198.             }
  6199.             e.preventDefault();
  6200.         }
  6201.     }
  6202.     if(e.repeat){return;}
  6203.    
  6204.     if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  6205.         if(ishost){
  6206.             if(keycode == "KeyE"){
  6207.                 if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  6208.                     Gdocument.getElementById("newbonklobby_editorbutton").click();
  6209.                 }
  6210.                 else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  6211.                     Gdocument.getElementById("mapeditor_close").click();
  6212.                 }
  6213.                 e.preventDefault();
  6214.  
  6215.             }
  6216.             else if(keycode == "KeyT"){
  6217.                 Gdocument.getElementById("newbonklobby_teamsbutton").click();
  6218.                 e.preventDefault();
  6219.             }
  6220.             else if(keycode == "KeyM"){
  6221.                 Gdocument.getElementById("newbonklobby_modebutton").click();
  6222.                 e.preventDefault();
  6223.             }
  6224.             else if(keycode == "KeyK"){
  6225.                 if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6226.                     Gdocument.getElementById("pretty_top_exit").click();
  6227.                 }
  6228.                 e.preventDefault();
  6229.             }
  6230.             else if(keycode == "KeyS"){
  6231.                 if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  6232.                     Gdocument.getElementById("newbonklobby_editorbutton").click();
  6233.                 }
  6234.                 if(recmodebool && ishost){
  6235.                     var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  6236.                     if(mode == "" && defaultmode!="d"){
  6237.                             mode = defaultmode;
  6238.                     }
  6239.                     if(mode != ""){
  6240.                         RECIEVE('42[26,"b","'+mode+'"]');
  6241.                     }
  6242.                 }
  6243.                 Gdocument.getElementById("mapeditor_close").click();
  6244.                 Gdocument.getElementById("newbonklobby").style["display"] = "none";
  6245.                 roundsperqp2 = 0;
  6246.                 Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  6247.                 e.preventDefault();
  6248.             }
  6249.             else if(keycode == "KeyD"){
  6250.                 roundsperqp2 = 0;
  6251.                 if(stopquickplay == 0){
  6252.                     if(shuffle){
  6253.                         var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6254.                         var available = [];
  6255.                         var availableindexes = [];
  6256.                         var notempty = false;
  6257.                         for(var i = 0; i<e2.length;i++){
  6258.                             var a = false;
  6259.                             [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6260.                             available.push(a);
  6261.                             if(a){
  6262.                                 availableindexes.push(i);
  6263.                                 notempty = true;
  6264.                             }
  6265.                         }
  6266.                         if(notempty){
  6267.  
  6268.                             if(availableindexes.length!=1){
  6269.                                 availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6270.                             }
  6271.                             quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6272.                         }
  6273.                     }
  6274.                     else{
  6275.                         var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6276.                         var available = [];
  6277.                         var availableindexes = [];
  6278.                         var notempty = false;
  6279.                         for(var i = 0; i<e2.length;i++){
  6280.                             var a = false;
  6281.                             [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6282.                             available.push(a);
  6283.                             if(a){
  6284.                                 availableindexes.push(i);
  6285.                                 notempty = true;
  6286.                             }
  6287.                         }
  6288.                         if(notempty){
  6289.                             var above = [];
  6290.                             for(var i = 0;i<availableindexes.length;i++){
  6291.                                 if(availableindexes[i]>quicki && !reverseqp){
  6292.                                     above.push(availableindexes[i]);  
  6293.                                 }
  6294.                                 else if(availableindexes[i]<quicki && reverseqp){
  6295.                                     above.push(availableindexes[i])
  6296.                                 }
  6297.                             }
  6298.                             if(above.length>0){
  6299.                                 quicki = above[0];
  6300.                                 if(reverseqp){
  6301.                                     quicki = above[above.length-1];
  6302.                                 }
  6303.                             }
  6304.                             else{
  6305.                                 quicki = availableindexes[0];
  6306.                                 if(reverseqp){
  6307.                                     quicki = availableindexes[availableindexes.length-1];
  6308.                                 }
  6309.                             }
  6310.                         }
  6311.                     }
  6312.                     gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6313.                 }
  6314.                 e.preventDefault();
  6315.             }
  6316.             else if(keycode == "KeyA"){
  6317.                 if(stopquickplay == 0){
  6318.                     roundsperqp2 = 0;
  6319.                     if(shuffle){
  6320.                         var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6321.                         var available = [];
  6322.                         var availableindexes = [];
  6323.                         var notempty = false;
  6324.                         for(var i = 0; i<e2.length;i++){
  6325.                             var a = false;
  6326.                             [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6327.                             available.push(a);
  6328.                             if(a){
  6329.                                 availableindexes.push(i);
  6330.                                 notempty = true;
  6331.                             }
  6332.                         }
  6333.                         if(notempty){
  6334.  
  6335.                             if(availableindexes.length!=1){
  6336.                                 availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6337.                             }
  6338.                             quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6339.                         }
  6340.                     }
  6341.                     else{
  6342.                         var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6343.                         var available = [];
  6344.                         var availableindexes = [];
  6345.                         var notempty = false;
  6346.                         for(var i = 0; i<e2.length;i++){
  6347.                             var a = false;
  6348.                             [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6349.                             available.push(a);
  6350.                             if(a){
  6351.                                 availableindexes.push(i);
  6352.                                 notempty = true;
  6353.                             }
  6354.                         }
  6355.                         if(notempty){
  6356.                             var above = [];
  6357.                             for(var i = 0;i<availableindexes.length;i++){
  6358.                                 if(availableindexes[i]<quicki && !reverseqp){
  6359.                                     above.push(availableindexes[i]);  
  6360.                                 }
  6361.                                 else if(availableindexes[i]>quicki && reverseqp){
  6362.                                     above.push(availableindexes[i])
  6363.                                 }
  6364.                             }
  6365.                             if(above.length>0){
  6366.                                 quicki = above[above.length-1];
  6367.                                 if(reverseqp){
  6368.                                     quicki = above[0];
  6369.                                 }
  6370.                             }
  6371.                             else{
  6372.                                 quicki = availableindexes[availableindexes.length-1];
  6373.                                 if(reverseqp){
  6374.                                     quicki = availableindexes[0];
  6375.                                 }
  6376.                             }
  6377.                         }
  6378.                     }
  6379.                     gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6380.                 }
  6381.                 e.preventDefault();
  6382.             }
  6383.             else if(keycode == "KeyQ"){
  6384.                 if(stopquickplay == 1){
  6385.                     stopquickplay = 0;
  6386.                     quicki = 0;
  6387.                     qppaused = false;
  6388.                     displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  6389.                 }
  6390.                 else{
  6391.                     stopquickplay = 1;
  6392.                     quicki = 0;
  6393.                     qppaused = false;
  6394.                     displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  6395.                 }
  6396.                 e.preventDefault();
  6397.             }
  6398.             else if(keycode == "KeyP" && stopquickplay==0){
  6399.                 if(qppaused == true){
  6400.                     qppaused = false;
  6401.                     displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  6402.                 }
  6403.                 else{
  6404.                     qppaused = true;
  6405.                     displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  6406.                 }
  6407.                 e.preventDefault();
  6408.             }
  6409.             else if(keycode == "KeyR"){
  6410.                 if(recmodebool == true){
  6411.                     recmodebool = false;
  6412.                     displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  6413.  
  6414.                 }
  6415.                 else{
  6416.                     recmodebool = true;
  6417.                     displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  6418.  
  6419.                 }
  6420.             }
  6421.             else if(keycode == "KeyF"){
  6422.                 if(freejoin == false){
  6423.                     freejoin = true;
  6424.                     displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  6425.  
  6426.                 }
  6427.                 else{
  6428.                     freejoin = false;
  6429.                     displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  6430.                 }
  6431.                 e.preventDefault();
  6432.             }
  6433.            
  6434.         }
  6435.         else{
  6436.             if(keycode == "KeyE"){
  6437.                 e.preventDefault();
  6438.             }
  6439.             else if(keycode == "KeyT"){
  6440.                 e.preventDefault();
  6441.             }
  6442.             else if(keycode == "KeyM"){
  6443.                 e.preventDefault();
  6444.             }
  6445.             else if(keycode == "KeyK"){
  6446.                 e.preventDefault();
  6447.             }
  6448.             else if(keycode == "KeyS"){
  6449.                 e.preventDefault();
  6450.             }
  6451.             else if(keycode == "KeyD"){
  6452.                 e.preventDefault();
  6453.             }
  6454.             else if(keycode == "KeyA"){
  6455.                 e.preventDefault();
  6456.             }
  6457.             else if(keycode == "KeyQ"){
  6458.                 e.preventDefault();
  6459.             }
  6460.             else if(keycode == "KeyP"){
  6461.                 e.preventDefault();
  6462.             }
  6463.             else if(keycode == "KeyF"){
  6464.                 e.preventDefault();
  6465.             }
  6466.             else if(keycode == "KeyR"){
  6467.                 e.preventDefault();
  6468.             }
  6469.  
  6470.         }
  6471.        
  6472.         if(keycode == "KeyL"){
  6473.             lobby();
  6474.             e.preventDefault();
  6475.         }
  6476.         if(keycode == "KeyC"){
  6477.             if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6478.                 if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  6479.                     Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6480.                 }
  6481.                 else{
  6482.                     Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  6483.                 }
  6484.             }
  6485.             e.preventDefault();
  6486.         }
  6487.         if(keycode == "KeyI"){
  6488.             if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  6489.                 debuggeropen = true;
  6490.                 Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  6491.                 Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  6492.                 Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  6493.             }
  6494.             else{
  6495.                 debuggeropen = false;
  6496.                 Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  6497.                 Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  6498.                 Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  6499.             }
  6500.             e.preventDefault();
  6501.         }
  6502.         if(keycode == "KeyB"){
  6503.             var element = Gdocument.getElementById("ingamewinner_scores");
  6504.             if(element.style["opacity"]<1){
  6505.                 element.style["opacity"] = 1;
  6506.                 element.style["visibility"] = "visible";
  6507.             }
  6508.             else{
  6509.                 element.style["opacity"] = 0;
  6510.                 element.style["visibility"] = "unset";
  6511.             }
  6512.             e.preventDefault();
  6513.         }
  6514.         if(keycode == "KeyY"){
  6515.             Gdocument.getElementById("pretty_top_settings").click();
  6516.             Gdocument.getElementById("settings_close").click();
  6517.             if(Gdocument.getElementById("settings_graphicsquality").value==1){
  6518.                 displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  6519.                 return "";
  6520.             }
  6521.  
  6522.  
  6523.             if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6524.                 var addto = {"children":[]};
  6525.                 for(var i = 0;i<parentDraw.children.length;i++){
  6526.                     if(parentDraw.children[i].constructor.name == "e"){
  6527.                         addto = parentDraw.children[i];
  6528.                         break;
  6529.                     }
  6530.                 }
  6531.                 var addto2 = {"children":[]};
  6532.                 for(var i = 0;i<addto.children.length;i++){
  6533.                     if(addto.children[i].constructor.name == "e"){
  6534.                         addto2 = addto.children[i];
  6535.                         break;
  6536.                     }
  6537.                 }
  6538.                 var checkxray = addto2.children[0];
  6539.                 var addto3 = addto2.children[0].children;
  6540.                 if(addto3.length==1){
  6541.                     checkxray = checkxray.children[0];
  6542.                     addto3 = addto3[0].children;
  6543.                 }
  6544.                 var xrayon = false;
  6545.                 if(checkxray.xrayon){
  6546.                     checkxray.xrayon = false;
  6547.                     xrayon = false;
  6548.                 }
  6549.                 else{
  6550.                     checkxray.xrayon = true;
  6551.                     xrayon = true;
  6552.                 }
  6553.                 if(xrayon){
  6554.                     displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  6555.                     for(var i = 0;i<addto3.length;i++){
  6556.                         if(addto3[i].children.length>0){
  6557.                             var ids = [];
  6558.                             var ids2 = [];
  6559.                             for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6560.                                 addto3[i].children[i3].visible = false;
  6561.                                 if(addto3[i].children[i3].children.length>0){
  6562.                                     for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  6563.                                         if(addto3[i].children[i3].children[i4].geometry?.id){
  6564.                                             ids.push(addto3[i].children[i3].children[i4].geometry.id);
  6565.                                         }
  6566.                                         else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  6567.                                             ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  6568.                                         }
  6569.                                     }
  6570.                                 }
  6571.                             }
  6572.                             for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6573.                                 if(addto3[i].children[i3].children.length==0){
  6574.                                     if(addto3[i].children[i3].geometry?.id){
  6575.                                         if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  6576.                                             addto3[i].children[i3].visible = true;
  6577.                                             addto3[i].children[i3].alpha = 0.5;
  6578.                                         }
  6579.                                     }
  6580.                                     else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  6581.                                         if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  6582.                                             addto3[i].children[i3].visible = true;
  6583.                                             addto3[i].children[i3].alpha = 0.5;
  6584.                                         }
  6585.                                     }
  6586.                                 }
  6587.                             }
  6588.                         }
  6589.                     }
  6590.  
  6591.                 }
  6592.                 else{
  6593.                     displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  6594.                     for(var i = 0;i<addto3.length;i++){
  6595.                         for(var i2 = 0;i2<addto3[i].children.length;i2++){
  6596.                             addto3[i].children[i2].visible = true;
  6597.                             addto3[i].children[i2].alpha = 1;
  6598.                         }
  6599.                     }
  6600.                 }
  6601.             }
  6602.             e.preventDefault();
  6603.         }
  6604.         if(keycode == "KeyN"){
  6605.             if(FollowCam == true){
  6606.                 displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  6607.                 FollowCam = false;
  6608.                 if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6609.                     var addto = {"children":[]};
  6610.                     for(var i = 0;i<parentDraw.children.length;i++){
  6611.                         if(parentDraw.children[i].constructor.name == "e"){
  6612.                             addto = parentDraw.children[i];
  6613.                             break;
  6614.                         }
  6615.                     }
  6616.                     var canv = 0;
  6617.                     for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  6618.                         if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  6619.                             canv = Gdocument.getElementById("gamerenderer").children[i];
  6620.                             break;
  6621.                         }
  6622.                     }
  6623.                     var width = parseInt(canv.style["width"]);
  6624.                     var height = parseInt(canv.style["height"]);
  6625.                     parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  6626.                     parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  6627.                     parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  6628.                     parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  6629.                     if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  6630.                         pixiCircle.visible = false;
  6631.                     }
  6632.                     else{
  6633.                         pixiCircle.visible = true;
  6634.                     }
  6635.                 }
  6636.             }
  6637.             else{
  6638.                 displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  6639.                 FollowCam = true;
  6640.             }
  6641.             e.preventDefault();
  6642.         }
  6643.         if(keycode == "KeyV"){
  6644.             if(autocam == true){
  6645.                 displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  6646.                 autocam = false
  6647.             }
  6648.             else{
  6649.                 displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  6650.                 autocam = true;
  6651.             }
  6652.             e.preventDefault();
  6653.         }
  6654.         if (keycode == "BracketLeft"){
  6655.             if(pan_enabled == true){
  6656.                 displayInChat("Pan is now off.","#DA0808","#1EBCC1");
  6657.                 pan = {"x":0,"y":0};
  6658.                 pan_enabled = false;
  6659.             }
  6660.             else{
  6661.                 displayInChat("Pan is now on. Shift + Arrow Keys to pan.","#DA0808","#1EBCC1");
  6662.                 pan_enabled = true;
  6663.             }
  6664.             return "";
  6665.         }
  6666.         if (keycode == "BracketRight"){
  6667.             pan = {"x":0,"y":0};
  6668.             displayInChat("Reset pan.","#DA0808","#1EBCC1");
  6669.             return "";
  6670.         }
  6671.         if(keycode == "KeyO"){
  6672.                 if(heavybot == true){
  6673.                 displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  6674.                 heavybot = false;
  6675.             }
  6676.             else{
  6677.                 displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  6678.                 heavybot = true;
  6679.                 getplayerkeys();
  6680.             }
  6681.             e.preventDefault();
  6682.         }
  6683.         if(keycode == "KeyU"){
  6684.             if(aimbot == true){
  6685.                 displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  6686.                 aimbot = false;
  6687.             }
  6688.             else{
  6689.                 displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  6690.                 aimbot = true;
  6691.                 getplayerkeys();
  6692.             }
  6693.             e.preventDefault();
  6694.         }
  6695.         if(keycode == "KeyW"){
  6696.             if(staystill == true){
  6697.                 displayInChat("Still is now off.","#DA0808","#1EBCC1");
  6698.                 staystill = false;
  6699.                 staystillpos = [0,0];
  6700.                 fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6701.                 fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6702.             }
  6703.             else{
  6704.                 if(playerids[myid].playerData?.transform){
  6705.                     displayInChat("Still is now on.","#DA0808","#1EBCC1");
  6706.                     staystill = true;
  6707.                     staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  6708.                     getplayerkeys();
  6709.                     fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6710.                     fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6711.                 }
  6712.                 else{
  6713.                     displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  6714.                 }
  6715.             }
  6716.             e.preventDefault();
  6717.         }
  6718.        
  6719.        
  6720.     }
  6721.     if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  6722.         if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  6723.             if(Gdocument.getElementById("newbonklobby").style["display"]=="block" && Gdocument.getElementById("newbonklobby_chat_input").value == ""  && Gdocument.getElementById("maploadwindowcontainer").style["display"]!="block" && Gdocument.getElementById("newbonklobby_chat_input").style["display"]==""){
  6724.                 Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  6725.                 if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  6726.                     fire("keydown",{keyCode:13});
  6727.                 }
  6728.                 else{
  6729.                     Gdocument.getElementById("newbonklobby_chat_input").focus();
  6730.                 }
  6731.                 e.preventDefault();
  6732.  
  6733.             }
  6734.             else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  6735.                 Gdocument.getElementById("ingamechatinputtext").value = "/";
  6736.                 if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  6737.                     fire("keydown",{keyCode:13});
  6738.                 }
  6739.                 else{
  6740.                     Gdocument.getElementById("ingamechatinputtext").focus();
  6741.                 }
  6742.                 e.preventDefault();
  6743.  
  6744.             }
  6745.            
  6746.         }
  6747.     }
  6748. };
  6749.  
  6750. Gdocument.onkeydown = hotkeys;
  6751.  
  6752. Gwindow.addEventListener('resize',function(e){
  6753.     debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  6754.     debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  6755.     scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  6756.     scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  6757.     logmenu.style["width"] = width.toString()+"px";
  6758.     logmenu.style["height"] = height.toString()+"px";
  6759.     logmenutopleft.style["width"] = (width/2).toString()+"px";
  6760.     logmenutopright.style["width"] = (width/2).toString()+"px";
  6761.     logmenutopright.style["left"] = (width/2).toString()+"px";
  6762.     debuggerinput.style["width"] = width.toString()+"px";
  6763.     debuggerinput.style["top"] = (height+90).toString()+"px";
  6764.     debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  6765.     debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  6766.     debuggereval.style["width"] = (width-150).toString()+"px";
  6767.     debuggereval.style["top"] = (height+120).toString()+"px";},true);
  6768.  
  6769.  
  6770. function timeout123() {
  6771.     updateWssLog();
  6772.     EVENTLOOPFUNCTION();
  6773.     var now = Date.now();
  6774.     var keys = Object.keys(playerids);
  6775.     if(getroomslastcheck+3000<now){
  6776.         getroomslastcheck = now;
  6777.         if(inroom && savedrooms.length>0){
  6778.             Gdocument.getElementById("roomlistrefreshbutton").click();
  6779.         }
  6780.     }
  6781.     var namelist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  6782.     for(var i = 0;i<namelist.length;i++){
  6783.         var level = 0;
  6784.         var levelelement = 0;
  6785.         var pingelement = 0;
  6786.         var avatarelement = 0;
  6787.         var children = namelist[i].parentElement.children;
  6788.         for(var i2 = 0;i2<children.length;i2++){
  6789.             if(children[i2].className == "newbonklobby_playerentry_level"){
  6790.                 levelelement = children[i2];
  6791.                 level = parseInt(children[i2].textContent.slice(6));
  6792.             }
  6793.             else if(children[i2].className == "newbonklobby_playerentry_pingtext"){
  6794.                 pingelement = children[i2];
  6795.             }
  6796.             else if(children[i2].className == "newbonklobby_playerentry_avatar"){
  6797.                 avatarelement = children[i2];
  6798.             }
  6799.         }
  6800.         var isadmin = [false,0];
  6801.         for(var i3 = 0;i3<admins.length;i3++){
  6802.             if(admins[i3][0] == namelist[i].textContent){
  6803.                 isadmin = [true,i3];
  6804.                 break;
  6805.             }
  6806.         }
  6807.         if(level){
  6808.             if(isadmin[0]){
  6809.                 namelist[i].style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6810.                 if(isadmin[1]<=3){
  6811.                    
  6812.                    
  6813.                     var rotatevalue = 0;
  6814.                     if(admins[isadmin[1]][1][3]<90){
  6815.                         rotatevalue = admins[isadmin[1]][1][3]/2;
  6816.                     }
  6817.                     else if(admins[isadmin[1]][1][3]<270){
  6818.                         rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  6819.                     }
  6820.                     else if(admins[isadmin[1]][1][3]<360){
  6821.                         rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  6822.                     }
  6823.                     namelist[i].parentElement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6824.                     namelist[i].parentElement.style["font-size"] = "17px";
  6825.                     namelist[i].parentElement.style["background"] = "rgb("+[255-admins[isadmin[1]][1][0],255-admins[isadmin[1]][1][1],255-admins[isadmin[1]][1][2]].toString()+")";
  6826.                     if(levelelement){
  6827.                         levelelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6828.                     }
  6829.                     if(pingelement){
  6830.                         pingelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6831.                     }
  6832.                     if(avatarelement){
  6833.                         avatarelement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6834.                     }
  6835.                 }
  6836.                
  6837.             }
  6838.         }
  6839.         var stylekeys = Object.keys(allstyles);
  6840.         for(var i3 = 0;i3<stylekeys.length;i3++){
  6841.             if(stylekeys[i3] == namelist[i].textContent){
  6842.                 if(namelist[i].style["color"]!="rgb("+allstyles[stylekeys[i3]].toString()+")" && (allstyles[stylekeys[i3]][0]+allstyles[stylekeys[i3]][1]+allstyles[stylekeys[i3]][2]!=0 || !isadmin[0])){
  6843.                     var rgbvalue = [allstyles[stylekeys[i3]][0],allstyles[stylekeys[i3]][1],allstyles[stylekeys[i3]][2]];
  6844.                     namelist[i].style["color"] = "rgb("+rgbvalue.toString()+")";
  6845.                     if(!isadmin[0]){
  6846.                         var n = 255;
  6847.                         namelist[i].parentElement.style["background"] = "rgb("+[(203+rgbvalue[0])%n,(212+rgbvalue[1])%n,(215+rgbvalue[2])%n].toString()+")";
  6848.                     }
  6849.                     if(levelelement){
  6850.                         levelelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6851.                     }
  6852.                     if(pingelement){
  6853.                         pingelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6854.                     }
  6855.                 }
  6856.             }
  6857.         }
  6858.     }
  6859.     for(var i3 = 0;i3<admins.length;i3++){
  6860.         if(admins[i3][1][0]==0 && admins[i3][1][1]==0 && admins[i3][1][2]==0){
  6861.             admins[i3][1][2] = 180;
  6862.             admins[i3][1][1] = 0;
  6863.             admins[i3][1][0] = 0;
  6864.         }
  6865.         var rate = 5;
  6866.         var lowest = 0;
  6867.         var number = 360;
  6868.         admins[i3][1][3] = (admins[i3][1][3]%number+4+number)%number;
  6869.        
  6870.         if(admins[i3][1][0]>lowest && admins[i3][1][1] == lowest){
  6871.             admins[i3][1][0]-=rate;
  6872.             admins[i3][1][2]+=rate;
  6873.         }
  6874.         if(admins[i3][1][2]>lowest && admins[i3][1][0] == lowest){
  6875.             admins[i3][1][2]-=rate;
  6876.             admins[i3][1][1]+=rate;
  6877.         }
  6878.         if(admins[i3][1][1]>lowest && admins[i3][1][2] == lowest){
  6879.             admins[i3][1][0]+=rate;
  6880.             admins[i3][1][1]-=rate;
  6881.         }
  6882.         for(var i4 = 0;i4<3;i4++){
  6883.             if(admins[i3][1][i4]<lowest){
  6884.                 admins[i3][1][i4]=lowest;
  6885.             }
  6886.             else if(admins[i3][1][i4]>255){
  6887.                 admins[i3][1][i4]=255;
  6888.             }
  6889.         }
  6890.     }
  6891.     if(randomchat){
  6892.         if(randomchat_timestamp+randomchat_randomtimestamp<now){
  6893.             randomchat_timestamp = now;
  6894.             randomchat_randomtimestamp = 2000+Math.random()*2000;
  6895.             var randnumber = Math.floor(Math.random()*randomchatpriority[0])-randomchatlastmessage[1];
  6896.             for(var i = 0;i<randomchatpriority[1].length;i++){
  6897.                 if(randomchatpriority[1][i][0]!=randomchatlastmessage[0]){
  6898.                     randnumber-=randomchatpriority[1][i][1];
  6899.                     if(randnumber<=0){
  6900.                         chat(flag_manage(randomchatpriority[1][i][0]));
  6901.                         randomchatpriority[1][i][1]+=2;
  6902.                         randomchatpriority[0]+=2;
  6903.                         randomchatlastmessage = randomchatpriority[1][i];
  6904.                         break;
  6905.                     }
  6906.                 }
  6907.             }
  6908.         }
  6909.     }
  6910.     for(var i = 0;i<keys.length;i++){
  6911.         if(autokickbantimestamp+500<now && keys[i]!=myid && !playerids[keys[i]]?.commands && autokickban>0 && playerids[keys[i]].peerID!="sandbox" && ishost && playerids[keys[i]].ratelimit.join+750<now){
  6912.             SEND('42[9,{"banshortid":'+keys[i].toString()+',"kickonly":'+(autokickban == 1).toString()+'}]');
  6913.             autokickbantimestamp = now;
  6914.         }
  6915.        
  6916.         if(playerids[keys[i]].playerData){
  6917.             if(playerids[keys[i]].playerData2){
  6918.                 if(playerids[keys[i]].playerData.transform){
  6919.                     playerids[keys[i]].playerData2.alive = true;
  6920.                     if(playerids[keys[i]].playerData2.timeStamp == 0){
  6921.                         playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6922.                         playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6923.                         playerids[keys[i]].playerData2.timeStamp = performance.now();
  6924.                     }
  6925.                     else{
  6926.                         playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x)/(playerids[keys[i]].playerData2.timeStamp-performance.now());
  6927.                         playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y)/(playerids[keys[i]].playerData2.timeStamp-performance.now());
  6928.                         playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6929.                         playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6930.                         playerids[keys[i]].playerData2.timeStamp = performance.now();
  6931.                     }
  6932.                     if(playerids[keys[i]].playerData2.timeStamp2 == 0){
  6933.                         playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6934.                         playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6935.                         playerids[keys[i]].playerData2.timeStamp2 = performance.now();
  6936.                     }
  6937.                     else{
  6938.                         playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel)/((playerids[keys[i]].playerData2.timeStamp2-performance.now()));
  6939.                         playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel)/((playerids[keys[i]].playerData2.timeStamp2-performance.now()));
  6940.                         playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6941.                         playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6942.                         playerids[keys[i]].playerData2.timeStamp2 = performance.now();
  6943.                     }
  6944.                 }
  6945.                 else{
  6946.                     if(playerids[keys[i]].playerData2.alive){
  6947.  
  6948.                     }
  6949.                     playerids[keys[i]].playerData2.alive = false;
  6950.                 }
  6951.             }
  6952.             else{
  6953.                 playerids[keys[i]].playerData2 = {alive:true,radius:12,timeStamp:0,timeStamp2:0,px:0,py:0,pvx:0,pvy:0,xacc:0,yacc:0,xvel:0,yvel:0,balance:0};
  6954.             }
  6955.         }
  6956.     }
  6957.    
  6958.     for(var i = 0;i<keys.length;i++){
  6959.         if(!playerids[keys[i]].playerData2){
  6960.             playerids[keys[i]].playerData2 = {alive:true,radius:12,timeStamp:0,timeStamp2:0,px:0,py:0,pvx:0,pvy:0,xacc:0,yacc:0,xvel:0,yvel:0,balance:0};
  6961.         }
  6962.     }
  6963.     if(Gdocument.getElementById("redefineControls_table").children[0].children.length<=1 && keys.length>0){
  6964.         Gdocument.getElementById("pretty_top_settings").click();
  6965.         Gdocument.getElementById("settings_close").click();
  6966.     }
  6967.     if(pollactive[0] && pollactive[2]<now && ishost){
  6968.         playerids[myid].ratelimit.poll = Date.now();
  6969.         SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  6970.         var count = [0,0,0,0];
  6971.         var keys = Object.keys(playerids);
  6972.         for(var i = 0;i<keys.length;i++){
  6973.             if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  6974.                 count[playerids[keys[i]].vote.poll]++;
  6975.             }
  6976.             playerids[keys[i]].vote.poll = -1;
  6977.         }
  6978.         displayInChat("The poll ended due to time.","#DA0808","#1EBCC1");
  6979.         for(var i = 0;i<count.length;i++){
  6980.             if(count[i]>1){
  6981.                 displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6982.             }
  6983.             if(count[i]==1){
  6984.                 displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6985.             }
  6986.         }
  6987.         displayInChat("The poll was:","#DA0808","#1EBCC1");
  6988.         for(var i = 0;i<pollactive[3].length;i++){
  6989.             displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  6990.         }
  6991.         pollactive = [false,0,0,[]];
  6992.     }
  6993.     if(!ishost && sandboxcopyme!=-1){
  6994.         sandboxcopyme = -1;
  6995.     }
  6996.    
  6997.     if(afkkill>0 && ishost){
  6998.         var keys = Object.keys(playerids);
  6999.         currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  7000.         for(var i = 0; i<keys.length;i++){
  7001.             if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  7002.                 playerids[keys[i]].lastmove = now;
  7003.             }
  7004.             else{
  7005.                 if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  7006.                     killedids.push(keys[i]);
  7007.                     SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  7008.                     RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  7009.                     break;
  7010.                 }
  7011.             }
  7012.         }
  7013.     }
  7014.     if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  7015.         clearmaprequests.style["display"] = "block";
  7016.         refreshmaprequests.style["display"] = "block";
  7017.     }
  7018.     else{
  7019.         clearmaprequests.style["display"] = "none";
  7020.         refreshmaprequests.style["display"] = "none";
  7021.     }
  7022.     if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  7023.        Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";
  7024.        Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  7025.        pan = {"x":0,"y":0};
  7026.     }
  7027.     if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  7028.         maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  7029.     }
  7030.    
  7031.     if((Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "hidden" || Gdocument.getElementById("sm_connectingContainer").style["visibility"] == "") && (Gdocument.getElementById("roomlistcreatewindowcontainer").style["visibility"] == "hidden" || Gdocument.getElementById("roomlistcreatewindowcontainer").style["visibility"] == "")){
  7032.         var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  7033.         while (chatbox.firstChild) {
  7034.             chatbox.removeChild(chatbox.firstChild);
  7035.         }
  7036.         chatbox = Gdocument.getElementById("ingamechatcontent");
  7037.         while (chatbox.firstChild) {
  7038.             chatbox.removeChild(chatbox.firstChild);
  7039.         }
  7040.         rcaps_flag = false;
  7041.         space_flag = false;
  7042.         number_flag = false;
  7043.         reverse_flag = false;
  7044.         autocorrect = false;
  7045.         translating2 = [false,""];
  7046.         translating = [false,""];
  7047.         echo_list = [];
  7048.         scroll = false;
  7049.         FollowCam = false;
  7050.         autocam = false;
  7051.         aimbot = false;
  7052.         recievedinitdata = false;
  7053.         zoom = 1;
  7054.         zoom2 = 1;
  7055.         newzoom = 1;
  7056.         newzoom2 = 1;
  7057.         FFA = true;
  7058.         mode = "b";
  7059.         ghostroomwss = -1;
  7060.         heavybot = false;
  7061.         stopquickplay = 1;
  7062.         roundsperqp = 1;
  7063.         roundsperqp2 = 0;
  7064.         staystill = false;
  7065.         staystillpos = [0,0];
  7066.         recording = false;
  7067.         recordingid = -1;
  7068.         reverseqp = false;
  7069.         jointeam = -1;
  7070.         currentroomaddress = -1;
  7071.         checkboxhidden = false;
  7072.         freejoin = false;
  7073.         shuffle = false;
  7074.         textmode = -1;
  7075.         defaultmode = "";
  7076.         recmodebool = false;
  7077.         recteams = false;
  7078.         autorecord = false;
  7079.         pollactive = [false,0,0,[]];
  7080.         pollactive2 = [false,0,[]];
  7081.         afkkill = -1;
  7082.         nextafter = 0;
  7083.         jointext = "";
  7084.         ishost = false;
  7085.         parentDraw = 0;
  7086.         sandboxplayerids = {};
  7087.         sandboxcopyme = -1;
  7088.         wintext = "";
  7089.         sandboxon = false;
  7090.         sandboxid = 200;
  7091.         disabledkeys = [];
  7092.         myid = -1;
  7093.         randomchat = false;
  7094.         savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
  7095.         randomchatpriority = [0,[]];
  7096.         randomchatlastmessage = ["",0];
  7097.         autokickbantimestamp = 0;
  7098.         autokickban = 0;
  7099.         inroom = false;
  7100.         causelag = false;
  7101.         causelag2 = 0;
  7102.         jukeboxplayerURL = "";
  7103.         jukeboxplayer.src = "";
  7104.         jukeboxplayervolume = 20;
  7105.         allstyles = {};
  7106.         pan = {"x":0, "y":0};
  7107.         if(!bonkwss){
  7108.             playerids = {};
  7109.         }
  7110.  
  7111.         qppaused = false;
  7112.         nextafterbuffer = -1;
  7113.         hostid = -1;
  7114.         if(chatlog[chatlog.length-1]!="ROOM END"){
  7115.             chatlog.push("ROOM END");
  7116.         }
  7117.     }
  7118.     else{
  7119.         if(chatlog[chatlog.length-1]=="ROOM END"){
  7120.             chatlog.push("ROOM START");
  7121.         }
  7122.        
  7123.     }
  7124.  
  7125.     if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  7126.         Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  7127.     }
  7128.     else{
  7129.         Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  7130.  
  7131.     }
  7132.     if((myid == hostid && myid!=-1) || Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  7133.         ishost = true;
  7134.     }
  7135.     else{
  7136.         ishost = actuallyhost;
  7137.     }
  7138.  
  7139.     if(Gdocument.getElementById("pretty_top_name")!=null){
  7140.         username = Gdocument.getElementById("pretty_top_name").textContent;
  7141.         if(myid!=-1){
  7142.             username = playerids[myid].userName;
  7143.         }
  7144.     }
  7145.     try{
  7146.         Last_message = lastmessage()
  7147.     } catch{
  7148.         Last_message = "";
  7149.     }
  7150.     if (Laster_message != Last_message){
  7151.         Laster_message = Last_message;
  7152.         if(changed_chat==false){
  7153.             new_message = true;
  7154.         }
  7155.         else{
  7156.             changed_chat = false;
  7157.         }
  7158.     }
  7159.     if(new_message){
  7160.         chatlog.push(Last_message);
  7161.         var lm = "";
  7162.         try{
  7163.             lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  7164.             if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  7165.                 if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  7166.                     lm[2].innerHTML = urlify(lm[2].innerHTML);
  7167.                     Laster_message = lastmessage();
  7168.                     lm[0].parentElement.style["parsed"] = true;
  7169.                 }
  7170.                 if (lm[0].className == "newbonklobby_chat_status"){
  7171.                     lm[0].innerHTML = urlify(lm[0].innerHTML);
  7172.                     Laster_message = lastmessage();
  7173.                     lm[0].parentElement.style["parsed"] = true;
  7174.                 }
  7175.             }
  7176.         }
  7177.         catch{
  7178.             lm = "";
  7179.         }
  7180.  
  7181.         if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  7182.             if(Notification.requestPermission()){
  7183.                 var n = new Notification(Last_message);
  7184.             }
  7185.         }
  7186.  
  7187.         try{
  7188.             lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  7189.             if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  7190.                 if(lm[0].className == "ingamechatname"){
  7191.                     lm[1].innerHTML = urlify(lm[1].innerHTML);
  7192.                     Laster_message = lastmessage();
  7193.                     lm[0].parentElement.style["parsed"] = true;
  7194.                 }
  7195.                 if(lm[0].className == ""){
  7196.                     lm[0].innerHTML = urlify(lm[0].innerHTML);
  7197.                     Laster_message = lastmessage();
  7198.                     lm[0].parentElement.style["parsed"] = true;
  7199.                 }
  7200.             }
  7201.         }
  7202.         catch{
  7203.             lm = "";
  7204.         }
  7205.        
  7206.         if(text2speech){
  7207.             if(!sayer.speaking){
  7208.                 if(Last_message.includes(":  ")){
  7209.                     speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  7210.                     speech.rate = 2.25;
  7211.                     sayer.speak(speech);
  7212.                     speech.text = Last_message.substring(Last_message.indexOf(":  ")+3).toLowerCase();
  7213.                     speech.rate = 1.25;
  7214.                     sayer.speak(speech);
  7215.                 }
  7216.                 else{
  7217.                     speech.text = Last_message.toLowerCase();
  7218.                     sayer.speak(speech);
  7219.                 }
  7220.             }
  7221.         }
  7222.     }
  7223.     if (ishost==true && new_message){
  7224.         for(i=0;i<banned.length;i++){
  7225.             if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  7226.                 chat2("/kick '"+banned[i]+"'");
  7227.             }
  7228.         }
  7229.     }
  7230.     if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  7231.         roundsperqp2 = 0;
  7232.     }
  7233.     if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  7234.         if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  7235.             if(stopquickplay!=1){
  7236.                 roundsperqp2++;
  7237.             }
  7238.             if(autorecord){
  7239.                 Gdocument.getElementById("pretty_top_replay").click();
  7240.             }
  7241.         }
  7242.         if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  7243.             chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  7244.         }
  7245.         Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  7246.     }
  7247.     else{
  7248.         Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  7249.     }
  7250.     if(ishost && stopquickplay == 0){
  7251.         if(checkboxhidden){
  7252.             checkboxhidden = false;
  7253.             var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  7254.             for(var i = 0; i<classes.length;i++){
  7255.                 classes[i].style["display"] = "block";
  7256.                 classes[i].className = "quickplaycheckbox quickplaychecked";
  7257.             }
  7258.             Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  7259.  
  7260.         }
  7261.         if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit" && !qppaused){
  7262.             roundsperqp2 = 0;
  7263.             if(shuffle){
  7264.                 var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  7265.                 var available = [];
  7266.                 var availableindexes = [];
  7267.                 var notempty = false;
  7268.                 for(var i = 0; i<e.length;i++){
  7269.                     var a = false;
  7270.                     [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  7271.                     available.push(a);
  7272.                     if(a){
  7273.                         availableindexes.push(i);
  7274.                         notempty = true;
  7275.                     }
  7276.                 }
  7277.                 if(notempty){
  7278.  
  7279.                     if(availableindexes.length!=1){
  7280.                         availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  7281.                     }
  7282.                     quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  7283.                 }
  7284.             }
  7285.             else{
  7286.                 var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  7287.                 var available = [];
  7288.                 var availableindexes = [];
  7289.                 var notempty = false;
  7290.                 for(var i = 0; i<e.length;i++){
  7291.                     var a = false;
  7292.                     [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  7293.                     available.push(a);
  7294.                     if(a){
  7295.                         availableindexes.push(i);
  7296.                         notempty = true;
  7297.                     }
  7298.                 }
  7299.                 if(notempty){
  7300.                     var above = [];
  7301.                     for(var i = 0;i<availableindexes.length;i++){
  7302.                         if(availableindexes[i]>quicki && !reverseqp){
  7303.                             above.push(availableindexes[i]);  
  7304.                         }
  7305.                         else if(availableindexes[i]<quicki && reverseqp){
  7306.                             above.push(availableindexes[i]);  
  7307.                         }
  7308.                     }
  7309.                     if(above.length>0){
  7310.                         quicki = above[0];
  7311.                         if(reverseqp){
  7312.                             above[above.length-1];
  7313.                         }
  7314.                     }
  7315.                     else{
  7316.                         quicki = availableindexes[0];
  7317.                         if(reverseqp){
  7318.                             quicki = availableindexes[availableindexes.length-1];
  7319.                         }
  7320.                     }
  7321.                 }
  7322.             }
  7323.             startedinqp = true;
  7324.             dontswitch = true;
  7325.             gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  7326.         }
  7327.         if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden && !qppaused){
  7328.             if(roundsperqp2>=roundsperqp){
  7329.                 if(shuffle){
  7330.                     var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  7331.                     var available = [];
  7332.                     var availableindexes = [];
  7333.                     var notempty = false;
  7334.                     for(var i = 0; i<e.length;i++){
  7335.                         var a = false;
  7336.                         [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  7337.                         available.push(a);
  7338.                         if(a){
  7339.                             availableindexes.push(i);
  7340.                             notempty = true;
  7341.                         }
  7342.                     }
  7343.                     if(notempty){
  7344.  
  7345.                         if(availableindexes.length!=1){
  7346.                             availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  7347.                         }
  7348.                         quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  7349.                     }
  7350.                 }
  7351.                 else{
  7352.                     var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  7353.                     var available = [];
  7354.                     var availableindexes = [];
  7355.                     var notempty = false;
  7356.                     for(var i = 0; i<e.length;i++){
  7357.                         var a = false;
  7358.                         [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  7359.                         available.push(a);
  7360.                         if(a){
  7361.                             availableindexes.push(i);
  7362.                             notempty = true;
  7363.                         }
  7364.                     }
  7365.                     if(notempty){
  7366.                         var above = [];
  7367.                         for(var i = 0;i<availableindexes.length;i++){
  7368.                             if(availableindexes[i]>quicki && !reverseqp){
  7369.                                 above.push(availableindexes[i]);  
  7370.                             }
  7371.                             else if(availableindexes[i]<quicki && reverseqp){
  7372.                                 above.push(availableindexes[i])
  7373.                             }
  7374.                         }
  7375.                         if(above.length>0){
  7376.                             quicki = above[0];
  7377.                             if(reverseqp){
  7378.                                 quicki = above[above.length-1];
  7379.                             }
  7380.                         }
  7381.                         else{
  7382.                             quicki = availableindexes[0];
  7383.                             if(reverseqp){
  7384.                                 quicki = availableindexes[availableindexes.length-1];
  7385.                             }
  7386.  
  7387.                         }
  7388.                     }
  7389.                 }
  7390.             }
  7391.             transitioning = true;
  7392.             startedinqp = true;
  7393.             map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  7394.             dontswitch = true;
  7395.             setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  7396.  
  7397.         }
  7398.     }
  7399.     else{
  7400.         if(!checkboxhidden){
  7401.             checkboxhidden = true;
  7402.             var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  7403.             for(var i = 0; i<classes.length;i++){
  7404.                 classes[i].style["display"] = "none";
  7405.                 classes[i].className = "quickplaycheckbox quickplayunchecked";
  7406.             }
  7407.             Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  7408.         }
  7409.     }
  7410.     new_message = false;
  7411. };
  7412. });
  7413.  
Comments
Add Comment
Please, Sign In to add comment