Greasy Fork 还支持 简体中文。

Bonk Commands

Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.

目前為 2025-05-06 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://greasyfork.org/en/scripts/451341-bonk-commands
  4. // @version 21.2
  5. // @description Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.
  6. // @author LEGENDBOSS123 + left paren + mastery3
  7. // @match https://bonk.io/*
  8. // @match https://bonkisback.io/*
  9. // @match https://multiplayer.gg/physics/*
  10. // @run-at document-idle
  11. // @grant none
  12. // @unwrap
  13. // ==/UserScript==
  14.  
  15.  
  16. function BonkCommandsScriptInjector(f){
  17. if(window.location == window.parent.location){
  18. if(document.readyState == "complete"){f();}
  19. else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  20. }
  21. }
  22. BonkCommandsScriptInjector(function(){
  23. var scope = window;
  24. scope.scope = scope;
  25. scope.Gwindow = document.getElementById("maingameframe").contentWindow;
  26. scope.Gdocument = document.getElementById("maingameframe").contentDocument;
  27. Gwindow.Gwindow = window;
  28. Gwindow.Gdocument = document;
  29. scope.link2pastebin = "https://pastebin.com/2b8XqqYu";
  30. scope.link2greasyfork = "https://greasyfork.org/en/scripts/451341-bonk-commands";
  31. if(typeof(scope.injectedBonkCommandsScript)=='undefined'){
  32. scope.injectedBonkCommandsScript = true;
  33. }
  34. else{
  35. clearInterval(injectedBonkCommandsScript);
  36. }
  37. scope.GENERATE_COPRIME_NUMBER = function(mini = 0,maxi = 0,coprimewith = 0,choices = []){
  38. if(choices.length == 0){
  39. for(var i = mini;i<maxi+1;i++){
  40. choices.push(i);
  41. }
  42. }
  43. firstTry = choices[Math.floor(Math.random()*choices.length)];
  44. for(var i = 2; i<firstTry+1;i++){
  45. if(firstTry%i == 0 && coprimewith%i == 0){
  46. choices.splice(choices.indexOf(firstTry),1);
  47. if(choices.length == 0){
  48. return 0;
  49. }
  50. return GENERATE_COPRIME_NUMBER(mini,maxi,coprimewith,choices);
  51. }
  52. }
  53. return firstTry;
  54. };
  55. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  56. if(choices.length == 0){
  57. for(var i = mini;i<maxi+1;i++){
  58. choices.push(i);
  59. }
  60. }
  61. firstTry = choices[Math.floor(Math.random()*choices.length)];
  62. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  63. if(i!=firstTry){
  64. if(firstTry%i == 0){
  65. choices.splice(choices.indexOf(firstTry),1);
  66. if(choices.length == 0){
  67. return 0;
  68. }
  69. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  70. }
  71. }
  72. }
  73. return firstTry;
  74. };
  75. scope.SHUFFLE_LIST = function(x){
  76. var nl = x.slice();
  77. for(var i = nl.length - 1;i>0;i--){
  78. var r = Math.floor(Math.random()*(i+1));
  79. var t = nl[i];
  80. nl[i] = nl[r];
  81. nl[r] = t;
  82. }
  83. return nl;
  84. };
  85. scope.str2ab = function(str) {
  86. const buf = new ArrayBuffer(str.length);
  87. const bufView = new Uint8Array(buf);
  88. for (let i = 0, strLen = str.length; i < strLen; i++) {
  89. bufView[i] = str.charCodeAt(i);
  90. }
  91. return buf;
  92. };
  93. scope.ab2str = function(buffer) {
  94. return String.fromCharCode.apply(null, new Uint8Array(buffer));
  95. };
  96. scope.GENERATE_KEYS = async function(){
  97. return crypto.subtle.generateKey({name: "RSA-OAEP",modulusLength: 2048,publicExponent: new Uint8Array([1, 0, 1]),hash: {name: "SHA-256"}},true,["encrypt","decrypt"]);
  98. };
  99. scope.CRYPT_NUMBER = function(key, data){
  100. result = 1;
  101. for(var i = 0;i<key[1];i++){
  102. result*=data;
  103. result = result%key[0];
  104. }
  105. return result%key[0];
  106. };
  107. scope.ENCRYPT_MESSAGE = async function(key,data){
  108. try{
  109. var encrypted = await window.crypto.subtle.encrypt(
  110. {
  111. name: "RSA-OAEP"
  112. },
  113. key,
  114. new TextEncoder().encode(data)
  115. );
  116. return btoa(ab2str(encrypted));
  117. }
  118. catch(E){
  119. console.log(E);
  120. return 0;
  121. }
  122. };
  123. scope.DECRYPT_MESSAGE = async function(key,data){
  124. try{
  125. var decrypted = await window.crypto.subtle.decrypt(
  126. {
  127. name: "RSA-OAEP"
  128. },
  129. key,
  130. str2ab(atob(data))
  131. );
  132. return new TextDecoder().decode(decrypted);
  133. }
  134. catch{
  135. return 0;
  136. }
  137. };
  138. scope.IMPORT_KEY = async function(key){
  139. return await crypto.subtle.importKey("spki", str2ab(atob(key)),public_key.algorithm,true,["encrypt"]);
  140. };
  141. scope.EXPORT_KEY = async function(key){
  142. var result = await crypto.subtle.exportKey("spki",key);
  143. return btoa(ab2str(result));
  144. };
  145. scope.loadMap = function (m, encode = true) {
  146. var mapdata = m;
  147. if (encode) {
  148. var mapdata = encodeToDatabase(m);
  149. }
  150. RECIEVE('42' + JSON.stringify([29, mapdata]));
  151. SEND('42' + JSON.stringify([23, { "m": mapdata }]));
  152. };
  153. if(typeof(scope.textdecoder)=='undefined'){scope.textdecoder = new Gwindow.TextDecoder;}
  154. if(typeof(scope.textencoder)=='undefined'){scope.textencoder = new Gwindow.TextEncoder;}
  155. class bytebuffer2 {
  156. constructor() {
  157. var g1d = [arguments];
  158. this.index = 0;
  159. this.buffer = new ArrayBuffer(100*1024);
  160. this.view = new DataView(this.buffer);
  161. this.implicitClassAliasArray = [];
  162. this.implicitStringArray = [];
  163. this.bodgeCaptureZoneDataIdentifierArray = [];
  164. }
  165. readByte() {
  166. var N0H = [arguments];
  167. N0H[4] = this.view.getUint8(this.index);
  168. this.index += 1;
  169. return N0H[4];
  170. }
  171. writeByte(z0w) {
  172. var v8$ = [arguments];
  173. this.view.setUint8(this.index, v8$[0][0]);
  174. this.index += 1;
  175. }
  176. readInt() {
  177. var A71 = [arguments];
  178. A71[6] = this.view.getInt32(this.index);
  179. this.index += 4;
  180. return A71[6];
  181. }
  182. writeInt(W6i) {
  183. var p5u = [arguments];
  184. this.view.setInt32(this.index, p5u[0][0]);
  185. this.index += 4;
  186. }
  187. readShort() {
  188. var R1R = [arguments];
  189. R1R[9] = this.view.getInt16(this.index);
  190. this.index += 2;
  191. return R1R[9];
  192. }
  193. writeShort(H8B) {
  194. var d_3 = [arguments];
  195. this.view.setInt16(this.index, d_3[0][0]);
  196. this.index += 2;
  197. }
  198. readUint() {
  199. var W2$ = [arguments];
  200. W2$[8] = this.view.getUint32(this.index);
  201. this.index += 4;
  202. return W2$[8];
  203. }
  204. writeUint(B2X) {
  205. var f8B = [arguments];
  206. this.view.setUint32(this.index, f8B[0][0]);
  207. this.index += 4;
  208. }
  209. readBoolean() {
  210. var h6P = [arguments];
  211. h6P[6] = this.readByte();
  212. return h6P[6] == 1;
  213. }
  214. writeBoolean(Y3I) {
  215. var l79 = [arguments];
  216. if (l79[0][0]) {
  217. this.writeByte(1);
  218. } else {
  219. this.writeByte(0);
  220. }
  221. }
  222. readDouble() {
  223. var V60 = [arguments];
  224. V60[4] = this.view.getFloat64(this.index);
  225. this.index += 8;
  226. return V60[4];
  227. }
  228. writeDouble(z4Z) {
  229. var O41 = [arguments];
  230. this.view.setFloat64(this.index, O41[0][0]);
  231. this.index += 8;
  232. }
  233. readFloat() {
  234. var I0l = [arguments];
  235. I0l[5] = this.view.getFloat32(this.index);
  236. this.index += 4;
  237. return I0l[5];
  238. }
  239. writeFloat(y4B) {
  240. var B0v = [arguments];
  241. this.view.setFloat32(this.index, B0v[0][0]);
  242. this.index += 4;
  243. }
  244. readUTF() {
  245. var d6I = [arguments];
  246. d6I[8] = this.readByte();
  247. d6I[7] = this.readByte();
  248. d6I[9] = d6I[8] * 256 + d6I[7];
  249. d6I[1] = new Uint8Array(d6I[9]);
  250. for (d6I[6] = 0; d6I[6] < d6I[9]; d6I[6]++) {
  251. d6I[1][d6I[6]] = this.readByte();
  252. }
  253. return textdecoder.decode(d6I[1]);
  254. }
  255. writeUTF(L3Z) {
  256. var Z75 = [arguments];
  257. Z75[4] = textencoder.encode(Z75[0][0]);
  258. Z75[3] = Z75[4].length;
  259. Z75[5] = Math.floor(Z75[3]/256);
  260. Z75[8] = Z75[3] % 256;
  261. this.writeByte(Z75[5]);
  262. this.writeByte(Z75[8]);
  263. Z75[7] = this;
  264. Z75[4].forEach(I_O);
  265. function I_O(s0Q, H4K, j$o) {
  266. var N0o = [arguments];
  267. Z75[7].writeByte(N0o[0][0]);
  268. }
  269. }
  270. toBase64() {
  271. var P4$ = [arguments];
  272. P4$[4] = "";
  273. P4$[9] = new Uint8Array(this.buffer);
  274. P4$[8] = this.index;
  275. for (P4$[7] = 0; P4$[7] < P4$[8]; P4$[7]++) {
  276. P4$[4] += String.fromCharCode(P4$[9][P4$[7]]);
  277. }
  278. return Gwindow.btoa(P4$[4]);
  279. }
  280. fromBase64(W69, A8Q) {
  281. var o0n = [arguments];
  282. o0n[8] = Gwindow.pako;
  283. o0n[6] = Gwindow.atob(o0n[0][0]);
  284. o0n[9] = o0n[6].length;
  285. o0n[4] = new Uint8Array(o0n[9]);
  286. for (o0n[1] = 0; o0n[1] < o0n[9]; o0n[1]++) {
  287. o0n[4][o0n[1]] = o0n[6].charCodeAt(o0n[1]);
  288. }
  289. if (o0n[0][1] === true) {
  290. o0n[5] = o0n[8].inflate(o0n[4]);
  291. o0n[4] = o0n[5];
  292. }
  293. this.buffer = o0n[4].buffer.slice(
  294. o0n[4].byteOffset,
  295. o0n[4].byteLength + o0n[4].byteOffset
  296. );
  297. this.view = new DataView(this.buffer);
  298. this.index = 0;
  299. }
  300. };
  301. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  302. if(typeof(scope.originalDatenow)=='undefined'){scope.originalDatenow = Gwindow.Date.now;}
  303. if(typeof(scope.originalXMLOpen)=='undefined'){scope.originalXMLOpen = Gwindow.XMLHttpRequest.prototype.open;}
  304. if(typeof(scope.originalXMLSend)=='undefined'){scope.originalXMLSend = Gwindow.XMLHttpRequest.prototype.send;}
  305. if(typeof(scope.searchrequested)=='undefined'){scope.searchrequested = 0;}
  306. if(typeof(scope.originalDrawCircle)=='undefined'){scope.originalDrawCircle = Gwindow.PIXI.Graphics.prototype.drawCircle;}
  307. if(typeof(scope.parentDraw)=='undefined'){scope.parentDraw = 0;}
  308. if(typeof(scope.pixiCircle)=='undefined'){scope.pixiCircle = new Gwindow.PIXI.Graphics();}
  309. if(typeof(scope.container)=='undefined'){scope.container = new Gwindow.PIXI.Container();container.addChild(pixiCircle);}
  310. if(typeof(scope.canvasWidth)=='undefined'){scope.canvasWidth = -1;}
  311. if(typeof(scope.savedrooms)=='undefined'){scope.savedrooms = [];}
  312. if(typeof(scope.inroom)=='undefined'){scope.inroom = false;}
  313. if(typeof(scope.currentroomaddress)=='undefined'){scope.currentroomaddress = -1;}
  314. if(typeof(scope.savedroomsdata)=='undefined'){scope.savedroomsdata = {};}
  315. if(typeof(scope.jukeboxplayerURL)=='undefined'){scope.jukeboxplayerURL = "";}
  316. if(typeof(scope.jukeboxplayervolume)=='undefined'){scope.jukeboxplayervolume = 20;}
  317. if(typeof(scope.gameStartTimeStamp)=='undefined'){scope.gameStartTimeStamp = 0;}
  318. scope.checkInstance = async function(index){
  319. var doesitwork = false;
  320. await fetch(pipedurllist[index]+"dQw4w9WgXcQ").then(
  321. function(r){
  322. return r.json();
  323. }
  324. ).then(async function(r){
  325. if (r.audioStreams && !r.error){
  326. for(var i2 = 0;i2<r.audioStreams.length;i2++){
  327. if(r.audioStreams[i2].url){
  328. try{
  329. var f = await fetch(r.audioStreams[i2].url);
  330. if(f.ok){
  331. doesitwork = true;
  332. return;
  333. }
  334. }
  335. catch(e){}
  336. }
  337. }
  338. }
  339. }).catch(function(e){});
  340. if(!doesitwork){
  341. return -1;
  342. }
  343. return index;
  344. };
  345. scope.checkJukeboxStream = async function(index,id){
  346. var doesitwork = false;
  347. var urlreturn = [];
  348. await fetch(pipedurllist[index]+id).then(
  349. function(r){
  350. return r.json();
  351. }
  352. ).then(async function(r){
  353. if (r.audioStreams && !r.error){
  354. for(var i2 = 0;i2<r.audioStreams.length;i2++){
  355. if(r.audioStreams[i2].url){
  356. try{
  357. var f = await fetch(r.audioStreams[i2].url);
  358. if(f.ok){
  359. doesitwork = true;
  360. urlreturn = [r.audioStreams[i2].url,r.title,r.uploader];
  361. return;
  362. }
  363. }
  364. catch(e){}
  365. }
  366. }
  367. }
  368. }).catch(function(e){});
  369. if(!doesitwork){
  370. return -1;
  371. }
  372. return urlreturn;
  373. };
  374. scope.checkInstances = async function (){
  375. pipedindexes = [];
  376. for (var index = 0;index<pipedurllist.length;index++){
  377. checkInstance(index).then(function(value){
  378. if(value!=-1){
  379. pipedindexes.push(value);
  380. }
  381. });
  382. }
  383. };
  384. if(typeof(scope.pipedurllist)=='undefined'){
  385. scope.pipedurllist = [
  386. "https://pipedapi.kavin.rocks/streams/",
  387. "https://pipedapi.syncpundit.io/streams/",
  388. "https://api-piped.mha.fi/streams/",
  389. "https://piped-api.garudalinux.org/streams/",
  390. "https://pipedapi.rivo.lol/streams/",
  391. "https://pipedapi.leptons.xyz/streams/",
  392. "https://piped-api.lunar.icu/streams/",
  393. "https://ytapi.dc09.ru/streams/",
  394. "https://piped.tokhmi.xyz/streams/",
  395. "https://pipedapi.aeong.one/streams/"];
  396. scope.pipedindexes = [];
  397. checkInstances();
  398. }
  399. if(typeof(scope.requestAnimationFrameOriginal)=='undefined'){scope.requestAnimationFrameOriginal = Gwindow.requestAnimationFrame;}
  400. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  401. if(typeof(scope.bonkwssextra)=='undefined'){scope.bonkwssextra = [];}
  402. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  403. if(typeof(scope.wsssendrecievelog)=='undefined'){scope.wsssendrecievelog = [];}
  404. if(typeof(scope.wsssendlog)=='undefined'){scope.wsssendlog = [];}
  405. if(typeof(scope.wssrecievelog)=='undefined'){scope.wssrecievelog = [];}
  406. if(typeof(scope.wsslogpaused)=='undefined'){scope.wsslogpaused = false;}
  407. if(typeof(scope.debuggeropen)=='undefined'){scope.debuggeropen = false;}
  408. if(typeof(scope.debuggercount)=='undefined'){scope.debuggercount = true;}
  409. if(typeof(scope.packetcount)=='undefined'){scope.packetcount = 0;}
  410. if(typeof(scope.requestedmaps)=='undefined'){scope.requestedmaps = [];}
  411. if(typeof(scope.maponclick)=='undefined'){scope.maponclick = 0;}
  412. if(typeof(scope.LZString)=='undefined'){scope.LZString = Gwindow.LZString;}
  413. if(typeof(scope.PSON)=='undefined'){scope.PSON = Gwindow.dcodeIO.PSON;}
  414. if(typeof(scope.bytebuffer)=='undefined'){scope.bytebuffer = Gwindow.dcodeIO.ByteBuffer;}
  415. if(typeof(scope.speech)=='undefined'){scope.speech = new SpeechSynthesisUtterance();speech.pitch = 0.75;}
  416. if(typeof(scope.sayer)=='undefined'){scope.sayer = speechSynthesis;sayer.volume = 0.5;sayer.rate = 1.25;}
  417. if(typeof(scope.pollactive)=='undefined'){scope.pollactive = [false,0,0,[]];}
  418. if(typeof(scope.pollactive2)=='undefined'){scope.pollactive2 = [false,0,[]];}
  419. if(typeof(scope.mode)=='undefined'){scope.mode = '';}
  420. if(typeof(scope.FFA)=='undefined'){scope.FFA = true;}
  421. if(typeof(scope.recording)=='undefined'){scope.recording = false;}
  422. if(typeof(scope.recordingdata)=='undefined'){scope.recordingdata = [];}
  423. if(typeof(scope.recorddata)=='undefined'){scope.recorddata = {};}
  424. if(typeof(scope.recordingid)=='undefined'){scope.recordingid = -1;}
  425. if (typeof (scope.currentmap) == 'undefined') { scope.currentmap = []; }
  426.  
  427. if(typeof(scope.wordlist)=='undefined'){
  428. scope.wordlist = [];
  429. fetch("https://api.github.com/repos/first20hours/google-10000-english/contents/20k.txt").then(function(data){
  430. return data.json();
  431. }).then(function(data){
  432. fetch("https://api.github.com/repos/first20hours/google-10000-english/git/blobs/"+data.sha).then(function(data){
  433. return data.json();
  434. }).then(function(data){
  435. scope.wordlist = atob(data.content).split("\n");
  436. });
  437. });
  438. }
  439. if(typeof(scope.allstyles)=='undefined'){scope.allstyles = {};}
  440. if(typeof(scope.mystyle)=='undefined'){scope.mystyle = [0,0,0];}
  441. 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]);}
  442. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  443. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 200;}
  444. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  445. if(typeof(scope.delplayerids)=='undefined'){scope.delplayerids = {};}
  446. if(typeof(scope.myid)=='undefined'){scope.myid = -1;}
  447. if(typeof(scope.hostid)=='undefined'){scope.hostid = -1;}
  448. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  449. if(typeof(scope.originalMapLoad)=='undefined'){scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild;}
  450. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  451. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  452. 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;});}
  453. if(typeof(scope.jukeboxplayer)=='undefined'){
  454. scope.jukeboxplayer = Gdocument.createElement("audio");
  455. jukeboxplayer.controls = true;
  456. jukeboxplayer.loop = true;
  457. }
  458. if(Gdocument.getElementById("savedroombutton") == null){
  459. scope.savedroombutton = Gdocument.createElement("div");
  460. savedroombutton.id = "savedroombutton";
  461. savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
  462. savedroombutton.textContent = "Save Room";
  463. savedroombutton.style["left"] = "120px";
  464. savedroombutton.style["position"] = "absolute";
  465. savedroombutton.style["width"] = "90px";
  466. savedroombutton.style["height"] = "30px";
  467. savedroombutton.style["color"] = "#ffffff";
  468. savedroombutton.style["text-align"] = "center";
  469. savedroombutton.style["vertical-align"] = "middle";
  470. savedroombutton.style["line-height"] = "30px";
  471. savedroombutton.style["right"] = "0";
  472. savedroombutton.style["cursor"] = "pointer";
  473. savedroombutton.style["bottom"] = "10px";
  474. savedroombutton.style["margin"] = "auto";
  475. savedroombutton.style["bottom"] = "10px";
  476. savedroombutton.onclick = function(){
  477. if(!savedrooms.includes(currentroomaddress) && currentroomaddress!=-1){
  478. savedrooms.push(currentroomaddress);
  479. savedroomsdata[currentroomaddress] = {"exists":true};
  480. }
  481. Gdocument.getElementById("sm_connectingWindowCancelButton").click();
  482. };
  483. Gdocument.getElementById("sm_connectingWindowCancelButton").style["left"] = "-120px";
  484. Gdocument.getElementById("sm_connectingWindow").appendChild(savedroombutton)
  485. }
  486. if(Gdocument.getElementById("maploadtypedropdowntitlerequested") == null){
  487. scope.clearmaprequests = Gdocument.createElement("div");
  488. clearmaprequests.id = "clearmaprequests";
  489. clearmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  490. clearmaprequests.textContent = "Clear";
  491. clearmaprequests.style["position"] = "absolute";
  492. clearmaprequests.style["display"] = "none";
  493. if(typeof(ishost)!='undefined'){
  494. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  495. clearmaprequests.style["display"] = "block";
  496. }
  497. }
  498. clearmaprequests.style["right"] = "306px";
  499. clearmaprequests.style["top"] = "57px";
  500. clearmaprequests.style["height"] = "23px";
  501. clearmaprequests.style["width"] = "47px";
  502. clearmaprequests.style["line-height"] = "23px";
  503. clearmaprequests.style["font-size"] = "14px";
  504. clearmaprequests.addEventListener("click",function(){
  505. requestedmaps = [];
  506. Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "inherit";
  507. Gdocument.getElementById("maploadwindowstatustext").textContent = "No Maps";
  508. while(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0){
  509. Gdocument.getElementById("maploadwindowmapscontainer").removeChild(Gdocument.getElementById("maploadwindowmapscontainer").firstChild);
  510. }
  511. });
  512. Gdocument.getElementById("maploadwindow").insertBefore(clearmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  513. scope.refreshmaprequests = Gdocument.createElement("div");
  514. refreshmaprequests.id = "refreshmaprequests";
  515. refreshmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  516. refreshmaprequests.textContent = "Refresh";
  517. refreshmaprequests.style["position"] = "absolute";
  518. refreshmaprequests.style["display"] = "none";
  519. if(typeof(ishost)!='undefined'){
  520. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  521. refreshmaprequests.style["display"] = "block";
  522. }
  523. }
  524. refreshmaprequests.style["right"] = "357px";
  525. refreshmaprequests.style["top"] = "57px";
  526. refreshmaprequests.style["height"] = "23px";
  527. refreshmaprequests.style["width"] = "47px";
  528. refreshmaprequests.style["line-height"] = "23px";
  529. refreshmaprequests.style["font-size"] = "14px";
  530. refreshmaprequests.addEventListener("click",function(){
  531. searchrequested = 1;
  532. Gdocument.getElementById("maploadtypedropdowntitle").click();
  533. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  534. dropdownrequested.style["display"] = "none";
  535. clearmaprequests.style["display"] = "block";
  536. refreshmaprequests.style["display"] = "block";
  537. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  538. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  539. Gdocument.getElementById("maploadtypedropdownoption10").click();
  540. });
  541. Gdocument.getElementById("maploadwindow").insertBefore(refreshmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  542. scope.dropdownrequested = Gdocument.createElement("div");
  543. dropdownrequested.classList = "dropdown-option dropdown_classic";
  544. dropdownrequested.style["display"] = "none";
  545. dropdownrequested.id = "maploadtypedropdowntitlerequested";
  546. if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block"){
  547. dropdownrequested.style["display"] = "block";
  548. }
  549. dropdownrequested.textContent = "MAP REQUESTS";
  550. dropdownrequested.onclick = function(){
  551. searchrequested = 1;
  552. Gdocument.getElementById("maploadtypedropdowntitle").click();
  553. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  554. dropdownrequested.style["display"] = "none";
  555. clearmaprequests.style["display"] = "block";
  556. refreshmaprequests.style["display"] = "block";
  557. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  558. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  559. Gdocument.getElementById("maploadtypedropdownoption10").click();
  560. };
  561. (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});
  562. Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownrequested,Gdocument.getElementById("maploadtypedropdownoption1"));
  563. Gdocument.getElementById("maploadwindowmapscontainer").__defineGetter__("clientHeight",function(){if(Gdocument.getElementById("maploadtypedropdowntitle").textContent != "MAP REQUESTS"){return Gdocument.getElementById("maploadwindowmapscontainer").getClientRects()[0].height;}else{return 0;}});
  564. };
  565. scope.sandboxonclick = function(){
  566. Gdocument.getElementById("roomlistrefreshbutton").click();
  567. Gdocument.getElementById("roomlistcreatebutton").click();
  568. sandboxon = true;
  569. };
  570. scope.checkboxclearbuttononclick = function(){
  571. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  572. var e = true;
  573. for(var i = 0; i<classes.length;i++){
  574. if(classes[i].checked == true){
  575. e = false
  576. }
  577. classes[i].checked = false;
  578. }
  579. if(e){
  580. for(var i = 0; i<classes.length;i++){
  581. classes[i].checked = true;
  582. }
  583. }
  584. };
  585. Gdocument.getElementById("ingamechatcontent").__defineGetter__("childElementCount",function(){return this.children.length/50;});
  586. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  587. Gdocument.getElementById("roomlistrefreshbutton").click();
  588. scope.sandboxbutton = Gdocument.createElement("div");
  589. sandboxbutton.id = "classic_mid_sandbox";
  590. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  591. sandboxbutton.textContent = "Sandbox";
  592. sandboxbutton.addEventListener("click",sandboxonclick);
  593. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  594. }
  595. if(Gdocument.getElementById("clearallcheckboxes")==null){
  596. scope.checkboxclearbutton = Gdocument.createElement("div");
  597. checkboxclearbutton.id = "clearallcheckboxes";
  598. checkboxclearbutton.classList.value = "brownButton brownButton_classic buttonShadow";
  599. checkboxclearbutton.textContent = "On/Off";
  600. checkboxclearbutton.style["position"] = "absolute";
  601. checkboxclearbutton.style["display"] = "none";
  602. if(typeof(ishost)!='undefined'){
  603. if(ishost && stopquickplay == 0){
  604. checkboxclearbutton.style["display"] = "block";
  605. }
  606. }
  607. checkboxclearbutton.style["right"] = "255px";
  608. checkboxclearbutton.style["top"] = "57px";
  609. checkboxclearbutton.style["height"] = "23px";
  610. checkboxclearbutton.style["width"] = "47px";
  611. checkboxclearbutton.style["line-height"] = "23px";
  612. checkboxclearbutton.style["font-size"] = "13px";
  613. checkboxclearbutton.addEventListener("click",checkboxclearbuttononclick);
  614. Gdocument.getElementById("maploadwindow").insertBefore(checkboxclearbutton,Gdocument.getElementById("maploadwindowsearchinput"));
  615. }
  616. scope.holdloadbuttonTimeout = [];
  617. scope.holdloadbutton = function(){
  618. var scrollcount = 0;
  619. var mapwindow = Gdocument.getElementById("maploadwindowmapscontainer");
  620. mapwindow.scroll(0,mapwindow.scrollHeight);
  621. };
  622. if(Gdocument.getElementById("mapwindowloadall")==null){
  623. scope.loadall = Gdocument.createElement("div");
  624. loadall.id = "mapwindowloadall";
  625. loadall.classList.value = "brownButton brownButton_classic buttonShadow";
  626. loadall.textContent = "Load";
  627. loadall.style["position"] = "absolute";
  628. loadall.style["display"] = "block";
  629. loadall.style["left"] = "204px";
  630. loadall.style["top"] = "57px";
  631. loadall.style["height"] = "23px";
  632. loadall.style["width"] = "34px";
  633. loadall.style["line-height"] = "23px";
  634. loadall.style["font-size"] = "12px";
  635. var repeat = function(){holdloadbutton();holdloadbuttonTimeout.push(setTimeout(repeat,25));};
  636. loadall.onmousedown = function(){repeat();};
  637. loadall.onmouseup = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  638. loadall.onmouseout = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  639. Gdocument.getElementById("maploadwindow").insertBefore(loadall,Gdocument.getElementById("maploadwindowsearchinput"));
  640. }
  641. if(Gdocument.getElementById("BonkCommandsDebuggerContainer")==null){
  642. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  643. scope.debuggermenu = Gdocument.createElement("div");
  644. debuggermenu.id = "BonkCommandsDebuggerContainer";
  645. debuggermenu.style["position"] = "absolute";
  646. debuggermenu.style["display"] = "none";
  647. if(typeof(debuggeropen)!='undefined'){
  648. if(debuggeropen){
  649. debuggermenu.style["display"] = "block";
  650. }
  651. }
  652. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  653. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  654. debuggermenu.style["background"] = "rgb(26, 39, 51)";
  655. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  656. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  657. scope.logmenu = Gdocument.createElement("div");
  658. logmenu.id = "BonkCommandsWebSocketLog";
  659. logmenu.style["position"] = "absolute";
  660. logmenu.style["width"] = width.toString()+"px";
  661. logmenu.style["height"] = height.toString()+"px";
  662. logmenu.style["top"] = "80px";
  663. logmenu.style["left"] = "10px";
  664. logmenu.style["background"] = "rgb(207, 216, 220)";
  665. scope.logmenutopleft = Gdocument.createElement("div");
  666. logmenutopleft.id = "BonkCommandsWebSocketLog";
  667. logmenutopleft.style["position"] = "absolute";
  668. logmenutopleft.textContent = "Sending";
  669. logmenutopleft.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  670. logmenutopleft.style["width"] = (width/2).toString()+"px";
  671. logmenutopleft.style["height"] = "30px";
  672. logmenutopleft.style["top"] = "-30px";
  673. logmenutopleft.style["background"] = "rgb(0, 150, 136)";
  674. logmenu.appendChild(logmenutopleft);
  675. scope.logmenutopright = Gdocument.createElement("div");
  676. logmenutopright.id = "BonkCommandsWebSocketLog";
  677. logmenutopright.style["position"] = "absolute";
  678. logmenutopright.textContent = "Recieving";
  679. logmenutopright.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  680. logmenutopright.style["width"] = (width/2).toString()+"px";
  681. logmenutopright.style["height"] = "30px";
  682. logmenutopright.style["left"] = (width/2).toString()+"px";
  683. logmenutopright.style["top"] = "-30px";
  684. logmenutopright.style["background"] = "rgb(0, 150, 136)";
  685. logmenu.appendChild(logmenutopright);
  686. scope.logmenutable = Gdocument.createElement("table");
  687. logmenutable.id = "BonkCommandsWebSocketTable";
  688. logmenutable.style["position"] = "absolute";
  689. logmenutable.style["border-spacing"] = "0px";
  690. logmenutable.style["font-size"] = "12px";
  691. logmenutable.style["display"] = "table-cell";
  692. logmenutable.style["width"] = "50%";
  693. logmenutable.style["height"] = "100%";
  694. logmenutable.style["table-layout"] = "fixed";
  695. logmenutable.style["overflow-y"] = "scroll";
  696. scope.logmenutable2 = Gdocument.createElement("table");
  697. logmenutable2.id = "BonkCommandsWebSocketTable2";
  698. logmenutable2.style["position"] = "absolute";
  699. logmenutable2.style["width"] = "50%";
  700. logmenutable2.style["left"] = "50%";
  701. logmenutable2.style["font-size"] = "12px";
  702. logmenutable2.style["display"] = "table-cell";
  703. logmenutable2.style["height"] = "100%";
  704. logmenutable2.style["table-layout"] = "fixed";
  705. logmenutable2.style["overflow-y"] = "scroll";
  706. logmenutable2.style["border-spacing"] = "0px";
  707. scope.leftsync = false;
  708. scope.rightsync = false;
  709. logmenutable2.onscroll = function(){
  710. if(!leftsync){
  711. rightsync = true;
  712. logmenutable.scrollTop = this.scrollTop;
  713. }
  714. else{
  715. leftsync = false;
  716. }
  717. };
  718. logmenutable.onscroll = function(){
  719. if(!rightsync){
  720. leftsync = true;
  721. logmenutable2.scrollTop = this.scrollTop;
  722. }
  723. else{
  724. rightsync = false
  725. }
  726. };
  727. logmenu.appendChild(logmenutable);
  728. logmenu.appendChild(logmenutable2);
  729. debuggermenu.appendChild(logmenu);
  730. scope.debuggermenuclose = Gdocument.createElement("div");
  731. debuggermenuclose.id = "debuggerclose";
  732. debuggermenuclose.classList = "windowCloseButton brownButton brownButton_classic buttonShadow";
  733. debuggermenuclose.style["position"] = "absolute";
  734. debuggermenuclose.style["top"] = "40px";
  735. debuggermenuclose.style["right"] = "5px";
  736. debuggermenuclose.onclick = function(){debuggeropen = false;debuggermenu.style["display"] = "none";Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  737. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";};
  738. debuggermenu.appendChild(debuggermenuclose);
  739. scope.debuggerform = Gdocument.createElement("form");
  740. debuggerform.autocomplete = "off";
  741. scope.debuggerinput = Gdocument.createElement("input");
  742. debuggerinput.style["position"] = "absolute";
  743. debuggerinput.style["width"] = width.toString()+"px";
  744. debuggerinput.style["left"] = "10px";
  745. debuggerinput.style["top"] = (height+90).toString()+"px";
  746. debuggerinput.style["font-size"] = "12px";
  747. debuggerinput.style["height"] = "20px";
  748. debuggerform.appendChild(debuggerinput);
  749. scope.debuggersendrecieve = Gdocument.createElement("div");
  750. debuggersendrecieve.style["position"] = "absolute";
  751. debuggersendrecieve.style["width"] = "140px";
  752. debuggersendrecieve.style["left"] = "10px";
  753. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  754. debuggersendrecieve.style["font-size"] = "15px";
  755. debuggersendrecieve.style["height"] = "20px";
  756. debuggersendrecieve.classList = "brownButton brownButton_classic buttonShadow";
  757. debuggersendrecieve.textContent = "Send";
  758. debuggersendrecieve.value = 0;
  759. debuggersendrecieve.onclick = function(){if(this.value == 0){this.textContent = "Recieve";this.value = 1;}else{this.textContent = "Send";this.value = 0;}};
  760. debuggermenu.appendChild(debuggersendrecieve);
  761. scope.debuggerpausebutton = Gdocument.createElement("div");
  762. debuggerpausebutton.style["position"] = "absolute";
  763. debuggerpausebutton.style["width"] = "140px";
  764. debuggerpausebutton.style["left"] = "10px";
  765. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  766. debuggerpausebutton.style["font-size"] = "15px";
  767. debuggerpausebutton.style["height"] = "20px";
  768. debuggerpausebutton.classList = "brownButton brownButton_classic buttonShadow";
  769. debuggerpausebutton.textContent = "Pause";
  770. debuggerpausebutton.value = 0;
  771. debuggerpausebutton.onclick = function(){if(this.value == 0){this.textContent = "Play";this.value = 1;wsslogpaused = true}else{this.textContent = "Pause";this.value = 0;wsslogpaused = false;}};
  772. debuggermenu.appendChild(debuggerpausebutton);
  773. scope.debuggereval = Gdocument.createElement("input");
  774. debuggereval.style["position"] = "absolute";
  775. debuggereval.style["width"] = (width-150).toString()+"px";
  776. debuggereval.style["right"] = "10px";
  777. debuggereval.style["top"] = (height+120).toString()+"px";
  778. debuggereval.style["font-size"] = "12px";
  779. debuggereval.style["height"] = "20px";
  780. 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);}}});
  781. debuggerform.appendChild(debuggereval);
  782. debuggermenu.appendChild(debuggerform);
  783. Gdocument.getElementById("newbonkgamecontainer").appendChild(debuggermenu);
  784. }
  785. scope.ISdecode = function(rawdata) {
  786. rawdata_caseflipped = "";
  787. for (i = 0; i < rawdata.length; i++) {
  788. if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toLowerCase()) {
  789. rawdata_caseflipped += rawdata.charAt(i).toUpperCase();
  790. } else if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toUpperCase()) {
  791. rawdata_caseflipped += rawdata.charAt(i).toLowerCase();
  792. } else {
  793. rawdata_caseflipped += rawdata.charAt(i);
  794. }
  795. }
  796. data_deLZd = LZString.decompressFromEncodedURIComponent(rawdata_caseflipped);
  797. databuffer = bytebuffer.fromBase64(data_deLZd);
  798. data = ISpsonpair.decode(databuffer.buffer);
  799. return data;
  800. };
  801. scope.ISencode = function(obj) {
  802. data = ISpsonpair.encode(obj);
  803. b64 = data.toBase64();
  804. lzd = LZString.compressToEncodedURIComponent(b64);
  805. caseflipped = "";
  806. for (i = 0; i < lzd.length; i++) {
  807. if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toLowerCase()) {
  808. caseflipped += lzd.charAt(i).toUpperCase();
  809. } else if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toUpperCase()) {
  810. caseflipped += lzd.charAt(i).toLowerCase();
  811. } else {
  812. caseflipped += lzd.charAt(i);
  813. }
  814. }
  815. return caseflipped;
  816. };
  817. scope.decodeIS = function(x){
  818. return ISdecode(x);
  819. };
  820. scope.encodeIS = function(x){
  821. return ISencode(x);
  822. };
  823. scope.encodeToDatabase = function (W2A) {
  824. var M3n = [arguments];
  825. M3n[1] = new bytebuffer2;
  826. M3n[9] = M3n[0][0].physics;
  827. M3n[0][0].v = 15;
  828. M3n[1].writeShort(M3n[0][0].v);
  829. M3n[1].writeBoolean(M3n[0][0].s.re);
  830. M3n[1].writeBoolean(M3n[0][0].s.nc);
  831. M3n[1].writeShort(M3n[0][0].s.pq);
  832. M3n[1].writeFloat(M3n[0][0].s.gd);
  833. M3n[1].writeBoolean(M3n[0][0].s.fl);
  834. M3n[1].writeUTF(M3n[0][0].m.rxn);
  835. M3n[1].writeUTF(M3n[0][0].m.rxa);
  836. M3n[1].writeUint(M3n[0][0].m.rxid);
  837. M3n[1].writeShort(M3n[0][0].m.rxdb);
  838. M3n[1].writeUTF(M3n[0][0].m.n);
  839. M3n[1].writeUTF(M3n[0][0].m.a);
  840. M3n[1].writeUint(M3n[0][0].m.vu);
  841. M3n[1].writeUint(M3n[0][0].m.vd);
  842. M3n[1].writeShort(M3n[0][0].m.cr.length);
  843. for (
  844. M3n[84] = 0;
  845. M3n[84] < M3n[0][0].m.cr.length;
  846. M3n[84]++
  847. ) {
  848. M3n[1].writeUTF(M3n[0][0].m.cr[M3n[84]]);
  849. }
  850. M3n[1].writeUTF(M3n[0][0].m.mo);
  851. M3n[1].writeInt(M3n[0][0].m.dbid);
  852. M3n[1].writeBoolean(M3n[0][0].m.pub);
  853. M3n[1].writeInt(M3n[0][0].m.dbv);
  854. M3n[1].writeShort(M3n[9].ppm);
  855. M3n[1].writeShort(M3n[9].bro.length);
  856. for (M3n[17] = 0; M3n[17] < M3n[9].bro.length; M3n[17]++) {
  857. M3n[1].writeShort(M3n[9].bro[M3n[17]]);
  858. }
  859. M3n[1].writeShort(M3n[9].shapes.length);
  860. for (M3n[80] = 0; M3n[80] < M3n[9].shapes.length; M3n[80]++) {
  861. M3n[2] = M3n[9].shapes[M3n[80]];
  862. if (M3n[2].type == "bx") {
  863. M3n[1].writeShort(1);
  864. M3n[1].writeDouble(M3n[2].w);
  865. M3n[1].writeDouble(M3n[2].h);
  866. M3n[1].writeDouble(M3n[2].c[0]);
  867. M3n[1].writeDouble(M3n[2].c[1]);
  868. M3n[1].writeDouble(M3n[2].a);
  869. M3n[1].writeBoolean(M3n[2].sk);
  870. }
  871. if (M3n[2].type == "ci") {
  872. M3n[1].writeShort(2);
  873. M3n[1].writeDouble(M3n[2].r);
  874. M3n[1].writeDouble(M3n[2].c[0]);
  875. M3n[1].writeDouble(M3n[2].c[1]);
  876. M3n[1].writeBoolean(M3n[2].sk);
  877. }
  878. if (M3n[2].type == "po") {
  879. M3n[1].writeShort(3);
  880. M3n[1].writeDouble(M3n[2].s);
  881. M3n[1].writeDouble(M3n[2].a);
  882. M3n[1].writeDouble(M3n[2].c[0]);
  883. M3n[1].writeDouble(M3n[2].c[1]);
  884. M3n[1].writeShort(M3n[2].v.length);
  885. for (M3n[61] = 0; M3n[61] < M3n[2].v.length; M3n[61]++) {
  886. M3n[1].writeDouble(M3n[2].v[M3n[61]][0]);
  887. M3n[1].writeDouble(M3n[2].v[M3n[61]][1]);
  888. }
  889. }
  890. }
  891. M3n[1].writeShort(M3n[9].fixtures.length);
  892. for (M3n[20] = 0; M3n[20] < M3n[9].fixtures.length; M3n[20]++) {
  893. M3n[7] = M3n[9].fixtures[M3n[20]];
  894. M3n[1].writeShort(M3n[7].sh);
  895. M3n[1].writeUTF(M3n[7].n);
  896. if (M3n[7].fr === null) {
  897. M3n[1].writeDouble(Number.MAX_VALUE);
  898. } else {
  899. M3n[1].writeDouble(M3n[7].fr);
  900. }
  901. if (M3n[7].fp === null) {
  902. M3n[1].writeShort(0);
  903. }
  904. if (M3n[7].fp === false) {
  905. M3n[1].writeShort(1);
  906. }
  907. if (M3n[7].fp === true) {
  908. M3n[1].writeShort(2);
  909. }
  910. if (M3n[7].re === null) {
  911. M3n[1].writeDouble(Number.MAX_VALUE);
  912. } else {
  913. M3n[1].writeDouble(M3n[7].re);
  914. }
  915. if (M3n[7].de === null) {
  916. M3n[1].writeDouble(Number.MAX_VALUE);
  917. } else {
  918. M3n[1].writeDouble(M3n[7].de);
  919. }
  920. M3n[1].writeUint(M3n[7].f);
  921. M3n[1].writeBoolean(M3n[7].d);
  922. M3n[1].writeBoolean(M3n[7].np);
  923. M3n[1].writeBoolean(M3n[7].ng);
  924. M3n[1].writeBoolean(M3n[7].ig);
  925. }
  926. M3n[1].writeShort(M3n[9].bodies.length);
  927. for (M3n[37] = 0; M3n[37] < M3n[9].bodies.length; M3n[37]++) {
  928. M3n[4] = M3n[9].bodies[M3n[37]];
  929. M3n[1].writeUTF(M3n[4].type);
  930. M3n[1].writeUTF(M3n[4].n);
  931. M3n[1].writeDouble(M3n[4].p[0]);
  932. M3n[1].writeDouble(M3n[4].p[1]);
  933. M3n[1].writeDouble(M3n[4].a);
  934. M3n[1].writeDouble(M3n[4].fric);
  935. M3n[1].writeBoolean(M3n[4].fricp);
  936. M3n[1].writeDouble(M3n[4].re);
  937. M3n[1].writeDouble(M3n[4].de);
  938. M3n[1].writeDouble(M3n[4].lv[0]);
  939. M3n[1].writeDouble(M3n[4].lv[1]);
  940. M3n[1].writeDouble(M3n[4].av);
  941. M3n[1].writeDouble(M3n[4].ld);
  942. M3n[1].writeDouble(M3n[4].ad);
  943. M3n[1].writeBoolean(M3n[4].fr);
  944. M3n[1].writeBoolean(M3n[4].bu);
  945. M3n[1].writeDouble(M3n[4].cf.x);
  946. M3n[1].writeDouble(M3n[4].cf.y);
  947. M3n[1].writeDouble(M3n[4].cf.ct);
  948. M3n[1].writeBoolean(M3n[4].cf.w);
  949. M3n[1].writeShort(M3n[4].f_c);
  950. M3n[1].writeBoolean(M3n[4].f_1);
  951. M3n[1].writeBoolean(M3n[4].f_2);
  952. M3n[1].writeBoolean(M3n[4].f_3);
  953. M3n[1].writeBoolean(M3n[4].f_4);
  954. M3n[1].writeBoolean(M3n[4].f_p);
  955. M3n[1].writeBoolean(M3n[4].fz.on);
  956. if (M3n[4].fz.on) {
  957. M3n[1].writeDouble(M3n[4].fz.x);
  958. M3n[1].writeDouble(M3n[4].fz.y);
  959. M3n[1].writeBoolean(M3n[4].fz.d);
  960. M3n[1].writeBoolean(M3n[4].fz.p);
  961. M3n[1].writeBoolean(M3n[4].fz.a);
  962. M3n[1].writeShort(M3n[4].fz.t);
  963. + M3n[1].writeDouble(M3n[4].fz.cf);
  964. }
  965. M3n[1].writeShort(M3n[4].fx.length);
  966. for (M3n[28] = 0; M3n[28] < M3n[4].fx.length; M3n[28]++) {
  967. M3n[1].writeShort(M3n[4].fx[M3n[28]]);
  968. }
  969. }
  970. M3n[1].writeShort(M3n[0][0].spawns.length);
  971. for (
  972. M3n[30] = 0;
  973. M3n[30] < M3n[0][0].spawns.length;
  974. M3n[30]++
  975. ) {
  976. M3n[6] = M3n[0][0].spawns[M3n[30]];
  977. M3n[1].writeDouble(M3n[6].x);
  978. M3n[1].writeDouble(M3n[6].y);
  979. M3n[1].writeDouble(M3n[6].xv);
  980. M3n[1].writeDouble(M3n[6].yv);
  981. M3n[1].writeShort(M3n[6].priority);
  982. M3n[1].writeBoolean(M3n[6].r);
  983. M3n[1].writeBoolean(M3n[6].f);
  984. M3n[1].writeBoolean(M3n[6].b);
  985. M3n[1].writeBoolean(M3n[6].gr);
  986. M3n[1].writeBoolean(M3n[6].ye);
  987. M3n[1].writeUTF(M3n[6].n);
  988. }
  989. M3n[1].writeShort(M3n[0][0].capZones.length);
  990. for (
  991. M3n[74] = 0;
  992. M3n[74] < M3n[0][0].capZones.length;
  993. M3n[74]++
  994. ) {
  995. M3n[3] = M3n[0][0].capZones[M3n[74]];
  996. M3n[1].writeUTF(M3n[3].n);
  997. M3n[1].writeDouble(M3n[3].l);
  998. M3n[1].writeShort(M3n[3].i);
  999. M3n[1].writeShort(M3n[3].ty);
  1000. }
  1001. M3n[1].writeShort(M3n[9].joints.length);
  1002. for (M3n[89] = 0; M3n[89] < M3n[9].joints.length; M3n[89]++) {
  1003. M3n[5] = M3n[9].joints[M3n[89]];
  1004. if (M3n[5].type == "rv") {
  1005. M3n[1].writeShort(1);
  1006. M3n[1].writeDouble(M3n[5].d.la);
  1007. M3n[1].writeDouble(M3n[5].d.ua);
  1008. M3n[1].writeDouble(M3n[5].d.mmt);
  1009. M3n[1].writeDouble(M3n[5].d.ms);
  1010. M3n[1].writeBoolean(M3n[5].d.el);
  1011. M3n[1].writeBoolean(M3n[5].d.em);
  1012. M3n[1].writeDouble(M3n[5].aa[0]);
  1013. M3n[1].writeDouble(M3n[5].aa[1]);
  1014. }
  1015. if (M3n[5].type == "d") {
  1016. M3n[1].writeShort(2);
  1017. M3n[1].writeDouble(M3n[5].d.fh);
  1018. M3n[1].writeDouble(M3n[5].d.dr);
  1019. M3n[1].writeDouble(M3n[5].aa[0]);
  1020. M3n[1].writeDouble(M3n[5].aa[1]);
  1021. M3n[1].writeDouble(M3n[5].ab[0]);
  1022. M3n[1].writeDouble(M3n[5].ab[1]);
  1023. }
  1024. if (M3n[5].type == "lpj") {
  1025. M3n[1].writeShort(3);
  1026. M3n[1].writeDouble(M3n[5].pax);
  1027. M3n[1].writeDouble(M3n[5].pay);
  1028. M3n[1].writeDouble(M3n[5].pa);
  1029. M3n[1].writeDouble(M3n[5].pf);
  1030. M3n[1].writeDouble(M3n[5].pl);
  1031. M3n[1].writeDouble(M3n[5].pu);
  1032. M3n[1].writeDouble(M3n[5].plen);
  1033. M3n[1].writeDouble(M3n[5].pms);
  1034. }
  1035. if (M3n[5].type == "lsj") {
  1036. M3n[1].writeShort(4);
  1037. M3n[1].writeDouble(M3n[5].sax);
  1038. M3n[1].writeDouble(M3n[5].say);
  1039. M3n[1].writeDouble(M3n[5].sf);
  1040. M3n[1].writeDouble(M3n[5].slen);
  1041. }
  1042. if(M3n[5].type == "g"){
  1043. M3n[1].writeShort(5);
  1044. M3n[1].writeUTF(M3n[5].n);
  1045. M3n[1].writeShort(M3n[5].ja);
  1046. M3n[1].writeShort(M3n[5].jb);
  1047. M3n[1].writeDouble(M3n[5].r);
  1048. }
  1049. if(M3n[5].type != "g"){
  1050. M3n[1].writeShort(M3n[5].ba);
  1051. M3n[1].writeShort(M3n[5].bb);
  1052. M3n[1].writeBoolean(M3n[5].d.cc);
  1053. M3n[1].writeDouble(M3n[5].d.bf);
  1054. M3n[1].writeBoolean(M3n[5].d.dl);
  1055. }
  1056. }
  1057. M3n[32] = M3n[1].toBase64();
  1058. M3n[77] = LZString.compressToEncodedURIComponent(M3n[32]);
  1059. return M3n[77];
  1060. };
  1061. scope.decodeFromDatabase = function (map) {
  1062. var F5W = [arguments];
  1063. var b64mapdata = LZString.decompressFromEncodedURIComponent(map);
  1064. var binaryReader = new bytebuffer2;
  1065. binaryReader.fromBase64(b64mapdata, false);
  1066. 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: "", }};
  1067. map.physics = map.physics;
  1068. map.v = binaryReader.readShort();
  1069. if (map.v > 15) {
  1070. throw new Error("Future map version, please refresh page");
  1071. }
  1072. map.s.re = binaryReader.readBoolean();
  1073. map.s.nc = binaryReader.readBoolean();
  1074. if (map.v >= 3) {
  1075. map.s.pq = binaryReader.readShort();
  1076. }
  1077. if (map.v >= 4 && map.v <= 12) {
  1078. map.s.gd = binaryReader.readShort();
  1079. } else if (map.v >= 13) {
  1080. map.s.gd = binaryReader.readFloat();
  1081. }
  1082. if (map.v >= 9) {
  1083. map.s.fl = binaryReader.readBoolean();
  1084. }
  1085. map.m.rxn = binaryReader.readUTF();
  1086. map.m.rxa = binaryReader.readUTF();
  1087. map.m.rxid = binaryReader.readUint();
  1088. map.m.rxdb = binaryReader.readShort();
  1089. map.m.n = binaryReader.readUTF();
  1090. map.m.a = binaryReader.readUTF();
  1091. if (map.v >= 10) {
  1092. map.m.vu = binaryReader.readUint();
  1093. map.m.vd = binaryReader.readUint();
  1094. }
  1095. if (map.v >= 4) {
  1096. F5W[7] = binaryReader.readShort();
  1097. for (F5W[83] = 0; F5W[83] < F5W[7]; F5W[83]++) {
  1098. map.m.cr.push(binaryReader.readUTF());
  1099. }
  1100. }
  1101. if (map.v >= 5) {
  1102. map.m.mo = binaryReader.readUTF();
  1103. map.m.dbid = binaryReader.readInt();
  1104. }
  1105. if (map.v >= 7) {
  1106. map.m.pub = binaryReader.readBoolean();
  1107. }
  1108. if (map.v >= 8) {
  1109. map.m.dbv = binaryReader.readInt();
  1110. }
  1111. map.physics.ppm = binaryReader.readShort();
  1112. F5W[4] = binaryReader.readShort();
  1113. for (F5W[15] = 0; F5W[15] < F5W[4]; F5W[15]++) {
  1114. map.physics.bro[F5W[15]] = binaryReader.readShort();
  1115. }
  1116. F5W[6] = binaryReader.readShort();
  1117. for (F5W[28] = 0; F5W[28] < F5W[6]; F5W[28]++) {
  1118. F5W[5] = binaryReader.readShort();
  1119. if (F5W[5] == 1) {
  1120. map.physics.shapes[F5W[28]] = { type: "bx", w: 10, h: 40, c: [0, 0], a: 0.0, sk: false };
  1121. map.physics.shapes[F5W[28]].w = binaryReader.readDouble();
  1122. map.physics.shapes[F5W[28]].h = binaryReader.readDouble();
  1123. map.physics.shapes[F5W[28]].c = [
  1124. binaryReader.readDouble(),
  1125. binaryReader.readDouble(),
  1126. ];
  1127. map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
  1128. map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
  1129. }
  1130. if (F5W[5] == 2) {
  1131. map.physics.shapes[F5W[28]] = { type: "ci", r: 25, c: [0, 0], sk: false };
  1132. map.physics.shapes[F5W[28]].r = binaryReader.readDouble();
  1133. map.physics.shapes[F5W[28]].c = [
  1134. binaryReader.readDouble(),
  1135. binaryReader.readDouble(),
  1136. ];
  1137. map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
  1138. }
  1139. if (F5W[5] == 3) {
  1140. map.physics.shapes[F5W[28]] = { type: "po", v: [], s: 1, a: 0, c: [0, 0] };
  1141. map.physics.shapes[F5W[28]].s = binaryReader.readDouble();
  1142. map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
  1143. map.physics.shapes[F5W[28]].c = [
  1144. binaryReader.readDouble(),
  1145. binaryReader.readDouble(),
  1146. ];
  1147. F5W[74] = binaryReader.readShort();
  1148. map.physics.shapes[F5W[28]].v = [];
  1149. for (F5W[27] = 0; F5W[27] < F5W[74]; F5W[27]++) {
  1150. map.physics.shapes[F5W[28]].v.push([
  1151. binaryReader.readDouble(),
  1152. binaryReader.readDouble(),
  1153. ]);
  1154. }
  1155. }
  1156. }
  1157. F5W[71] = binaryReader.readShort();
  1158. for (F5W[17] = 0; F5W[17] < F5W[71]; F5W[17]++) {
  1159. 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 };
  1160. map.physics.fixtures[F5W[17]].sh = binaryReader.readShort();
  1161. map.physics.fixtures[F5W[17]].n = binaryReader.readUTF();
  1162. map.physics.fixtures[F5W[17]].fr = binaryReader.readDouble();
  1163. if (map.physics.fixtures[F5W[17]].fr == Number.MAX_VALUE) {
  1164. map.physics.fixtures[F5W[17]].fr = null;
  1165. }
  1166. F5W[12] = binaryReader.readShort();
  1167. if (F5W[12] == 0) {
  1168. map.physics.fixtures[F5W[17]].fp = null;
  1169. }
  1170. if (F5W[12] == 1) {
  1171. map.physics.fixtures[F5W[17]].fp = false;
  1172. }
  1173. if (F5W[12] == 2) {
  1174. map.physics.fixtures[F5W[17]].fp = true;
  1175. }
  1176. map.physics.fixtures[F5W[17]].re = binaryReader.readDouble();
  1177. if (map.physics.fixtures[F5W[17]].re == Number.MAX_VALUE) {
  1178. map.physics.fixtures[F5W[17]].re = null;
  1179. }
  1180. map.physics.fixtures[F5W[17]].de = binaryReader.readDouble();
  1181. if (map.physics.fixtures[F5W[17]].de == Number.MAX_VALUE) {
  1182. map.physics.fixtures[F5W[17]].de = null;
  1183. }
  1184. map.physics.fixtures[F5W[17]].f = binaryReader.readUint();
  1185. map.physics.fixtures[F5W[17]].d = binaryReader.readBoolean();
  1186. map.physics.fixtures[F5W[17]].np = binaryReader.readBoolean();
  1187. if (map.v >= 11) {
  1188. map.physics.fixtures[F5W[17]].ng = binaryReader.readBoolean();
  1189. }
  1190. if (map.v >= 12) {
  1191. map.physics.fixtures[F5W[17]].ig = binaryReader.readBoolean();
  1192. }
  1193. }
  1194. F5W[63] = binaryReader.readShort();
  1195. for (F5W[52] = 0; F5W[52] < F5W[63]; F5W[52]++) {
  1196. 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}};
  1197. map.physics.bodies[F5W[52]].type = binaryReader.readUTF();
  1198. map.physics.bodies[F5W[52]].n = binaryReader.readUTF();
  1199. map.physics.bodies[F5W[52]].p = [binaryReader.readDouble(), binaryReader.readDouble()];
  1200. map.physics.bodies[F5W[52]].a = binaryReader.readDouble();
  1201. map.physics.bodies[F5W[52]].fric = binaryReader.readDouble();
  1202. map.physics.bodies[F5W[52]].fricp = binaryReader.readBoolean();
  1203. map.physics.bodies[F5W[52]].re = binaryReader.readDouble();
  1204. map.physics.bodies[F5W[52]].de = binaryReader.readDouble();
  1205. map.physics.bodies[F5W[52]].lv = [
  1206. binaryReader.readDouble(),
  1207. binaryReader.readDouble(),
  1208. ];
  1209. map.physics.bodies[F5W[52]].av = binaryReader.readDouble();
  1210. map.physics.bodies[F5W[52]].ld = binaryReader.readDouble();
  1211. map.physics.bodies[F5W[52]].ad = binaryReader.readDouble();
  1212. map.physics.bodies[F5W[52]].fr = binaryReader.readBoolean();
  1213. map.physics.bodies[F5W[52]].bu = binaryReader.readBoolean();
  1214. map.physics.bodies[F5W[52]].cf.x = binaryReader.readDouble();
  1215. map.physics.bodies[F5W[52]].cf.y = binaryReader.readDouble();
  1216. map.physics.bodies[F5W[52]].cf.ct = binaryReader.readDouble();
  1217. map.physics.bodies[F5W[52]].cf.w = binaryReader.readBoolean();
  1218. map.physics.bodies[F5W[52]].f_c = binaryReader.readShort();
  1219. map.physics.bodies[F5W[52]].f_1 = binaryReader.readBoolean();
  1220. map.physics.bodies[F5W[52]].f_2 = binaryReader.readBoolean();
  1221. map.physics.bodies[F5W[52]].f_3 = binaryReader.readBoolean();
  1222. map.physics.bodies[F5W[52]].f_4 = binaryReader.readBoolean();
  1223. if (map.v >= 2) {
  1224. map.physics.bodies[F5W[52]].f_p = binaryReader.readBoolean();
  1225. }
  1226. if (map.v >= 14) {
  1227. map.physics.bodies[F5W[52]].fz.on = binaryReader.readBoolean();
  1228. if (map.physics.bodies[F5W[52]].fz.on) {
  1229. map.physics.bodies[F5W[52]].fz.x = binaryReader.readDouble();
  1230. map.physics.bodies[F5W[52]].fz.y = binaryReader.readDouble();
  1231. map.physics.bodies[F5W[52]].fz.d = binaryReader.readBoolean();
  1232. map.physics.bodies[F5W[52]].fz.p = binaryReader.readBoolean();
  1233. map.physics.bodies[F5W[52]].fz.a = binaryReader.readBoolean();
  1234. if(map.v >= 15){
  1235. map.physics.bodies[F5W[52]].t = binaryReader.readShort();
  1236. map.physics.bodies[F5W[52]].cf = binaryReader.readDouble();
  1237. }
  1238. }
  1239. }
  1240. F5W[88] = binaryReader.readShort();
  1241. for (F5W[65] = 0; F5W[65] < F5W[88]; F5W[65]++) {
  1242. map.physics.bodies[F5W[52]].fx.push(binaryReader.readShort());
  1243. }
  1244. }
  1245. F5W[97] = binaryReader.readShort();
  1246. for (F5W[41] = 0; F5W[41] < F5W[97]; F5W[41]++) {
  1247. 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"};
  1248. F5W[35] = map.spawns[F5W[41]];
  1249. F5W[35].x = binaryReader.readDouble();
  1250. F5W[35].y = binaryReader.readDouble();
  1251. F5W[35].xv = binaryReader.readDouble();
  1252. F5W[35].yv = binaryReader.readDouble();
  1253. F5W[35].priority = binaryReader.readShort();
  1254. F5W[35].r = binaryReader.readBoolean();
  1255. F5W[35].f = binaryReader.readBoolean();
  1256. F5W[35].b = binaryReader.readBoolean();
  1257. F5W[35].gr = binaryReader.readBoolean();
  1258. F5W[35].ye = binaryReader.readBoolean();
  1259. F5W[35].n = binaryReader.readUTF();
  1260. }
  1261. F5W[16] = binaryReader.readShort();
  1262. for (F5W[25] = 0; F5W[25] < F5W[16]; F5W[25]++) {
  1263. map.capZones[F5W[25]] = {"n":"Cap Zone","ty":1,"l":10,"i":-1};
  1264. map.capZones[F5W[25]].n = binaryReader.readUTF();
  1265. map.capZones[F5W[25]].l = binaryReader.readDouble();
  1266. map.capZones[F5W[25]].i = binaryReader.readShort();
  1267. if (map.v >= 6) {
  1268. map.capZones[F5W[25]].ty = binaryReader.readShort();
  1269. }
  1270. }
  1271. F5W[98] = binaryReader.readShort();
  1272. for (F5W[19] = 0; F5W[19] < F5W[98]; F5W[19]++) {
  1273. F5W[31] = binaryReader.readShort();
  1274. if (F5W[31] == 1) {
  1275. 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]};
  1276. F5W[20] = map.physics.joints[F5W[19]];
  1277. F5W[20].d.la = binaryReader.readDouble();
  1278. F5W[20].d.ua = binaryReader.readDouble();
  1279. F5W[20].d.mmt = binaryReader.readDouble();
  1280. F5W[20].d.ms = binaryReader.readDouble();
  1281. F5W[20].d.el = binaryReader.readBoolean();
  1282. F5W[20].d.em = binaryReader.readBoolean();
  1283. F5W[20].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1284. }
  1285. if (F5W[31] == 2) {
  1286. map.physics.joints[F5W[19]] = {"type":"d","d":{"fh":0,"dr":0,"cc":false,"bf":0,"dl":true},"aa":[0,0],"ab":[0,0]};
  1287. F5W[87] = map.physics.joints[F5W[19]];
  1288. F5W[87].d.fh = binaryReader.readDouble();
  1289. F5W[87].d.dr = binaryReader.readDouble();
  1290. F5W[87].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1291. F5W[87].ab = [binaryReader.readDouble(), binaryReader.readDouble()];
  1292. }
  1293. if (F5W[31] == 3) {
  1294. 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};
  1295. F5W[90] = map.physics.joints[F5W[19]];
  1296. F5W[90].pax = binaryReader.readDouble();
  1297. F5W[90].pay = binaryReader.readDouble();
  1298. F5W[90].pa = binaryReader.readDouble();
  1299. F5W[90].pf = binaryReader.readDouble();
  1300. F5W[90].pl = binaryReader.readDouble();
  1301. F5W[90].pu = binaryReader.readDouble();
  1302. F5W[90].plen = binaryReader.readDouble();
  1303. F5W[90].pms = binaryReader.readDouble();
  1304. }
  1305. if (F5W[31] == 4) {
  1306. map.physics.joints[F5W[19]] = {"type":"lsj","d":{"cc":false,"bf":0,"dl":true},"sax":0,"say":0,"sf":0,"slen":0};
  1307. F5W[44] = map.physics.joints[F5W[19]];
  1308. F5W[44].sax = binaryReader.readDouble();
  1309. F5W[44].say = binaryReader.readDouble();
  1310. F5W[44].sf = binaryReader.readDouble();
  1311. F5W[44].slen = binaryReader.readDouble();
  1312. }
  1313. if(F5W[31] == 5){
  1314. map.physics.joints[F5W[19]] = {type:"g",n:"",ja:-1,jb:-1,r:1};
  1315. F5W[91] = map.physics.joints[F5W[19]];
  1316. F5W[91].n = binaryReader.readUTF();
  1317. F5W[91].ja = binaryReader.readShort();
  1318. F5W[91].jb = binaryReader.readShort();
  1319. F5W[91].r = binaryReader.readDouble();
  1320.  
  1321. }
  1322. if(F5W[31]!=5){
  1323. map.physics.joints[F5W[19]].ba = binaryReader.readShort();
  1324. map.physics.joints[F5W[19]].bb = binaryReader.readShort();
  1325. map.physics.joints[F5W[19]].d.cc = binaryReader.readBoolean();
  1326. map.physics.joints[F5W[19]].d.bf = binaryReader.readDouble();
  1327. map.physics.joints[F5W[19]].d.dl = binaryReader.readBoolean();
  1328. }
  1329. }
  1330. return map;
  1331. };
  1332. scope.updateWssLog = function(){
  1333. if(!wsslogpaused){
  1334. if(logmenutable.children.length < wsssendrecievelog.length){
  1335. var bottomscroll = logmenutable.clientHeight + logmenutable.scrollTop >= logmenutable.scrollHeight-1;
  1336. while (logmenutable.children.length>1000) {
  1337. logmenutable.removeChild(logmenutable.firstChild);
  1338. logmenutable2.removeChild(logmenutable2.firstChild);
  1339. }
  1340. var loopthro = wsssendrecievelog.slice(packetcount);
  1341. for(var i = 0; i < loopthro.length;i++){
  1342. packetcount++;
  1343. var row = document.createElement("tr");
  1344. var row2 = document.createElement("tr");
  1345. var cell1 = document.createElement("td");
  1346. cell1.style["overflow-x"] = "scroll";
  1347. cell1.style["padding"] = "0px";
  1348. cell1.style["width"] = "100000px";
  1349. var cell2 = document.createElement("td");
  1350. cell2.style["overflow-x"] = "scroll";
  1351. cell2.style["padding"] = "0px";
  1352. cell2.style["width"] = "100000px";
  1353. if(debuggercount){
  1354. cell1.style["background"] = "rgb(178, 185, 189)";
  1355. debuggercount = false;
  1356. }
  1357. else{
  1358. cell2.style["background"] = "rgb(178, 185, 189)";
  1359. debuggercount = true;
  1360. }
  1361. cell1.textContent = loopthro[i][1];
  1362. cell2.textContent = loopthro[i][1];
  1363. if(loopthro[i][0] == 0){
  1364. cell2.style["color"] = "transparent";
  1365. cell1.onclick = function(){debuggerinput.value = this.textContent};
  1366. }
  1367. else{
  1368. cell1.style["color"] = "transparent";
  1369. cell2.onclick = function(){debuggerinput.value = this.textContent};
  1370. }
  1371. row.appendChild(cell1);
  1372. row2.appendChild(cell2);
  1373. logmenutable.appendChild(row);
  1374. logmenutable2.appendChild(row2);
  1375. }
  1376. while (logmenutable.children.length>1000) {
  1377. logmenutable.removeChild(logmenutable.firstChild);
  1378. logmenutable2.removeChild(logmenutable2.firstChild);
  1379. }
  1380. if(bottomscroll){
  1381. logmenutable.scrollTop = logmenutable.scrollHeight;
  1382. logmenutable2.scrollTop = logmenutable.scrollHeight;
  1383. }
  1384. }
  1385. }
  1386. };
  1387. Gdocument.getElementById("maploadwindowmapscontainer").appendChild = function(args){
  1388. var checkbox = Gdocument.createElement("input");
  1389. checkbox.type = "checkbox";
  1390. checkbox.style["position"]="absolute";
  1391. checkbox.style["margin-top"] = "135px";
  1392. checkbox.style["margin-left"] = "140px";
  1393. checkbox.style["scale"] = "2";
  1394. checkbox.style["display"] = "none";
  1395. checkbox.className = "quickplaycheckbox quickplayunchecked";
  1396. if(ishost && stopquickplay==0){
  1397. checkbox.style["display"] = "block";
  1398. checkbox.className = "quickplaycheckbox quickplaychecked";
  1399. }
  1400. checkbox.checked = true;
  1401. checkbox.onclick = function(e){e.stopPropagation();};
  1402. args.appendChild(checkbox);
  1403. originalMapLoad.call(this,args);
  1404. };
  1405. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  1406. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1407. if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  1408. var kickedorbanned = "banned";
  1409. if(onlykicked){
  1410. kickedorbanned = "kicked";
  1411. }
  1412. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game ";
  1413. }
  1414. }
  1415. setTimeout(function(){
  1416. if(args.textContent.startsWith("* ") && args.children.length>=5){
  1417. var newarg = args.cloneNode();
  1418. for(var i = 0;i<args.children.length;i++){
  1419. var newarg2 = args.children[i].cloneNode();
  1420. newarg2.textContent = args.children[i].textContent;
  1421. newarg2.style.color = '#ffffffd6';
  1422. newarg2.onclick = args.children[i].onclick;
  1423. newarg2.suggestID = args.children[i].suggestID;
  1424. newarg.appendChild(newarg2);
  1425. }
  1426. Gdocument.getElementById("ingamechatcontent").appendChild(newarg);
  1427. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  1428. }},0);
  1429. originalLobbyChat.call(this,args);
  1430. };
  1431. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  1432. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1433. if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  1434. var kickedorbanned = "banned";
  1435. if(onlykicked){
  1436. kickedorbanned = "kicked";
  1437. }
  1438. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game.";
  1439. }
  1440. }
  1441. if(recordedTimeStamp+100>Date.now() && args.children.length>0){
  1442. if(args.children[0].textContent.includes("seconds") && args.children[0].textContent.startsWith("* ")){
  1443. args.children[0].textContent = args.children[0].textContent + " - " + playerids[recordedId].userName;
  1444. }
  1445. }
  1446. originalIngameChat.call(this,args);
  1447. };
  1448. Gwindow.Date.now = function(){
  1449. if(overideDate[0]){
  1450. return overideDate[1];
  1451. }
  1452. else if(causelag){
  1453. return originalDatenow.call(this,...arguments)-causelag2;
  1454. }
  1455. return originalDatenow.call(this,...arguments);
  1456. };
  1457. Gwindow.XMLHttpRequest.prototype.open = function(_, url) {
  1458. if (url.includes("scripts/map_get") || url.includes("scripts/map_b1_get") || url.includes("scripts/hotmaps/")) {
  1459. if(searchrequested==1){
  1460. Gdocument.getElementById("maploadtypedropdowntitle").click();
  1461. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  1462. dropdownrequested.style["display"] = "none";
  1463. clearmaprequests.style["display"] = "block";
  1464. refreshmaprequests.style["display"] = "block";
  1465. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  1466. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  1467. searchrequested = 0;
  1468. this.isSearchMap = true;
  1469. }
  1470. }
  1471. else if(url.includes("getrooms.php")){
  1472. this.isGetRooms = true;
  1473. }
  1474. else if(url.includes("getroomaddress.php")){
  1475. this.isGetRoomAddress = true;
  1476. }
  1477. originalXMLOpen.call(this, ...arguments);
  1478. };
  1479. Gwindow.XMLHttpRequest.prototype.send = function(data) {
  1480. if(this.isGetRoomAddress){
  1481. currentroomaddress = parseInt(data.slice(3));
  1482. }
  1483. else if(this.isGetRooms && inroom){
  1484. this.onreadystatechange = function(){
  1485. if(this.readyState == 4){
  1486. lastrooms = JSON.parse(this.response)["rooms"];
  1487. if(lastrooms){
  1488. var keys = Object.keys(savedroomsdata);
  1489. for(var i = 0;i<lastrooms.length;i++){
  1490. if(savedrooms.includes(lastrooms[i].id)){
  1491. exists = true;
  1492. savedroomsdata[lastrooms[i].id] = lastrooms[i];
  1493. savedroomsdata[lastrooms[i].id].exists = true;
  1494. savedroomsdata[lastrooms[i].id].exists2 = true;
  1495. if(lastrooms[i].maxplayers>lastrooms[i].players){
  1496. if(inroom){
  1497. if(lastrooms[i].id!=currentroomaddress){
  1498. displayInChat('The room '+JSON.stringify(lastrooms[i].roomname)+' is now open with '+lastrooms[i].players+"/"+lastrooms[i].maxplayers+" players.","#DA0808","#1EBCC1");
  1499. savedrooms.splice(savedrooms.indexOf(lastrooms[i].id),1);
  1500. delete savedroomsdata[lastrooms[i].id];
  1501. keys.splice(keys.indexOf((lastrooms[i].id).toString()),1);
  1502. }
  1503. else{
  1504. savedrooms.splice(savedrooms.indexOf(lastrooms[i].id),1);
  1505. delete savedroomsdata[lastrooms[i].id];
  1506. keys.splice(keys.indexOf((lastrooms[i].id).toString()),1);
  1507. }
  1508. }
  1509. }
  1510. }
  1511. }
  1512. for(var i = 0;i<keys.length;i++){
  1513. if(!savedroomsdata[keys[i]].exists2){
  1514. savedroomsdata[keys[i]].exists = false;
  1515. }
  1516. savedroomsdata[keys[i]].exists2 = false;
  1517. }
  1518. for(var i = 0;i<keys.length;i++){
  1519. if(!savedroomsdata[keys[i]].exists){
  1520. savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])),1);
  1521. displayInChat('The room '+JSON.stringify(savedroomsdata[keys[i]].roomname)+" does not exist anymore.","#DA0808","#1EBCC1");
  1522. delete savedroomsdata[keys[i]];
  1523. }
  1524. }
  1525. }
  1526. }
  1527. }
  1528. }
  1529. else if (this.isSearchMap) {
  1530. this.onreadystatechange = function () {
  1531. if (this.readyState == 4){
  1532. var jsonargs = {r:"success",maps:[],more:true};
  1533. for(var i = 0; i<requestedmaps.length; i++){
  1534. var dec = requestedmaps[i][0];
  1535. var undec = requestedmaps[i][1];
  1536. var map = {};
  1537. map.id = dec["m"]["dbid"];
  1538. map.name = dec["m"]["n"];
  1539. map.authorname = dec["m"]["a"];
  1540. map.leveldata = undec;
  1541. map.publisheddate = dec["m"]["date"];
  1542. map.remixauthor = dec["m"]["rxa"];
  1543. map.remixdb = dec["m"]["rxdb"];
  1544. map.remixid = dec["m"]["rxid"];
  1545. map.remixname = dec["m"]["rxn"];
  1546. map.vd = dec["m"]["vd"];
  1547. map.vu = dec["m"]["vu"];
  1548. jsonargs.maps.push(map);
  1549. }
  1550. jsonargs2 = JSON.stringify(jsonargs);
  1551. function stringifyjsonargs(){
  1552. return jsonargs2;
  1553. }
  1554. this.__defineGetter__("responseText", stringifyjsonargs);
  1555. this.__defineGetter__("response", stringifyjsonargs);
  1556. }
  1557. }
  1558. }
  1559. originalXMLSend.call(this, ...arguments);
  1560. };
  1561. scope.STB = function(x){
  1562. if(x == "0"){
  1563. return 0;
  1564. }
  1565. else{
  1566. return 1;
  1567. }
  1568. };
  1569. scope.BTS = function(x){
  1570. if(x == 0){
  1571. return "0";
  1572. }
  1573. else{
  1574. return "1";
  1575. }
  1576. };
  1577. scope.GET_KEYS = function(x){
  1578. var x2 = ((x+64)>>>0).toString(2).substring(1).split("");
  1579. 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])}
  1580. };
  1581. scope.MAKE_KEYS = function(x){
  1582. return x.special*32+x.heavy*16+x.down*8+x.up*4+x.right*2+x.left
  1583. };
  1584. Gwindow.PIXI.Graphics.prototype.drawCircle = function(...args){
  1585. var This = this;
  1586. var Args = [...args];
  1587. setTimeout(function(){
  1588. if(This.parent){
  1589. var childs = This.parent.children;
  1590. var user = 0;
  1591. for(var i = 0;i<childs.length;i++){
  1592. if(childs[i]._text){
  1593. user = childs[i]._text;
  1594. }
  1595. if(i==2 && childs[i]!=This){
  1596. return;
  1597. }
  1598. }
  1599. var keys = Object.keys(playerids);
  1600. for(var i = 0;i<keys.length;i++){
  1601. if(playerids[keys[i]].userName == user){
  1602. playerids[keys[i]].playerData = This.parent;
  1603. if(!playerids[keys[i]].playerData2){
  1604. 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};
  1605. }
  1606. playerids[keys[i]].playerData2.radius = Args[2];
  1607. parentDraw = This.parent;
  1608. while(parentDraw.parent){
  1609. parentDraw = parentDraw.parent;
  1610. }
  1611. }
  1612. }
  1613. }
  1614. },0);
  1615. return originalDrawCircle.call(this,...args);
  1616. };
  1617. Gwindow.requestAnimationFrame = function(...args){
  1618. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1619. while(parentDraw.parent){
  1620. parentDraw = parentDraw.parent;
  1621. }
  1622. var canv = 0;
  1623. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  1624. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  1625. canv = Gdocument.getElementById("gamerenderer").children[i];
  1626. break;
  1627. }
  1628. }
  1629. var width = parseInt(canv.style["width"]);
  1630. var height = parseInt(canv.style["height"]);
  1631. scale = (parseInt(canv.style["width"])/730);
  1632. var now = Date.now();
  1633. var keys = Object.keys(playerids);
  1634. addto = {"children":[]};
  1635. for(var i = 0;i<parentDraw.children.length;i++){
  1636. if(parentDraw.children[i].constructor.name == "e"){
  1637. addto = parentDraw.children[i];
  1638. break;
  1639. }
  1640. }
  1641. if(pan_enabled && Gdocument.getElementById("gamerenderer")?.childElementCount>0 && (keys_being_held["ShiftLeft"] || keys_being_held["ShiftRight"])){
  1642. var temp_zoom = zoom;
  1643. if(keys_being_held["ArrowUp"]){
  1644. pan.y+=pan_speed/temp_zoom;
  1645. }
  1646. if(keys_being_held["ArrowDown"]){
  1647. pan.y-=pan_speed/temp_zoom;
  1648. }
  1649. if(keys_being_held["ArrowRight"]){
  1650. pan.x-=pan_speed/temp_zoom;
  1651. }
  1652. if(keys_being_held["ArrowLeft"]){
  1653. pan.x+=pan_speed/temp_zoom;
  1654. }
  1655. }
  1656. var panx = 0;
  1657. var pany = 0;
  1658. if(pan){
  1659. panx = pan.x;
  1660. pany = pan.y;
  1661. }
  1662. if(autocam){
  1663. var autocamx = 365*scale;
  1664. var autocamy = 250*scale;
  1665. if(FollowCam && playerids[myid].playerData?.transform){
  1666. autocamx = playerids[myid].playerData.transform.position.x;
  1667. autocamy = playerids[myid].playerData.transform.position.y;
  1668. }
  1669. var distances = {};
  1670. for(var i = 0;i<keys.length;i++){
  1671. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2){
  1672. if(playerids[keys[i]].playerData.transform){
  1673. var ypos = playerids[keys[i]].playerData.transform.position.y;
  1674. if(ypos>460*scale && ypos< 500 * scale){
  1675. ypos = scale * 460;
  1676. }
  1677. distances[keys[i]] = [playerids[keys[i]].playerData.transform.position.x-autocamx,ypos-autocamy];
  1678. }
  1679. }
  1680. }
  1681. distances["topleft"] = [autocamx-40,autocamy-40];
  1682. distances["topright"] = [690*scale-autocamx,autocamy-40];
  1683. distances["bottomleft"] = [autocamx-40,460*scale-autocamy];
  1684. distances["bottomright"] = [690*scale-autocamx,460*scale-autocamy];
  1685. var lowestD = [-1,-1];
  1686. var keys2 = Object.keys(distances);
  1687. for(var i = 0;i<keys2.length;i++){
  1688. if(Math.abs(distances[keys2[i]][0]/scale)>lowestD[0]){
  1689. lowestD[0] = Math.abs(distances[keys2[i]][0]/scale);
  1690. }
  1691. if(Math.abs(distances[keys2[i]][1]/scale)>lowestD[1]){
  1692. lowestD[1] = Math.abs(distances[keys2[i]][1]/scale);
  1693. }
  1694. }
  1695. var horizontal = (lowestD[0])/345;
  1696. var vertical = (lowestD[1])/230;
  1697. newzoom = Math.min(Math.abs(1/Math.max(horizontal,vertical)),1);
  1698. }
  1699. else{
  1700. newzoom = 1;
  1701. }
  1702. newzoom2 = newzoom2 + 0.15*(newzoom-newzoom2);
  1703. zoom2 = zoom2 + 0.15*(zoom-zoom2);
  1704. addto.scale.x = newzoom2 * zoom2;
  1705. addto.scale.y = newzoom2 * zoom2;
  1706. if(holdheavy>0){
  1707. if(holdheavy==1){
  1708. holdheavy = -1;
  1709. }
  1710. else{
  1711. holdheavy-=1;
  1712. }
  1713. }
  1714. if(playerids[myid].playerData?.children){
  1715. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1716. if(playerids[myid].playerData.children[i].alpha!=1){
  1717. heavyid = i;
  1718. }
  1719. if(playerids[myid].playerData.children[i].vertextData){
  1720. if(playerids[myid].playerData.children[i].vertextData.length == 0){
  1721. specialid = i;
  1722. }
  1723. }
  1724. }
  1725. }
  1726. for(var i = 0;i<keys.length;i++){
  1727. if(allstyles[playerids[keys[i]].userName]){
  1728. var isadmin = [false,0];
  1729. for(var i3 = 0;i3<admins.length;i3++){
  1730. if(admins[i3][0] == playerids[keys[i]].userName && !playerids[keys[i].guest]){
  1731. isadmin = [true,i3];
  1732. break;
  1733. }
  1734. }
  1735. if(playerids[keys[i]].playerData?.children){
  1736. for(var i2 = 0;i2<playerids[keys[i]].playerData.children.length;i2++){
  1737. if(playerids[keys[i]].playerData.children[i2].text){
  1738. if(allstyles[playerids[keys[i]].userName][0]==0 && allstyles[playerids[keys[i]].userName][1]==0 && allstyles[playerids[keys[i]].userName][2]==0){
  1739. playerids[keys[i]].playerData.children[i2].tint = 255*256**3-1;
  1740. }
  1741. else{
  1742. 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];
  1743. }
  1744. }
  1745. }
  1746. }
  1747. if(isadmin[1]<=3){
  1748. if(isadmin[0]){
  1749. if(playerids[keys[i]].playerData?.children && playerids[keys[i]].guest==false){
  1750. for(var i2 = 0;i2<playerids[keys[i]].playerData.children.length;i2++){
  1751. 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)){
  1752. 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]);
  1753. }
  1754. if(!Array.isArray(playerids[keys[i]].playerData.children[i2].filters)){
  1755. playerids[keys[i]].playerData.children[i2].filters = [new Gwindow.PIXI.filters.ColorMatrixFilter()];
  1756. playerids[keys[i]].playerData.children[i2].filters[0].resolution = 3;
  1757. }
  1758. var rotatevalue = 0;
  1759. if(admins[isadmin[1]][1][3]<90){
  1760. rotatevalue = admins[isadmin[1]][1][3]/2;
  1761. }
  1762. else if(admins[isadmin[1]][1][3]<270){
  1763. rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  1764. }
  1765. else if(admins[isadmin[1]][1][3]<360){
  1766. rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  1767. }
  1768. playerids[keys[i]].playerData.children[i2].filters[0].hue(rotatevalue);
  1769. }
  1770. }
  1771. }
  1772. }
  1773. }
  1774. }
  1775. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1776. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1777. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1778. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1779. if(canvasWidth!=width){
  1780. canvasWidth = width;
  1781. pixiCircle.clear();
  1782. pixiCircle.x = parseInt(canv.style["width"])/2;
  1783. pixiCircle.y = parseInt(canv.style["height"])/2;
  1784. pixiCircle.lineStyle(3, 0x8B8000);
  1785. pixiCircle.drawRect(-parseInt(canv.style["width"])/2,-parseInt(canv.style["height"])/2,parseInt(canv.style["width"]),parseInt(canv.style["height"]));
  1786. pixiCircle.lineStyle(3, 0xFF0000);
  1787. pixiCircle.arc(0, 0, 850*scale,Math.atan2(250,-100*Math.sqrt(66)),Math.atan2(250,100*Math.sqrt(66)));
  1788. pixiCircle.lineTo(-100*Math.sqrt(66)*scale,250*scale);
  1789. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1790. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1791. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1792. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1793. }
  1794. if(!addto.children.includes(container)){
  1795. addto.addChild(container);
  1796. }
  1797. if(keys.length>0){
  1798. if(playerids[myid].playerData && playerids[myid].playerData2){
  1799. if(aimbot || heavybot || staystill){
  1800. var targetid = -1;
  1801. var distances = {};
  1802. if(Gdocument.getElementById("ingamecountdown").style["visibility"] == "hidden"){
  1803. if(playerids[myid].playerData.transform){
  1804. var teamok = true;
  1805. if(playerids[myid].team>1){
  1806. teamok = false;
  1807. }
  1808. for(var i = 0;i<keys.length;i++){
  1809. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2 && keys[i]!=myid){
  1810. if(playerids[keys[i]].playerData.transform && (playerids[keys[i]].team != playerids[myid].team || teamok || FFA)){
  1811. 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);
  1812. }
  1813. }
  1814. }
  1815. }
  1816. }
  1817. var lowestD = [-1,-1];
  1818. var keys2 = Object.keys(distances);
  1819. for(var i = 0;i<keys2.length;i++){
  1820. if(myid != keys2[i]){
  1821. if(lowestD[1] == -1){
  1822. lowestD[1] = distances[keys2[i]];
  1823. lowestD[0] = keys2[i];
  1824. }
  1825. else if(distances[keys2[i]]<lowestD[1]){
  1826. lowestD[1] = distances[keys2[i]];
  1827. lowestD[0] = keys2[i];
  1828. }
  1829. }
  1830. }
  1831. targetid = lowestD[0];
  1832. if(playerids[myid].playerData?.transform && playerids[myid].playerData2){
  1833. if(staystill & staystillpos[0]!=null){
  1834. var playerpos = playerids[myid].playerData.transform.position;
  1835. if(Math.abs(staystillpos[0]-playerpos.x/scale)<3){
  1836. if(playerids[myid].playerData2.xvel/scale>0){
  1837. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1838. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1839. }
  1840. else if(playerids[myid].playerData2.xvel/scale<0){
  1841. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1842. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1843. }
  1844. else{
  1845. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1846. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1847. }
  1848. }
  1849. else{
  1850. if(staystillpos[0]>playerpos.x/scale){
  1851. if(playerids[myid].playerData2.xvel/scale>10){
  1852. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1853. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1854. }
  1855. else{
  1856. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1857. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1858. }
  1859. }
  1860. else if(staystillpos[0]<playerpos.x/scale){
  1861. if(playerids[myid].playerData2.xvel/scale<-10){
  1862. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1863. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1864. }
  1865. else{
  1866. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1867. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1868. }
  1869. }
  1870. }
  1871. }
  1872. }
  1873. if(targetid != -1 && playerids[myid].playerData?.transform){
  1874. if(playerids[myid].playerData.children.length >= 7 && playerids[targetid].playerData && playerids[targetid].playerData.transform && playerids[targetid].playerData2 && aimbot){
  1875. var indexE = -1;
  1876. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1877. if(playerids[myid].playerData.children[i].constructor.name == "e"){
  1878. indexE = i;
  1879. break;
  1880. }
  1881. }
  1882. if(indexE != -1 && playerids[myid].playerData.children[indexE].visible){
  1883. if(started == 0){
  1884. started = now;
  1885. }
  1886. var scale2=1/(parseInt(canv.style["width"])/730);
  1887. scale2 /= scale/(1 + playerids[myid].playerData2.balance*0.0088)*(playerids[myid].playerData2.radius/12);
  1888. var Dstarted = (Math.min((now-started)/1000,10/3)/(10/3));
  1889. var v = multiplier * (Dstarted*100+15)*scale2;
  1890. var g = gravity;
  1891. var mypos = playerids[myid].playerData.transform.position;
  1892. var targetpos = playerids[targetid].playerData.transform.position;
  1893. var deltapos = [(targetpos.x-mypos.x)*scale2,(targetpos.y-mypos.y)*scale2];
  1894. var dis = (Math.sqrt(deltapos[0]**2 + deltapos[1]**2))/v*prediction;
  1895. deltapos[0]+=(playerids[targetid].playerData2.xvel*scale2*dis+(playerids[targetid].playerData2.xacc*scale2*(dis))**2/2);
  1896. deltapos[1]+=(playerids[targetid].playerData2.yvel*scale2*dis+(playerids[targetid].playerData2.yacc*scale2*(dis))**2/2);
  1897. deltapos[1] = -deltapos[1];
  1898. var angle = positive(-Math.atan2(deltapos[1],deltapos[0]));
  1899. var rot = playerids[myid].playerData.children[indexE].transform.rotation;
  1900. rot = positive(rot);
  1901. angle = positive(angle);
  1902. var alpha = deltapos[0];
  1903. var beta = deltapos[1];
  1904. var v_squared = v**2;
  1905. var eff = 2*v_squared/g;
  1906. var rootterm = eff*(eff-2*beta)-2*alpha**2;
  1907. if(rootterm < 0) {
  1908. } else {
  1909. gamma_first = (eff + Math.sqrt(rootterm));
  1910. gamma_second = (eff - Math.sqrt(rootterm));
  1911. theta_first = positive(-Math.atan2(gamma_first, alpha));
  1912. theta_second = positive(-Math.atan2(gamma_second, alpha));
  1913. if(angle_between(angle,theta_first)<angle_between(angle,theta_second)){
  1914. angle = theta_first;
  1915. }
  1916. else{
  1917. angle = theta_second;
  1918. }
  1919. }
  1920. var min = angle_between(angle,rot);
  1921. if(angle_between2(angle,rot)<0){
  1922. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1923. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1924. }
  1925. else{
  1926. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1927. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1928. }
  1929. if(min<0.05){
  1930. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1931. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1932. }
  1933. }
  1934. else if(started>0){
  1935. started = 0;
  1936. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1937. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1938. }
  1939. }
  1940. }
  1941. if(playerids[myid].playerData?.transform && heavybot && mode!="f" && mode!="bs"){
  1942. var myradius = playerids[myid].playerData2.radius / scale;
  1943. var mypos = playerids[myid].playerData.transform.position;
  1944. var breakout = false;
  1945. for(var i = 0;i<keys2.length;i++){
  1946. var targetradius = playerids[keys2[i]].playerData2.radius / scale;
  1947. var targetpos = playerids[keys2[i]].playerData.transform.position;
  1948. var deltapos = [(targetpos.x-mypos.x)/scale,(targetpos.y-mypos.y)/scale];
  1949. for(var i2 = 0;i2<160;i2++){
  1950. deltapos2 = [...deltapos];
  1951. var i3 = i2*0.5;
  1952. deltapos2[0]+=((playerids[keys2[i]].playerData2.xvel-playerids[myid].playerData2.xvel)/scale*i3);
  1953. deltapos2[1]+=((playerids[keys2[i]].playerData2.yvel-playerids[myid].playerData2.yvel)/scale*i3);
  1954. var dis = Math.sqrt(deltapos2[0]**2+deltapos2[1]**2);
  1955. if(dis<myradius+targetradius){
  1956. breakout = true;
  1957. holdheavy = 20;
  1958. break;
  1959. }
  1960. }
  1961. if(breakout){
  1962. break;
  1963. }
  1964. }
  1965. if(holdheavy>0){
  1966. if(!heavyheld2){
  1967. heavyheld = playerids[myid].playerData.children[heavyid].alpha>0;
  1968. }
  1969. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1970. heavyheld2 = true;
  1971. if(mode == "sp"){
  1972. if(!grappleheld2){
  1973. grappleheld = playerids[myid].playerData.children[specialid].vertexData?.length>0;
  1974. }
  1975. if(grappleheld){
  1976. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1977. }
  1978. grappleheld2 = true;
  1979. }
  1980. }
  1981. else if(holdheavy<0){
  1982. holdheavy = 0;
  1983. heavyheld2 = false;
  1984. grappleheld2 = false;
  1985. if(!heavyheld){
  1986. heavyheld = false;
  1987. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1988. }
  1989. if(grappleheld && mode == "sp"){
  1990. grappleheld = false;
  1991. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1992. }
  1993. }
  1994. else{
  1995. heavyheld2 = false;
  1996. heavyheld = false;
  1997. grappleheld2 = false;
  1998. grappleheld = false;
  1999. }
  2000. }
  2001. }
  2002. if(FollowCam){
  2003. if(playerids[myid].playerData?.transform){
  2004. pixiCircle.visible = true;
  2005. parentDraw.x = -playerids[myid].playerData.x*addto.scale.x+parseInt(width)/2;
  2006. parentDraw.y = -playerids[myid].playerData.y*addto.scale.y+parseInt(height)/2;
  2007. parentDraw.children[0].x = playerids[myid].playerData.x*addto.scale.x-parseInt(width)/2;
  2008. parentDraw.children[0].y = playerids[myid].playerData.y*addto.scale.y-parseInt(height)/2;
  2009. }
  2010. else{
  2011. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  2012. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  2013. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  2014. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  2015. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  2016. pixiCircle.visible = false;
  2017. }
  2018. else{
  2019. pixiCircle.visible = true;
  2020. }
  2021. }
  2022. }
  2023. }
  2024. }
  2025. if(!FollowCam){
  2026. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !pan_enabled){
  2027. pixiCircle.visible = false;
  2028. }
  2029. else{
  2030. pixiCircle.visible = true;
  2031. }
  2032. }
  2033. parentDraw.x+=panx*addto.scale.x;
  2034. parentDraw.y+=pany*addto.scale.y;
  2035. parentDraw.children[0].x-=panx*addto.scale.x;
  2036. parentDraw.children[0].y-=pany*addto.scale.y;
  2037. }
  2038. if(maxfps){
  2039. return setTimeout.call(this,...args);
  2040. }
  2041. return requestAnimationFrameOriginal.call(this,...args);
  2042. };
  2043. scope.SENDFUNCTION = function(args){return args;};
  2044. scope.RECIEVEFUNCTION = function(args){return args;};
  2045. scope.EVENTLOOPFUNCTION = function(){};
  2046. Gwindow.WebSocket.prototype.send = function(args) {
  2047. if(this.url.includes("socket.io/?EIO=3&transport=websocket&sid=")){
  2048. if(typeof(args) == "string" && !bonkwssextra.includes(this)){
  2049. args = SENDFUNCTION(args);
  2050. wsssendlog.push(args);
  2051. wsssendrecievelog.push([0,args]);
  2052. if(!bonkwss){
  2053. bonkwss = this;
  2054. }
  2055. if(args.startsWith('42[26,')){
  2056. var jsonargs = JSON.parse(args.substring(2));
  2057. if(sandboxon){
  2058. if(typeof(sandboxplayerids[jsonargs[1]["targetID"]])!='undefined'){
  2059. var packet = '42[18,'+jsonargs[1]["targetID"]+','+jsonargs[1]["targetTeam"]+']';
  2060. RECIEVE(packet);
  2061. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  2062. }
  2063. }
  2064. }
  2065. if(args.startsWith('42[9,')){
  2066. var jsonargs = JSON.parse(args.substring(2));
  2067. if(sandboxon){
  2068. if(typeof(sandboxplayerids[jsonargs[1]["banshortid"]])!='undefined'){
  2069. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  2070. var packet = '42[24,'+jsonargs[1]["banshortid"].toString()+','+jsonargs[1]["kickonly"]+']';
  2071. var packet2 = '42[5,'+jsonargs[1]["banshortid"].toString()+',0]';
  2072. RECIEVE(packet);
  2073. RECIEVE(packet2);
  2074. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet,packet2],to:[-1]}]));
  2075. }
  2076. else{
  2077. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  2078. }
  2079. }
  2080. }
  2081. }
  2082. if(args.startsWith('42[1,')){
  2083. return;
  2084. }
  2085. if(args.startsWith('42[4,')){
  2086. var jsonargs = JSON.parse(args.substring(2));
  2087. if(sandboxcopyme==myid && typeof(jsonargs[1]["i"])!="undefined"){
  2088. var jsonkeys = Object.keys(sandboxplayerids);
  2089. var jsonargs2 = jsonargs[1];
  2090. for(var i = 0; i<jsonkeys.length;i++){
  2091. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2092. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2093. RECIEVE(packet);
  2094. }
  2095. jsonargs2["c"] = "CVALUE";
  2096. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2097. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2098. }
  2099. if(typeof(jsonargs[1]["i"]) != "undefined"){
  2100. if(playerids[myid].movecount>=jsonargs[1]["c"]){
  2101. jsonargs[1]["c"] = playerids[myid].movecount;
  2102. playerids[myid].movecount+=1;
  2103. }
  2104. else{
  2105. playerids[myid].movecount = jsonargs[1]["c"]+1;
  2106. }
  2107. }
  2108. if(recording && typeof(jsonargs[1]["i"])!="undefined"){
  2109. if(myid.toString() == recordingid){
  2110. if(recordingdata.length == 0){
  2111. recordingdata.push([jsonargs[1]["i"],jsonargs[1]["f"]]);
  2112. }
  2113. else{
  2114. recordingdata.push([jsonargs[1]["i"],jsonargs[1]["f"]-recordingdata[0][1]]);
  2115. }
  2116. }
  2117. }
  2118. playerids[myid].lastmove = Date.now();
  2119. if(ishost && typeof(jsonargs[1]["i"])!="undefined"){
  2120. for(var i = 0;i<disabledkeys.length;i++){
  2121. if(GET_KEYS(jsonargs[1]["i"])[disabledkeys[i]]){
  2122. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(myid)){
  2123. killedids.push(myid);
  2124. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2125. SEND('42[25,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2126. RECIEVE('42[31,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2127. break;
  2128. }
  2129. }
  2130. }
  2131. }
  2132. args = "42"+JSON.stringify(jsonargs);
  2133. }
  2134. if(args.startsWith('42[29,')){
  2135. var jsonargs = JSON.parse(args.substring(2));
  2136. playerids[jsonargs[1]["sid"]].playerData2.balance = jsonargs[1]["bal"];
  2137. if(sandboxon){
  2138. if(typeof(sandboxplayerids[jsonargs[1]["sid"]])!='undefined'){
  2139. var packet = '42[36,'+jsonargs[1]["sid"]+','+jsonargs[1]["bal"]+']';
  2140. RECIEVE(packet);
  2141. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  2142. }
  2143. }
  2144. }
  2145. if(args.startsWith('42[12,')){
  2146. playerids = {};
  2147. var jsonargs2 = JSON.parse(args.substring(2));
  2148. var jsonargs = jsonargs2[1];
  2149. 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}};
  2150. allstyles[username] = [0,0,0];
  2151. myid = 0;
  2152. bonkwss = this;
  2153. hostid = 0;
  2154. inroom = true;
  2155. if(savedrooms.length>0){
  2156. Gdocument.getElementById("roomlistrefreshbutton").click();
  2157. }
  2158. }
  2159. if(args.startsWith('42[10')){
  2160. var jsonargs = JSON.parse(args.substring(2));
  2161. if(jsonargs[2]){
  2162. args = "42"+JSON.stringify([10,jsonargs[1]]);
  2163. }
  2164. else if(translating2[0]){
  2165. text = translate(jsonargs[1]["message"],"auto",translating2[1]).then(function(r){SEND("42"+JSON.stringify([10,{"message":r},true]))});
  2166. return;
  2167. }
  2168. }
  2169. if (args.startsWith('42[23,')) {
  2170. var jsonargs = JSON.parse(args.substring(2));
  2171. var map = decodeFromDatabase(jsonargs[1]["m"]);
  2172. currentmap.push(map);
  2173. }
  2174. if(args.startsWith('42[23,') && recteams){
  2175. var jsonargs = JSON.parse(args.substring(2));
  2176. var map = decodeFromDatabase(jsonargs[1]["m"]);
  2177. var spawns = map["spawns"];
  2178. var teamsneeded = true;
  2179. var excludedindexes = [];
  2180. var ffaspawns = false;
  2181. var ffaforsure = false;
  2182. for(var i = 0; i<spawns.length;i++){
  2183. var currentSpawn = spawns[i];
  2184. if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 || currentSpawn.y>250){
  2185. excludedindexes.push(i);
  2186. }
  2187. else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  2188. excludedindexes.push(i);
  2189. }
  2190. else if(currentSpawn.f){
  2191. ffaspawns = true;
  2192. if(!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  2193. excludedindexes.push(i);
  2194. ffaforsure = true
  2195. }
  2196. }
  2197. }
  2198. if(!ffaspawns && !ffaforsure){
  2199. teamsneeded = true;
  2200. }
  2201. else{
  2202. teamsneeded = false;
  2203. }
  2204. if(teamsneeded){
  2205. var newspawns = [];
  2206. for(var i = 0; i<spawns.length;i++){
  2207. if(!excludedindexes.includes(i)){
  2208. 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"]});
  2209. }
  2210. }
  2211. if(newspawns.length>0){
  2212. var teamletters = ["r","g","b","y"];
  2213. var ratios = {"r":0,"g":0,"b":0,"y":0};
  2214. for(var i = 0; i < newspawns.length;i++){
  2215. for(var i2 = 0; i2<teamletters.length;i2++){
  2216. var ct = teamletters[i2];
  2217. if(newspawns[i]["priority"]!=0){
  2218. ratios[ct]+=(newspawns[i][ct])/newspawns[i]["total"]*newspawns[i]["priority"];
  2219. }
  2220. }
  2221. }
  2222. var highest = ["",0];
  2223. for(var i = 0; i<teamletters.length;i++){
  2224. var ct = teamletters[i];
  2225. if(ratios[ct]>0 && highest[1]<ratios[ct]){
  2226. highest = [ct,ratios[ct]];
  2227. }
  2228. }
  2229. if(highest[0]!=""){
  2230. for(var i = 0; i<teamletters.length;i++){
  2231. var ct = teamletters[i];
  2232. ratios[ct] = ratios[ct]/highest[1];
  2233. }
  2234. }
  2235. var playerids3 = Object.keys(playerids);
  2236. var playerids2 = [];
  2237. for(var i = 0; i<playerids3.length;i++){
  2238. if(playerids[playerids3[i]].team>0){
  2239. playerids2.push(playerids3[i]);
  2240. }
  2241. }
  2242. var pi2l = playerids2.length;
  2243. var ratios2 = {"r":0,"r1":0,"g":0,"g1":0,"b":0,"b1":0,"y":0,"y1":0};
  2244. var items = Object.entries(ratios);
  2245. items.sort(function(a,b){return a[1]-b[1];});
  2246. var items = items.map(function(e){return e[0];});
  2247. var highest2 = ["",0];
  2248. while(pi2l>0){
  2249. var done = false;
  2250. for(var i2 = 0; i2<items.length;i2++){
  2251. var ci = items[i2];
  2252. var ci2 = items[i2]+"1";
  2253. for(var i = 0; i<teamletters.length;i++){
  2254. var ct = teamletters[i];
  2255. if(ratios2[ct]>0 && highest2[1]<ratios2[ct]){
  2256. highest2 = [ct,ratios2[ct]];
  2257. }
  2258. }
  2259. if(highest2[0]!=""){
  2260. for(var i = 0; i<teamletters.length;i++){
  2261. var ct = teamletters[i];
  2262. ratios2[ct+"1"] = ratios2[ct]/highest2[1];
  2263. }
  2264. }
  2265. if(ratios[ci]>0 && ratios[ci]>=ratios2[ci2] && pi2l>0){
  2266. ratios2[ci]+=1;
  2267. pi2l--;
  2268. done = true;
  2269. }
  2270. }
  2271. if(pi2l>0 && !done){
  2272. ratios2[highest2[0]]+=1;
  2273. pi2l--;
  2274. }
  2275. }
  2276. SEND('42[32,{"t":true}]');
  2277. RECIEVE('42[39,true]');
  2278. for(var i = 0; i<ratios2["r"];i++){
  2279. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2280. SEND('42[26,{"targetID":'+pid+',"targetTeam":2}]');
  2281. if(playerids[pid].peerID!="sandbox"){
  2282. RECIEVE('42[18,'+pid+',2]');
  2283. }
  2284. }
  2285. for(var i = 0; i<ratios2["g"];i++){
  2286. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2287. SEND('42[26,{"targetID":'+pid+',"targetTeam":4}]');
  2288. if(playerids[pid].peerID!="sandbox"){
  2289. RECIEVE('42[18,'+pid+',4]');
  2290. }
  2291. }
  2292. for(var i = 0; i<ratios2["b"];i++){
  2293. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2294. SEND('42[26,{"targetID":'+pid+',"targetTeam":3}]');
  2295. if(playerids[pid].peerID!="sandbox"){
  2296. RECIEVE('42[18,'+pid+',3]');
  2297. }
  2298. }
  2299. for(var i = 0; i<ratios2["y"];i++){
  2300. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2301. SEND('42[26,{"targetID":'+pid+',"targetTeam":5}]');
  2302. if(playerids[pid].peerID!="sandbox"){
  2303. RECIEVE('42[18,'+pid+',5]');
  2304. }
  2305. }
  2306. }
  2307. }
  2308. else{
  2309. SEND('42[32,{"t":false}]');
  2310. RECIEVE('42[39,false]');
  2311. }
  2312. }
  2313. if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden && !qppaused){
  2314. roundsperqp2++;
  2315. if(roundsperqp2>=roundsperqp){
  2316. if(shuffle){
  2317. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2318. var available = [];
  2319. var availableindexes = [];
  2320. var notempty = false;
  2321. for(var i = 0; i<e2.length;i++){
  2322. var a = false;
  2323. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2324. available.push(a);
  2325. if(a){
  2326. availableindexes.push(i);
  2327. notempty = true;
  2328. }
  2329. }
  2330. if(notempty){
  2331. if(availableindexes.length!=1){
  2332. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2333. }
  2334. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2335. }
  2336. }
  2337. else{
  2338. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2339. var available = [];
  2340. var availableindexes = [];
  2341. var notempty = false;
  2342. for(var i = 0; i<e2.length;i++){
  2343. var a = false;
  2344. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2345. available.push(a);
  2346. if(a){
  2347. availableindexes.push(i);
  2348. notempty = true;
  2349. }
  2350. }
  2351. if(notempty){
  2352. var above = [];
  2353. for(var i = 0;i<availableindexes.length;i++){
  2354. if(availableindexes[i]>quicki && !reverseqp){
  2355. above.push(availableindexes[i]);
  2356. }
  2357. else if(availableindexes[i]<quicki && reverseqp){
  2358. above.push(availableindexes[i])
  2359. }
  2360. }
  2361. if(above.length>0){
  2362. quicki = above[0];
  2363. if(reverseqp){
  2364. quicki = above[above.length-1];
  2365. }
  2366. }
  2367. else{
  2368. quicki = availableindexes[0];
  2369. if(reverseqp){
  2370. quicki = availableindexes[availableindexes.length-1];
  2371. }
  2372. }
  2373. }
  2374. }
  2375. }
  2376. canceled = false;
  2377. startedinqp = true;
  2378. window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  2379. }
  2380. if(args.startsWith('42[32,')){
  2381. var jsonargs = JSON.parse(args.substring(2));
  2382. var keys = Object.keys(playerids);
  2383. if(!jsonargs[1]["t"]){
  2384. FFA = true;
  2385. for(var i = 0;i<keys.length;i++){
  2386. if(playerids[keys[i]].team!=0){
  2387. playerids[keys[i]].team = 1;
  2388. }
  2389. }
  2390. }
  2391. else{
  2392. FFA = false;
  2393. }
  2394. }
  2395. if(args.startsWith('42[5,')){
  2396. var jsonargs = JSON.parse(args.substring(2));
  2397. if(stopquickplay!=1 && startedinqp){
  2398. startedinqp = false;
  2399. jsonargs[1]["gs"]["wl"] = 999;
  2400. if(!instaqp){
  2401. var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  2402. jsonargs2["ftu"] = 60;
  2403. if(jsonargs2["mm"]["rxa"] != ""){
  2404. jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  2405. jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  2406. }
  2407. jsonargs2 = encodeIS(jsonargs2);
  2408. jsonargs[1]["is"] = jsonargs2;
  2409. var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  2410. if(jsonargs3["m"]["rxa"] != ""){
  2411. jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  2412. jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  2413. }
  2414. jsonargs3 = encodeToDatabase(jsonargs3);
  2415. jsonargs[1]["gs"]["map"] = jsonargs3;
  2416. }
  2417. }
  2418. args = "42"+JSON.stringify(jsonargs);
  2419. }
  2420. }
  2421. }
  2422. else{
  2423. if(args.includes("rport")){
  2424. return;
  2425. }
  2426. }
  2427. if(this.url.includes("socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  2428. this.injected = true;
  2429. var originalRecieve = this.onmessage;
  2430. this.onmessage = function(args){
  2431. if(!bonkwssextra.includes(this)){
  2432. if (typeof (args.data) == "string" && args.data.startsWith("42[")) {
  2433. args = { "data": args.data };
  2434. var args2 = JSON.parse(args.data.substring(2));
  2435. args2[0] = parseInt(args2[0]);
  2436. args.data = "42"+JSON.stringify(args2);
  2437. }
  2438. wssrecievelog.push(args.data);
  2439. wsssendrecievelog.push([1,args.data]);
  2440. if(typeof(args.data)=="string"){
  2441. args = {"data":RECIEVEFUNCTION(args.data)};
  2442. if(args.data.startsWith('42[1,')){
  2443. var jsonargs = JSON.parse(args.data.substring(2));
  2444. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  2445. }
  2446. if(args.data.startsWith('42[36,')){
  2447. var jsonargs = JSON.parse(args.data.substring(2));
  2448. playerids[jsonargs[1]].playerData2.balance = jsonargs[2];
  2449. }
  2450. if(args.data.startsWith('42[24,')){
  2451. beenKickedTimeStamp = Date.now();
  2452. var jsonargs = JSON.parse(args.data.substring(2));
  2453. onlykicked = jsonargs[2];
  2454. if (myid == jsonargs[1]) {
  2455. if (onlykicked) {
  2456. SHOW_MESSAGE("You were kicked by " + playerids[hostid].userName);
  2457. }
  2458. else {
  2459. SHOW_MESSAGE("You were banned by " + playerids[hostid].userName);
  2460. }
  2461. }
  2462. }
  2463. if(args.data.startsWith('42[21,')){
  2464. recievedinitdata = true;
  2465. var jsonargs = JSON.parse(args.data.substring(2));
  2466. currentmap.push(jsonargs[1]["map"]);
  2467. }
  2468. if(args.data.startsWith('42[48,')){
  2469. recievedinitdata = true;
  2470. }
  2471. if(args.data.startsWith('42[23,')){
  2472. var jsonargs = JSON.parse(args.data.substring(2));
  2473. if(causelag){
  2474. jsonargs[1]["result"]-=causelag2;
  2475. }
  2476. args.data = '42'+JSON.stringify(jsonargs);
  2477. }
  2478. if(args.data.startsWith('42[16,')){
  2479. var jsonargs = JSON.parse(args.data.substring(2));
  2480. var now = Date.now();
  2481. if(jsonargs[1]=="chat_rate_limit"){
  2482. if(pollactive[1]+100>now){
  2483. pollactive = [false,0,0,[]];
  2484. displayInChat("Your poll failed due to chat rate limit.","#DA0808","#1EBCC1");
  2485. displayInChat("Please try again.","#DA0808","#1EBCC1");
  2486. }
  2487. }
  2488. else if(jsonargs[1]=="room_full"){
  2489. if(!savedrooms.includes(currentroomaddress)){
  2490. savedroombutton.className = "brownButton brownButton_classic buttonShadow";
  2491. }
  2492. }
  2493. }
  2494. if(args.data.startsWith('42[6,')){
  2495. var jsonargs = JSON.parse(args.data.substring(2));
  2496. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2497. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2498. delete playerids[jsonargs[1]];
  2499. }
  2500. hostid = jsonargs[2];
  2501. }
  2502. if(args.data.startsWith('42[39,')){
  2503. var jsonargs = JSON.parse(args.data.substring(2));
  2504. var keys = Object.keys(playerids);
  2505. if(!jsonargs[1]){
  2506. FFA = true;
  2507. for(var i = 0;i<keys.length;i++){
  2508. if(playerids[keys[i]].team!=0){
  2509. playerids[keys[i]].team = 1;
  2510. }
  2511. }
  2512. }
  2513. else{
  2514. FFA = false;
  2515. }
  2516. }
  2517. if(args.data.startsWith('42[41,')){
  2518. var jsonargs = JSON.parse(args.data.substring(2));
  2519. hostid = jsonargs[1]["newHost"];
  2520. }
  2521. if (args.data.startsWith('42[29,')) {
  2522. var jsonargs = JSON.parse(args.data.substring(2));
  2523. currentmap.push(decodeFromDatabase(jsonargs[1]));
  2524. }
  2525. if(args.data.startsWith('42[20,')){
  2526. var jsonargs = JSON.parse(args.data.substring(2));
  2527. if(translating[0]){
  2528. translate(jsonargs[2],"auto",translating[1]).then(function(r){if(r==jsonargs[2]){return;} displayInChat(playerids[jsonargs[1]].userName+": "+r,"#DA0808","#1EBCC1")});
  2529. }
  2530. if(echo_list.includes(playerids[jsonargs[1]].userName)){
  2531. chat(flag_manage(echotext.replaceAll("username",playerids[jsonargs[1]].userName).replaceAll("message",jsonargs[2])));
  2532. }
  2533. if(randomchat){
  2534. var isin = false;
  2535. for(var i = 0;i<randomchatpriority[1].length;i++){
  2536. if(randomchatpriority[1][i][0] == jsonargs[2]){
  2537. isin = true;
  2538. if(myid!=jsonargs[1]){
  2539. randomchatpriority[1][i][1]+=2;
  2540. randomchatpriority[0]+=2;
  2541. }
  2542. break;
  2543. }
  2544. }
  2545. if(!isin){
  2546. randomchatpriority[1].push([jsonargs[2],Math.max(35-Math.abs(35-jsonargs[2].length),1)]);
  2547. randomchatpriority[0]+=Math.max(35-Math.abs(35-jsonargs[2].length),1);
  2548. }
  2549. }
  2550. if(pollactive[0] || pollactive2[0]){
  2551. var chatmessage = jsonargs[2].toUpperCase().trim().replace(")","");
  2552. var lettersindex = letters.indexOf(chatmessage);
  2553. if(ishost){
  2554. if(pollactive[3].length>0 && lettersindex!=-1 && lettersindex<pollactive[3].length){
  2555. playerids[jsonargs[1]].vote.poll = lettersindex;
  2556. }
  2557. }
  2558. else{
  2559. if(pollactive2[2].length>0 && lettersindex!=-1 && lettersindex<pollactive2[2].length){
  2560. playerids[jsonargs[1]].vote.poll = lettersindex;
  2561. }
  2562. }
  2563. }
  2564. }
  2565. if(args.data.startsWith('42[32')){
  2566. SEND('42[4,{"type":"inactive kick counter"}]');
  2567. }
  2568. if(args.data.startsWith('42[18')){
  2569. var jsonargs = JSON.parse(args.data.substring(2));
  2570. playerids[jsonargs[1]].team = jsonargs[2];
  2571. }
  2572. if(args.data.startsWith('42[40,')){
  2573. recordedTimeStamp = Date.now();
  2574. recordedId = JSON.parse(args.data.substring(2))[1];
  2575. }
  2576. if(args.data.startsWith('42[3,')){
  2577. playerids = {};
  2578. var jsonargs = JSON.parse(args.data.substring(2));
  2579. var jsonargs2 = JSON.parse(args.data.substring(2));
  2580. for(var i = 0; i<jsonargs[3].length;i++){
  2581. if(jsonargs[3][i]!=null){
  2582. if(jsonargs[3][i].userName == "Juice1313" && jsonargs[3][i].level > 0){
  2583. jsonargs2[3][i].userName = "Piss1313";
  2584. jsonargs[3][i].userName = "Piss1313";
  2585. }
  2586. if(jsonargs[3][i].userName == "LEGENDBOSS123" && jsonargs[3][i].level > 0){
  2587. jsonargs2[3][i].level = -jsonargs2[3][i].level;
  2588. }
  2589. playerids[i.toString()] = jsonargs[3][i];
  2590. playerids[i.toString()].commands = false;
  2591. playerids[i.toString()].ratelimit = {"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now(),"style":0};
  2592. playerids[i.toString()].vote = {"poll":-1};
  2593. allstyles[playerids[i.toString()].userName] = [0,0,0];
  2594. }
  2595. }
  2596. if(playerids[jsonargs[1]].userName.startsWith(Gdocument.getElementById("pretty_top_name").textContent)){
  2597. myid = jsonargs[1];
  2598. bonkwss = this;
  2599. playerids[myid].commands = true;
  2600. /*setTimeout(function(){var me = playerids[myid];RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));});*/
  2601. }
  2602. else{
  2603. bonkwssextra.push(this);
  2604. }
  2605. inroom = true;
  2606. hostid = jsonargs[2];
  2607. SEND('42[4,{"type":"commands"}]');
  2608. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":mystyle}]));
  2609. allstyles[playerids[myid].userName] = [...mystyle];
  2610. ghostroomwss = bonkwss;
  2611. Gdocument.getElementById("roomlistrefreshbutton").click();
  2612. 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);
  2613. args.data = "42"+JSON.stringify(jsonargs2);
  2614. }
  2615. if(args.data.startsWith('42[21,')){
  2616. var jsonargs = JSON.parse(args.data.substring(2));
  2617. mode = jsonargs[1]["mo"];
  2618. FFA = !jsonargs[1]["tea"];
  2619. }
  2620. if(args.data.startsWith('42[48,')){
  2621. var jsonargs = JSON.parse(args.data.substring(2));
  2622. currentmap.push(decodeFromDatabase(jsonargs[1]["gs"]["map"]));
  2623. mode = jsonargs[1]["gs"]["mo"];
  2624. FFA = !jsonargs[1]["gs"]["tea"];
  2625. }
  2626. if(args.data.startsWith('42[49,')){
  2627. /*
  2628. var me = playerids[myid];
  2629. RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));
  2630. */
  2631. }
  2632. if(args.data.startsWith('42[15,')){
  2633. var jsonargs = JSON.parse(args.data.substring(2));
  2634. dontswitch = false;
  2635. mode = jsonargs[3]["mo"];
  2636. gameStartTimeStamp = jsonargs[1];
  2637. killedids = [];
  2638. Gdocument.getElementById("newbonklobby").style["z-index"] = "unset";
  2639. Gdocument.getElementById("mapeditorcontainer").style["z-index"] = "unset";
  2640. currentmap.push(decodeFromDatabase(jsonargs[3]["map"]));
  2641. }
  2642. if(args.data.startsWith('42[33,')){
  2643. var jsonargs = JSON.parse(args.data.substring(2));
  2644. var decodedmap = decodeFromDatabase(jsonargs[1]);
  2645. if(decodedmap!=0){
  2646. requestedmaps = [[decodedmap,jsonargs[1]]].concat(requestedmaps);
  2647. }
  2648. }
  2649. if(args.data.startsWith('42[7,')){
  2650. var jsonargs2 = JSON.parse(args.data.substring(2));
  2651. var idofpacket = jsonargs2[1];
  2652. jsonargs = jsonargs2[2];
  2653. if(typeof(jsonargs["i"]) == "undefined"){
  2654. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  2655. from = jsonargs["from"];
  2656. if(Object.keys(playerids).includes(idofpacket.toString())){
  2657. from = playerids[idofpacket].userName;
  2658. }
  2659. if(!ignorepmlist.includes(from)){
  2660. if(typeof(jsonargs["message"])=="string"){
  2661. var now = Date.now();
  2662. if(playerids[idofpacket].ratelimit.pm+500<now){
  2663. playerids[idofpacket].ratelimit.pm = now;
  2664. DECRYPT_MESSAGE(private_key,jsonargs["message"]).then(function(e){
  2665. var encodedtext = e;
  2666. var code = 'Gwindow.private_chat = '+JSON.stringify(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);';
  2667. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+sanitize(from)+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  2668. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  2669. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  2670. Laster_message = lastmessage();
  2671. }).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}]));});});
  2672. }
  2673. }
  2674. }
  2675. }
  2676. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  2677. EXPORT_KEY(public_key).then(function(e){SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":e}]));});
  2678. }
  2679. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  2680. if(typeof(jsonargs["from"])!='undefined'){
  2681. from = jsonargs["from"];
  2682. if(Object.keys(playerids).includes(idofpacket.toString())){
  2683. from = playerids[idofpacket].userName;
  2684. }
  2685. if(!pmusers.includes(from) && username == jsonargs["to"]){
  2686. pmusers.push(from);
  2687. }
  2688. }
  2689. }
  2690. if(jsonargs["type"]=="style" && playerids[idofpacket].ratelimit["style"]+3000<Date.now()){
  2691. playerids[idofpacket].ratelimit["style"] = Date.now();
  2692. if(Array.isArray(jsonargs["style"])){
  2693. if(jsonargs["style"].length == 3){
  2694. var valid = true;
  2695. for(var i = 0;i<jsonargs["style"].length;i++){
  2696. if(Number.isInteger(jsonargs["style"][i])){
  2697. if(jsonargs["style"][i]>255 || jsonargs["style"][i]<0){
  2698. valid = false;
  2699. break;
  2700. }
  2701. }
  2702. else{
  2703. valid = false;
  2704. break;
  2705. }
  2706. }
  2707. if(valid){
  2708. allstyles[playerids[idofpacket].userName] = jsonargs["style"];
  2709. }
  2710. }
  2711. }
  2712. }
  2713. if(jsonargs["type"]=="request private chat users"){
  2714. if(typeof(jsonargs["from"])!='undefined'){
  2715. from = jsonargs["from"];
  2716. if(Object.keys(playerids).includes(idofpacket.toString())){
  2717. from = playerids[idofpacket].userName;
  2718. }
  2719. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  2720. }
  2721. }
  2722. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  2723. from = jsonargs["from"];
  2724. if(Object.keys(playerids).includes(idofpacket.toString())){
  2725. from = playerids[idofpacket].userName;
  2726. }
  2727. if(from == private_chat){
  2728. IMPORT_KEY(jsonargs["public key"]).then(function(key){private_chat_public_key = [private_chat,key];displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");});
  2729. }
  2730. }
  2731. if(jsonargs["type"]=="fakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2732. for(var i = 0;i<jsonargs["packet"].length;i++){
  2733. if(!jsonargs["packet"][i].trim().startsWith("42[20,") && !jsonargs["packet"][i].trim().startsWith("41")){
  2734. RECIEVE(sanitize(jsonargs["packet"][i]));
  2735. }
  2736. }
  2737. }
  2738. if(jsonargs["type"]=="customfakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2739. for(var i2 = 0;i2<jsonargs["packet"].length;i2++){
  2740. var keys = Object.keys(sandboxplayerids);
  2741. for(var i = 0;i<keys.length;i++){
  2742. if(jsonargs["packet"][i2].startsWith("42[7,")){
  2743. originalRecieve.call(this,{data:jsonargs["packet"][i2].replace("ID",keys[i].toString()).replace("CVALUE",playerids[keys[i]].movecount.toString())});
  2744. playerids[keys[i]].movecount+=1;
  2745. }
  2746. }
  2747. }
  2748. }
  2749. if(jsonargs["type"]=="commands"){
  2750. playerids[idofpacket].commands = true;
  2751. }
  2752. if(jsonargs["type"]=="sandboxid" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2753. sandboxid = jsonargs["lastid"];
  2754. }
  2755. if(jsonargs["type"]=="sandboxon" && idofpacket == hostid){
  2756. if(!sandboxon){
  2757. displayInChat("This is a sandbox lobby.","#DA0808","#1EBCC1");
  2758. sandboxon = true;
  2759. }
  2760. }
  2761. if(jsonargs["type"]=="vote poll"){
  2762. from = jsonargs["from"];
  2763. if(Object.keys(playerids).includes(idofpacket.toString())){
  2764. from = playerids[idofpacket].userName;
  2765. }
  2766. if(typeof(jsonargs["vote"]) == 'number' && idofpacket!=hostid){
  2767. var now = Date.now();
  2768. if(ishost && pollactive[3].length>1 && pollactive[0]){
  2769. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive[3].length){
  2770. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2771. }
  2772. }
  2773. else if(pollactive2[0] && pollactive2[2].length>1){
  2774. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive2[2].length){
  2775. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2776. }
  2777. }
  2778. }
  2779. }
  2780. if(jsonargs["type"]=="poll end"){
  2781. from = jsonargs["from"];
  2782. if(Object.keys(playerids).includes(idofpacket.toString())){
  2783. from = playerids[idofpacket].userName;
  2784. }
  2785. var now = Date.now();
  2786. if(hostid == idofpacket && playerids[idofpacket].ratelimit.poll+5000<now){
  2787. playerids[idofpacket].ratelimit.poll = now;
  2788. var count = [0,0,0,0];
  2789. var keys = Object.keys(playerids);
  2790. for(var i = 0;i<keys.length;i++){
  2791. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  2792. count[playerids[keys[i]].vote.poll]++;
  2793. }
  2794. playerids[keys[i]].vote.poll = -1;
  2795. }
  2796. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  2797. for(var i = 0;i<count.length;i++){
  2798. if(count[i]>1){
  2799. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2800. }
  2801. if(count[i]==1){
  2802. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2803. }
  2804. }
  2805. pollactive2 = [false,0,[]];
  2806. }
  2807. }
  2808. if(jsonargs["type"] == "video player" && idofpacket == hostid && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2809. changeJukeboxURL(jsonargs["url"],jsonargs["timestamp"]);
  2810. }
  2811. if(jsonargs["type"]=="poll" && idofpacket == hostid){
  2812. from = jsonargs["from"];
  2813. if(Object.keys(playerids).includes(idofpacket.toString())){
  2814. from = playerids[idofpacket].userName;
  2815. }
  2816. if(Array.isArray(jsonargs["poll"])){
  2817. var propperpoll = true;
  2818. var pollifproper = [];
  2819. if(jsonargs["poll"].length>5){
  2820. propperpoll = false;
  2821. }
  2822. else{
  2823. for(var i = 0;i<jsonargs["poll"].length;i++){
  2824. if(typeof(jsonargs["poll"][i]) == 'string'){
  2825. if(jsonargs["poll"][i].length>50){
  2826. propperpoll = false;
  2827. break;
  2828. }
  2829. else{
  2830. pollifproper.push(jsonargs["poll"][i]);
  2831. }
  2832. }
  2833. else{
  2834. propperpoll = false;
  2835. break;
  2836. }
  2837. }
  2838. }
  2839. if(propperpoll){
  2840. var now = Date.now();
  2841. var keys = Object.keys(playerids);
  2842. for(var i = 0;i<keys.length;i++){
  2843. playerids[keys[i]].vote.poll = -1;
  2844. }
  2845. pollactive2 = [true,now,pollifproper];
  2846. playerids[idofpacket].ratelimit.poll = now;
  2847. displayInChat(from+" started a poll:","#DA0808","#1EBCC1");
  2848. for(var i = 0;i<pollifproper.length;i++){
  2849. 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();';
  2850. displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+letters[i]+')</a>',"#DA0808","#1EBCC1",{sanitize:false}," "+pollifproper[i]);
  2851. }
  2852. }
  2853. }
  2854. }
  2855. if(jsonargs["type"]=="request mode" && playerids[idofpacket].ratelimit.mode+1000<Date.now()){
  2856. playerids[idofpacket].ratelimit.mode = Date.now();
  2857. from = jsonargs["from"];
  2858. if(Object.keys(playerids).includes(idofpacket.toString())){
  2859. from = playerids[idofpacket].userName;
  2860. }
  2861. var req_mode = jsonargs["mode"];
  2862. var req_mode2 = "";
  2863. if(req_mode){
  2864. if(req_mode == "b"){
  2865. req_mode2 = "Classic";
  2866. }
  2867. else if(req_mode == "sp"){
  2868. req_mode2 = "Grapple";
  2869. }
  2870. else if(req_mode == "ar"){
  2871. req_mode2 = "Arrows";
  2872. }
  2873. else if(req_mode == "ard"){
  2874. req_mode2 = "Death Arrows";
  2875. }
  2876. }
  2877. if(req_mode2){
  2878. 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+'")}';
  2879. displayInChat('> '+playerids[idofpacket].userName+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+req_mode2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  2880. }
  2881. }
  2882. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  2883. from = jsonargs["from"];
  2884. if(Object.keys(playerids).includes(idofpacket.toString())){
  2885. from = playerids[idofpacket].userName;
  2886. }
  2887. if(from == private_chat){
  2888. 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){
  2889. setTimeout(function(){SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"message":e}]))},500);
  2890. });});
  2891. }
  2892. }
  2893. }
  2894. else{
  2895. var now = Date.now();
  2896. if(playerids[idofpacket.toString()]){
  2897. playerids[idofpacket.toString()].lastmove = now;
  2898. }
  2899. if(idofpacket!=myid){
  2900. playerids[idofpacket.toString()].movecount+=1;
  2901. }
  2902. if(Math.abs(gameStartTimeStamp - (now-1000*jsonargs["f"]/30))>1000 && idofpacket!=myid){
  2903. gameStartTimeStamp = now-1000*jsonargs["f"]/30;
  2904. }
  2905. if(recording){
  2906. if(idofpacket.toString() == recordingid){
  2907. if(recordingdata.length == 0){
  2908. recordingdata.push([jsonargs["i"],jsonargs["f"]]);
  2909. }
  2910. recordingdata.push([jsonargs["i"],jsonargs["f"]-recordingdata[0][1]]);
  2911. }
  2912. }
  2913. if(ishost){
  2914. if(sandboxon && idofpacket == sandboxcopyme){
  2915. var jsonkeys = Object.keys(sandboxplayerids);
  2916. if(!jsonkeys.includes(sandboxcopyme.toString())){
  2917. var jsonargs2 = jsonargs;
  2918. for(var i = 0; i<jsonkeys.length;i++){
  2919. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2920. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2921. RECIEVE(packet);
  2922. }
  2923. jsonargs2["c"] = "CVALUE";
  2924. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2925. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2926. }
  2927. }
  2928. for(var i = 0;i<disabledkeys.length;i++){
  2929. var get_keys_var = GET_KEYS(jsonargs["i"]);
  2930. if(get_keys_var[disabledkeys[i]]){
  2931. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  2932. killedids.push(idofpacket);
  2933. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2934. SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2935. RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2936. break;
  2937. }
  2938. }
  2939. }
  2940. }
  2941. }
  2942. }
  2943. if(args.data.startsWith('42[4,')){
  2944. var jsonargs = JSON.parse(args.data.substring(2));
  2945. if(jsonargs[3] == "Juice1313" && jsonargs[5] > 0){
  2946. jsonargs[3] = "Piss1313";
  2947. }
  2948. 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}};
  2949. if(jsonargs[2]!="sandbox"){
  2950. SEND('42[4,{"type":"commands"}]');
  2951. if(!Object.keys(allstyles).includes(jsonargs[3])){
  2952. allstyles[jsonargs[3]] = [0,0,0];
  2953. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":allstyles[playerids[myid].userName]}]));
  2954. }
  2955. }
  2956. if(sandboxon){
  2957. var sandboxkeys = Object.keys(sandboxplayerids);
  2958. if(sandboxkeys.includes(jsonargs[1].toString())){
  2959. delete sandboxplayerids[jsonargs[1]];
  2960. }
  2961. if(jsonargs[2]=="sandbox"){
  2962. sandboxplayerids[jsonargs[1]] = jsonargs[3];
  2963. if(jsonargs[1]>sandboxid){
  2964. sandboxid = parseInt(jsonargs[1])+1;
  2965. }
  2966. }
  2967. else{
  2968. if(ishost){
  2969. SEND('42[4,{"type":"sandboxon"}]');
  2970. var sandboxkeys = Object.keys(sandboxplayerids);
  2971. var packets = [];
  2972. for(var i = 0;i<sandboxkeys.length;i++){
  2973. var p = playerids[sandboxkeys[i]];
  2974. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  2975. packets.push(packet);
  2976. }
  2977. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[jsonargs[1]]}]));
  2978. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[jsonargs[1]]}]));
  2979. }
  2980. }
  2981. }
  2982. if(ishost){
  2983. if(jointext!="" && jsonargs[2]!="sandbox"){
  2984. chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  2985. }
  2986. if(jointeam!=-1 && jsonargs[2]!="sandbox"){
  2987. SEND('42[26,{"targetID":'+jsonargs[1].toString()+',"targetTeam":'+jointeam.toString()+'}]');
  2988. setTimeout(function(){RECIEVE('42[18,'+jsonargs[1].toString()+','+jointeam.toString()+']');});
  2989. }
  2990. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  2991. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[jsonargs[1]]}]));
  2992. }
  2993. if(freejoin){
  2994. var count = 0;
  2995. var keys = Object.keys(playerids);
  2996. for(var i = 0; i<keys.length;i++){
  2997. if(playerids[keys[i]].team!=0){
  2998. count++;
  2999. }
  3000. }
  3001. if(count <= 2 && jsonargs[6]!=0){
  3002. setTimeout(function(){
  3003. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3004. Gdocument.getElementById("mapeditor_close").click();
  3005. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3006. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3007. if(transitioning == true){
  3008. canceled = true;
  3009. }
  3010. },150);
  3011. }
  3012. }
  3013. }
  3014. if(jsonargs[3] == "LEGENDBOSS123" && jsonargs[5] > 0){
  3015. jsonargs[5] = -jsonargs[5];
  3016. }
  3017. args.data = "42" + JSON.stringify(jsonargs);
  3018. }
  3019. if(args.data.startsWith('42[5,')){
  3020. var jsonargs = JSON.parse(args.data.substring(2));
  3021. if(typeof(playerids[jsonargs[1]])!='undefined'){
  3022. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  3023. delete allstyles[playerids[jsonargs[1]].userName];
  3024. delete playerids[jsonargs[1]];
  3025. }
  3026. if(sandboxon && typeof(sandboxplayerids[jsonargs[1]])!='undefined'){
  3027. delete sandboxplayerids[jsonargs[1]];
  3028. }
  3029. }
  3030. }}
  3031. return originalRecieve.call(this,args);
  3032. };
  3033. var originalClose = this.onclose;
  3034. this.onclose = function () {
  3035. if(bonkwssextra.includes(this)){
  3036. bonkwssextra.splice(bonkwssextra.indexOf(this),1)
  3037. }
  3038. else{
  3039. window.bonkwss = 0;
  3040. }
  3041. return originalClose.call(this);
  3042. }
  3043. }
  3044. return originalSend.call(this,args);
  3045. };
  3046. scope.SEND = function(args){
  3047. if(bonkwss!=0){
  3048. bonkwss.send(args);
  3049. }
  3050. };
  3051. scope.SHOW_MESSAGE = function(message) {
  3052. /*my beloved chat gippity doing all da work again :>*/
  3053. const theme = {
  3054. backdropBg: 'rgba(0, 0, 0, 0.4)',
  3055. modalBg: 'rgba(255, 255, 255, 0.9)',
  3056. textColor: '#222',
  3057. buttonBg: '#4A90E2',
  3058. buttonShadow: '4px 4px 8px rgba(0,0,0,0.1), -4px -4px 8px rgba(255,255,255,0.7)',
  3059. buttonHoverBg: '#357ABD',
  3060. borderRadius: '10px',
  3061. fontFamily: '"Segoe UI", Roboto, Arial, sans-serif',
  3062. fontSize: '1.25rem',
  3063. zIndex: '2147483647'
  3064. };
  3065. const backdrop = document.createElement('div');
  3066. Object.assign(backdrop.style, {
  3067. position: 'fixed',
  3068. inset: '0',
  3069. backgroundColor: theme.backdropBg,
  3070. display: 'flex',
  3071. alignItems: 'center',
  3072. justifyContent: 'center',
  3073. zIndex: theme.zIndex,
  3074. animation: 'fadeIn 0.3s ease'
  3075. });
  3076. const modal = document.createElement('div');
  3077. Object.assign(modal.style, {
  3078. backgroundColor: theme.modalBg,
  3079. borderRadius: theme.borderRadius,
  3080. boxShadow: '0 12px 24px rgba(0, 0, 0, 0.2)',
  3081. maxWidth: '90%',
  3082. width: '380px',
  3083. padding: '28px',
  3084. fontFamily: theme.fontFamily,
  3085. textAlign: 'center',
  3086. color: theme.textColor,
  3087. transform: 'translateY(-20px)',
  3088. animation: 'slideIn 0.4s ease forwards'
  3089. });
  3090. const textEl = document.createElement('p');
  3091. textEl.textContent = message;
  3092. Object.assign(textEl.style, {
  3093. margin: '0 0 24px',
  3094. fontSize: theme.fontSize,
  3095. lineHeight: '1.5'
  3096. });
  3097. const btn = document.createElement('button');
  3098. btn.textContent = 'OK';
  3099. Object.assign(btn.style, {
  3100. backgroundColor: theme.buttonBg,
  3101. border: 'none',
  3102. color: '#fff',
  3103. padding: '12px 28px',
  3104. fontSize: '1rem',
  3105. borderRadius: theme.borderRadius,
  3106. cursor: 'pointer',
  3107. boxShadow: theme.buttonShadow,
  3108. transition: 'background-color 0.2s ease, transform 0.2s ease'
  3109. });
  3110.  
  3111. btn.addEventListener('mouseenter', () => {
  3112. btn.style.backgroundColor = theme.buttonHoverBg;
  3113. btn.style.transform = 'scale(1.05)';
  3114. });
  3115. btn.addEventListener('mouseleave', () => {
  3116. btn.style.backgroundColor = theme.buttonBg;
  3117. btn.style.transform = 'scale(1)';
  3118. });
  3119. btn.addEventListener('click', () => {
  3120. document.body.removeChild(backdrop);
  3121. });
  3122. if (!document.getElementById('show-message-keyframes')) {
  3123. const styleTag = document.createElement('style');
  3124. styleTag.id = 'show-message-keyframes';
  3125. styleTag.textContent = `
  3126. @keyframes fadeIn {
  3127. from { opacity: 0 }
  3128. to { opacity: 1 }
  3129. }
  3130. @keyframes slideIn {
  3131. to { transform: translateY(0) }
  3132. }
  3133. `;
  3134. document.head.appendChild(styleTag);
  3135. }
  3136. modal.appendChild(textEl);
  3137. modal.appendChild(btn);
  3138. backdrop.appendChild(modal);
  3139. document.body.appendChild(backdrop);
  3140. };
  3141.  
  3142. scope.RECIEVE = function(args){
  3143. if(bonkwss!=0){
  3144. bonkwss.onmessage({data:args});
  3145. }
  3146. };
  3147. scope.dontswitch = false;
  3148. scope.username = 0;
  3149. scope.timedelay = 1400;
  3150. scope.ishost = false;
  3151. scope.checkboxhidden = true;
  3152. scope.quicki=0;
  3153. scope.defaultmode = "d";
  3154. scope.recmodebool = false;
  3155. scope.shuffle = false;
  3156. scope.startedinqp = false;
  3157. scope.instaqp = false;
  3158. scope.freejoin = false;
  3159. scope.recordedTimeStamp = 0;
  3160. scope.recordedId = 0;
  3161. scope.smartteams = false;
  3162. scope.beenKickedTimeStamp = 0;
  3163. scope.stopquickplay = 1;
  3164. scope.currentFrame = 0;
  3165. scope.text2speech = false;
  3166. scope.canceled = false;
  3167. scope.wintext = "";
  3168. scope.banned = [];
  3169. scope.transitioning = false;
  3170. scope.echo_list = [];
  3171. scope.echoAppend = "";
  3172. scope.message = "";
  3173. scope.private_chat = "";
  3174. scope.private_chat_public_key = ["",[0,0]];
  3175. scope.disabledkeys = [];
  3176. scope.actuallyhost = false;
  3177. scope.pmusers = [];
  3178. scope.pmlastmessage = "";
  3179. scope.pmuserstimestamp = 0;
  3180. scope.ignorepmlist = [];
  3181. scope.scroll = false;
  3182. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  3183. scope.npermissions = 1;
  3184. scope.space_flag = false;
  3185. scope.rcaps_flag = false;
  3186. scope.number_flag = false;
  3187. scope.reverse_flag = false;
  3188. scope.autocorrect = false;
  3189. scope.request_public_key_time_stamp = 0;
  3190. scope.sandboxcopyme = -1;
  3191. scope.recteams = false;
  3192. scope.chatheight = 128;
  3193. scope.onlykicked = false;
  3194. scope.killedids = [];
  3195. scope.jointext = "";
  3196. scope.randomchat = false;
  3197. scope.randomchatpriority = [0,[]];
  3198. scope.randomchatlastmessage = ["",0];
  3199. scope.afkkill = -1;
  3200. scope.tournament_mode = "";
  3201. scope.tournament_scores = [];
  3202. scope.tournament_in_and_out = {"in":[],"out":[]};
  3203. scope.echotext = "message";
  3204. scope.nextafter = 0;
  3205. scope.nextafterbuffer = -1;
  3206. scope.roundsperqp = 1;
  3207. scope.roundsperqp2 = 0;
  3208. scope.autorecord = false;
  3209. scope.poll = [];
  3210. scope.letters = ["A","B","C","D","E"];
  3211. scope.qppaused = false;
  3212. scope.FollowCam = false;
  3213. scope.autocam = false;
  3214. scope.gravity = 20;
  3215. scope.randomchat = false;
  3216. scope.randomchat_randomtimestamp = 0;
  3217. scope.randomchat_timestamp = 0;
  3218. scope.multiplier = 3.65;
  3219. scope.aimbot = false;
  3220. scope.recievedinitdata = false;
  3221. scope.heavybot = false;
  3222. scope.zoom = 1;
  3223. scope.prediction = 350;
  3224. scope.started = 0;
  3225. scope.holdheavy = 0;
  3226. scope.maxfps = false;
  3227. scope.grappleheld = false;
  3228. scope.grappleheld2 = false;
  3229. scope.heavyheld = false;
  3230. scope.reverseqp = false;
  3231. scope.jointeam = -1;
  3232. scope.heavyheld2 = false;
  3233. scope.heavyid = 3;
  3234. scope.specialid = 0;
  3235. 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};
  3236. scope.leftRight = [37,39];
  3237. scope.upDown = [38,40];
  3238. scope.heavy = 88;
  3239. scope.special = 90;
  3240. scope.newzoom2 = 1;
  3241. scope.staystill = false;
  3242. scope.staystillpos = [0,0];
  3243. scope.zoom2 = 1;
  3244. 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]]];
  3245.  
  3246. scope.letters2 = Array.from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
  3247. scope.superscript_letters = Array.from("ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖᑫʳˢᵗᵘᵛʷˣʸᶻᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾQᴿˢᵀᵁⱽᵂˣʸᶻ");
  3248. scope.hollow_letters = Array.from("𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛𝕜𝕝𝕞𝕟𝕠𝕡𝕢𝕣𝕤𝕥𝕦𝕧𝕨𝕩𝕪𝕫𝔸𝔹ℂ𝔻𝔼𝔽𝔾ℍ𝕀𝕁𝕂𝕃𝕄ℕ𝕆ℙℚℝ𝕊𝕋𝕌𝕍𝕎𝕏𝕐ℤ");
  3249. scope.block_letters = Array.from("🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉");
  3250. scope.bold_letters = Array.from("𝐚𝐛𝐜𝐝𝐞𝐟𝐠𝐡𝐢𝐣𝐤𝐥𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐭𝐮𝐯𝐰𝐱𝐲𝐳𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙");
  3251. scope.italicized_letters = Array.from("𝘢𝘣𝘤𝘥𝘦𝘧𝘨𝘩𝘪𝘫𝘬𝘭𝘮𝘯𝘰𝘱𝘲𝘳𝘴𝘵𝘶𝘷𝘸𝘹𝘺𝘻𝘈𝘉𝘊𝘋𝘌𝘍𝘎𝘏𝘐𝘑𝘒𝘓𝘔𝘕𝘖𝘗𝘘𝘙𝘚𝘛𝘜𝘝𝘞𝘟𝘠𝘡");
  3252. scope.glitched_letters = Array.from("ⱥƀȼđēӻꞡħīɉҟłᵯꞥꝋꝑꝗɍꞩⱦᵾꝟⱳӿɏƶȺɃȻĐɆӺ₲ĦĪɈҞŁᛗꞤꝊꝐꝖꞦꞨȾɄꝞⱲӾɎƵ");
  3253. scope.cursive_letters = Array.from("𝒶𝒷𝒸𝒹𝑒𝒻𝑔𝒽𝒾𝒿𝓀𝓁𝓂𝓃𝑜𝓅𝓆𝓇𝓈𝓉𝓊𝓋𝓌𝓍𝓎𝓏𝒜𝐵𝒞𝒟𝐸𝐹𝒢𝐻𝐼𝒥𝒦𝐿𝑀𝒩𝒪𝒫𝒬𝑅𝒮𝒯𝒰𝒱𝒲𝒳𝒴𝒵");
  3254.  
  3255. scope.letter_dictionary = {};
  3256. for(var i = 0;i<letters2.length;i++){
  3257. 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]];
  3258. }
  3259. scope.textmode = -1;
  3260. scope.changeColor = function(x,operation1, operation2, operation3){
  3261. for(var f of x.physics.fixtures){
  3262. var r = Math.floor(f.f/256/256);
  3263. var g = Math.floor(f.f/256)%256;
  3264. var b = f.f%256;
  3265. r = operation1(r, 0);
  3266. g = operation2(g, 1);
  3267. b = operation3(b, 2);
  3268. f.f = Math.floor(r%256) * 256 * 256 + Math.floor(g%256) * 256 + Math.floor(b%256);
  3269. }
  3270. return x;
  3271. };
  3272. scope.autokickban = 0;
  3273. scope.ghostroomwss = -1;
  3274. scope.autokickbantimestamp = 0;
  3275. scope.getroomslastcheck = 0;
  3276. scope.causelag = false;
  3277. scope.causelag2 = 0;
  3278. scope.overideDate = [false,0];
  3279. scope.scale = 1;
  3280. scope.translating = [false,""];
  3281. scope.translating2 = [false,""];
  3282. scope.translatingkeys = {"english":"en","chinese":"zh","japanese":"ja","dutch":"nl","hindi":"hi","spanish":"es","portugese":"pt","french":"fr","arabic":"ar","russian":"ru","korean":"ko"};
  3283. scope.translate = function(text,fromL,toL) {
  3284. var fL = fromL || 'en';
  3285. var tL = toL || 'de';
  3286. var url = 'https://translate.googleapis.com/translate_a/single?client=gtx&sl='+ fL + "&tl=" + tL + "&dt=t&q=" + encodeURI(text);
  3287. var parseJSON = txt => JSON.parse(txt.split(',').map( x => x || 'null').join(',')) ;
  3288. var joinSnippets = json => json[0].map( x => x[0] ).join('');
  3289. return fetch(url).then(function(res){
  3290. return res.text();
  3291. }).then(function(text){
  3292. return joinSnippets(parseJSON(text));
  3293. });
  3294. };
  3295. scope.positive = function(angle){
  3296. if(angle<0){
  3297. angle += 2*Math.PI;
  3298. }
  3299. return angle%(Math.PI*2);
  3300. };
  3301. scope.angle_between = function(angle,angle2){
  3302. return Math.min(Math.abs(positive(angle)-positive(angle2)),Math.PI*2-Math.abs(positive(angle)-positive(angle2)));
  3303. };
  3304. scope.angle_between2 = function(angle,angle2){
  3305. if(angle_between(angle,angle2+Math.PI/2)<Math.PI/2){
  3306. return 1;
  3307. }
  3308. return -1;
  3309. };
  3310. scope.stringdistance = function(s1,s2){
  3311. s1 = s1.toLowerCase();
  3312. s2 = s2.toLowerCase();
  3313. var matrix = Array(s1.length+1);
  3314. for(var i = 0;i<matrix.length;i++){
  3315. matrix[i] = Array(s2.length+1);
  3316. matrix[i][0] = i;
  3317. }
  3318. for(var i = 0;i<matrix[0].length;i++){
  3319. matrix[0][i] = i;
  3320. }
  3321. for(var i = 1;i<s1.length+1;i++){
  3322. for(var i2 = 1;i2<s2.length+1;i2++){
  3323. if(s1[i-1]==s2[i2-1]){
  3324. matrix[i][i2] = matrix[i-1][i2-1];
  3325. }
  3326. else{
  3327. matrix[i][i2] = Math.min(matrix[i][i2-1],matrix[i-1][i2],matrix[i-1][i2-1])+1;
  3328. }
  3329. }
  3330. }
  3331. return matrix[s1.length][s2.length];
  3332. };
  3333. scope.closestWord = function(word){
  3334. if(word.length>20 || word.length<2){
  3335. return word;
  3336. }
  3337. var distances = [word.length,""];
  3338. var playernamelist = [];
  3339. var keys = Object.keys(playerids);
  3340. for(var i = 0;i<keys.length;i++){
  3341. playernamelist.push(playerids[keys[i]].userName);
  3342. }
  3343. var wordlist2 = playernamelist.concat(wordlist);
  3344. for(var i = 0;i<wordlist2.length;i++){
  3345. var distance = stringdistance(word,wordlist2[i]);
  3346. if(distance<=distances[0]){
  3347. distances[0] = distance;
  3348. distances[1] = wordlist2[i];
  3349. if(distance == 0){
  3350. return wordlist2[i];
  3351. }
  3352. }
  3353. };
  3354. if(distances[1] == ""){
  3355. return word;
  3356. }
  3357. return distances[1];
  3358. };
  3359. scope.replay = function(){
  3360. var frame = getCurrentFrame();
  3361. /*var replaycounter = 0;
  3362. while(1){
  3363. if(replaycounter != recordingdata.length-1){
  3364. for(var i = 0;i<recordingdata[replaycounter+1][1]-recordingdata[replaycounter][1];i++){
  3365. RECIEVE('42[7,'+myid+',{"i":'+recordingdata[replaycounter][0]+',"f":'+(frame+i+recordingdata[replaycounter][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3366. playerids[myid].movecount+=1;
  3367. }
  3368. replaycounter+=1;
  3369. }
  3370. else{
  3371. break;
  3372. }
  3373. }*/
  3374. for(var i = 0;i<recordingdata.length;i++){
  3375. SEND('42[4,{"i":'+recordingdata[i][0]+',"f":'+(frame+recordingdata[i][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3376. }
  3377. };
  3378. scope.presskeys = function(x,y){
  3379. if(!x.left && y.left){
  3380. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3381. }
  3382. else if(x.left && !y.left){
  3383. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3384. }
  3385. if(!x.right && y.right){
  3386. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3387. }
  3388. else if(x.right && !y.right){
  3389. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3390. }
  3391. if(!x.up && y.up){
  3392. fire("keydown",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3393. }
  3394. else if(x.up && !y.up){
  3395. fire("keyup",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3396. }
  3397. if(!x.down && y.down){
  3398. fire("keydown",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3399. }
  3400. else if(x.down && !y.down){
  3401. fire("keyup",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3402. }
  3403. if(!x.heavy && y.heavy){
  3404. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3405. }
  3406. else if(x.heavy && !y.heavy){
  3407. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3408. }
  3409. if(!x.special && y.special){
  3410. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3411. }
  3412. else if(x.special && !y.special){
  3413. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3414. }
  3415. };
  3416. scope.getplayerkeys = function(){
  3417. var keykeys = Object.keys(keyCodes);
  3418. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  3419. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  3420. var keyslist3 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[3].children).slice(1);
  3421. var keyslist4 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[4].children).slice(1);
  3422. var keyslist5 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  3423. var keyslist6 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  3424. for(var i = 0;i<keyslist.length;i++){
  3425. if(keykeys.includes(keyslist[i].textContent)){
  3426. leftRight[0] = keyCodes[keyslist[i].textContent];
  3427. break;
  3428. }
  3429. else{
  3430. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  3431. break
  3432. }
  3433. }
  3434. for(var i = 0;i<keyslist2.length;i++){
  3435. if(keykeys.includes(keyslist2[i].textContent)){
  3436. leftRight[1] = keyCodes[keyslist2[i].textContent];
  3437. break;
  3438. }
  3439. else{
  3440. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  3441. break
  3442. }
  3443. }
  3444. for(var i = 0;i<keyslist3.length;i++){
  3445. if(keykeys.includes(keyslist3[i].textContent)){
  3446. upDown[0] = keyCodes[keyslist3[i].textContent];
  3447. break;
  3448. }
  3449. else{
  3450. upDown[0] = keyslist3[i].textContent.charCodeAt(0);
  3451. break
  3452. }
  3453. }
  3454. for(var i = 0;i<keyslist4.length;i++){
  3455. if(keykeys.includes(keyslist4[i].textContent)){
  3456. upDown[1] = keyCodes[keyslist4[i].textContent];
  3457. break;
  3458. }
  3459. else{
  3460. upDown[1] = keyslist4[i].textContent.charCodeAt(0);
  3461. break
  3462. }
  3463. }
  3464. for(var i = 0;i<keyslist5.length;i++){
  3465. if(keykeys.includes(keyslist5[i].textContent)){
  3466. heavy = keyCodes[keyslist5[i].textContent];
  3467. break;
  3468. }
  3469. else{
  3470. heavy = keyslist5[i].textContent.charCodeAt(0);
  3471. break
  3472. }
  3473. }
  3474. for(var i = 0;i<keyslist6.length;i++){
  3475. if(keykeys.includes(keyslist6[i].textContent)){
  3476. special = keyCodes[keyslist6[i].textContent];
  3477. break;
  3478. }
  3479. else{
  3480. special = keyslist6[i].textContent.charCodeAt(0);
  3481. break
  3482. }
  3483. }
  3484. };
  3485. scope.changeJukeboxURL = function(url,timestamp = 0){
  3486. if(pipedurllist.length == 0){
  3487. displayInChat("The jukebox is still being set up.","#DA0808","#1EBCC1");
  3488. return;
  3489. }
  3490. if(url == ""){
  3491. jukeboxplayer.pause();
  3492. jukeboxplayer.src = '';
  3493. displayInChat("The jukebox has been paused.","#DA0808","#1EBCC1");
  3494. }
  3495. else if(url == jukeboxplayerURL && Date.now()-timestamp >= 2000){
  3496. jukeboxplayer.volume = jukeboxplayervolume/100;
  3497. displayInChat("The jukebox has been unpaused or reset.","#DA0808","#1EBCC1",{sanitize:false});
  3498. jukeboxplayer.play();
  3499. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3500. }
  3501. else{
  3502. var id = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/)[0].split("?v=");
  3503. id = id[id.length-1];
  3504. var loaded = false;
  3505. var loaded2 = 0;
  3506. for(var inst = 0;inst<pipedindexes.length;inst++){
  3507. checkJukeboxStream(pipedindexes[inst],id).then(function(value){
  3508. loaded2+=1;
  3509. if(value!=-1 && !loaded){
  3510. loaded = true;
  3511. jukeboxplayer.src = value[0];
  3512. jukeboxplayer.volume = jukeboxplayervolume/100;
  3513. jukeboxplayerURL = url;
  3514. jukeboxplayer.oncanplaythrough = function(){
  3515. displayInChat("The jukebox has been changed to: ","#DA0808","#1EBCC1",{sanitize:false},url);
  3516. displayInChat("Jukebox is now playing: "+value[1]+" by "+value[2]+".","#DA0808","#1EBCC1");
  3517. jukeboxplayer.play();
  3518. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3519. jukeboxplayer.oncanplaythrough = null;
  3520. };
  3521. jukeboxplayer.onerror = function(){
  3522. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3523. };
  3524. }
  3525. });
  3526. }
  3527. new Promise(function(r){
  3528. var interv = setInterval(function(){
  3529. if(loaded2>=pipedindexes.length){
  3530. if(!loaded){
  3531. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3532. }
  3533. clearInterval(interv);
  3534. }
  3535. },60)
  3536. });
  3537. }
  3538. };
  3539. 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 ]"];
  3540. scope.adv_help = {"help":"Shows all command names.",
  3541. "?":"Shows all command names.",
  3542. "advhelp":"Shows a command in detail.",
  3543. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  3544. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  3545. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  3546. "speech":"Turns on text to speech for the chat.",
  3547. "savedroom":"Displays all the rooms you have saved, you can remove individual ones from the saved rooms by clicking \"Remove\".",
  3548. "maxfps":"Toggles maxfps. When maxfps is on, your fps will be increased.",
  3549. "clearsavedroom":"Clears all the saved rooms.",
  3550. "echo":"Echoes a username. It copies the username's chat messages.",
  3551. "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.",
  3552. "remove":"Removes username from echo list. You will not echo that username anymore.",
  3553. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  3554. "chatw":"It private chats with username. Type /msg to message that username.",
  3555. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  3556. "ignorepm":"Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
  3557. "pmusers":"Dispays who you can private chat with.",
  3558. "pollstat":"Displays the current poll and its votes.",
  3559. "textmode":"Changes the text font.",
  3560. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  3561. "debugger":"Opens debugger.",
  3562. "style":"Change the color of your username, level, and background. For example, '/style 255 0 0' will make your username red.",
  3563. "translate":"Translates peoples texts to the chosen language.",
  3564. "translateto":"You will now speak the chosen language.",
  3565. "autocorrect":"Fixes spelling mistakes.",
  3566. "randomchat":"Spams random chat messages from the past.",
  3567. "lobby":"Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
  3568. "score":"Displays the current score while ingame. Type '/score' again to hide the score.",
  3569. "pan":"Toggles pan mode. Use Shift+Arrow Keys to move the camera around.",
  3570. "resetpan":"Resets pan.",
  3571. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3572. "scroll":"Toggles a scrollbar in ingame chat.",
  3573. "followcam":"Enables follow camera. Your character will be centered on the screen.",
  3574. "autocam":"Zooms in/out enough for you to see everyone on the screen.",
  3575. "zoom":"Zooms in, out, or resets zoom.",
  3576. "xray":"Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3577. "aimbot":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3578. "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.",
  3579. "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.",
  3580. "lagbot":"Makes your movements very laggy. Type '/lagbot 0' to turn it off.",
  3581. "hidechat":"Hides ingame chat. Type '/showchat' to show it again.",
  3582. "showchat":"Shows ingame chat. '/hidechat' hides the chat.",
  3583. "notify":"You will be notified if a person types @username",
  3584. "stopnotify":"You will not be notified if a person types @username",
  3585. "support":"Displays all the people who have supported this mod.",
  3586. "startqp":"Starts cycling maps in your map menu.",
  3587. "stopqp":"Stops cycling maps in your map menu.",
  3588. "revqp":"Reverses the order of quickplay. '/next', '/previous' will be inverted.",
  3589. "pauseqp":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3590. "next":"Skips the map. Usable only with '/startqp'.",
  3591. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  3592. "previous":"Goes to previous map. Usable only with '/startqp'.",
  3593. "shuffle":"Makes quickplay play random maps instead of in order.",
  3594. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3595. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  3596. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  3597. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  3598. "start":"Starts game instantly.",
  3599. "instaqp":"Rounds will instantly start without a countdown.",
  3600. "balanceA":"Balances everyone with balance number.",
  3601. "colorshift": "Shifts the color of the map.",
  3602. "brighten": "Brightens the map by the number.",
  3603. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3604. "balanceT":"Sets everyones balance to the number. The team is 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3605. "killA":"Kills everyone.",
  3606. "jointeam":"Sets the team of anyone who joins. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3607. "moveT":"Sets everyone in one team to another team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3608. "rounds":"Sets rounds to win.",
  3609. "replay":"Replays the movements that were recorded",
  3610. "record":"Records movements of the username",
  3611. "delrecording":"Deletes the recording with the name.",
  3612. "saverecording":"Saves the recording with the name.",
  3613. "loadrecording":"Loads the recording with the name. Type '/replay' to replay it.",
  3614. "stoprecord":"Stops recording the player. Type '/saverecording [text]' to save it.",
  3615. "jukebox":"Sets the jukebox to a link. That link will play for everyone who has this mod.",
  3616. "volume":"Sets the volume of the jukebox.",
  3617. "pausejukebox":"If the jukebox is playing, it pauses it.",
  3618. "resetjukebox":"Resets the jukebox, so it starts from the very beginning.",
  3619. "playjukebox":"If the jukebox is paused, it plays it.",
  3620. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  3621. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  3622. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  3623. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  3624. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  3625. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  3626. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  3627. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  3628. "kill":"Kills the person ingame.",
  3629. "resetpoll":"Clears the poll.",
  3630. "addoption":"Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
  3631. "deloption":"Removes the option with that letter.",
  3632. "startpoll":"Starts a poll that lasts for at least 10 seconds. Type '/endpoll' to end it early.",
  3633. "endpoll":"Ends the poll early if the poll lasted for at least 10 seconds.",
  3634. "addplayer":"In sandbox, it adds bots.",
  3635. "addname":"Adds a bot with a specific name. If that name already exists, it will copy the skin of that player to the bot.",
  3636. "delplayer":"In sandbox, it deletes bots.",
  3637. "copy":"In sandbox, it makes all bots copy the username's movements.",
  3638. "sandbox":"Turns a normal lobby into a sandbox lobby. You cannot turn a sandbox lobby back into a normal lobby.",
  3639. "autokick":"Automatically kicks everyone who is not using this mod.",
  3640. "autoban":"Automatically bans everyone who is not using this mod.",
  3641. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  3642. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  3643. "Alt S":"Starts game instantly.",
  3644. "Alt T":"Toggles teams.",
  3645. "Alt N":"Enables follow camera. Your character will be centered on the screen.",
  3646. "Alt G":"Zooms in.",
  3647. "Alt H":"Resets zoom.",
  3648. "Alt J":"Zooms out.",
  3649. "Alt Y":"Enables xray. Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3650. "Alt E":"Toggles editor.",
  3651. "Alt K":"Exits ingame and returns to lobby.",
  3652. "Alt M":"Switches modes.",
  3653. "Alt V":"Toggles autocam. Autocam zooms in/out enough for you to see everyone on the screen.",
  3654. "Alt Q":"Toggles quickplay.",
  3655. "Alt B":"Displays the current score while ingame. Press Alt B again to hide the score.",
  3656. "Alt A":"Skips the map if quickplay is on.",
  3657. "Alt D":"Goes to previous map if quickplay is on.",
  3658. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3659. "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.",
  3660. "Alt U":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3661. "Alt P":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3662. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  3663. "Alt I":"Opens debugger.",
  3664. "Alt W":"Saves your position, and tries to reach it constantly. This is useful in parkour if you want to go afk.",
  3665. "Alt <":"Lowers ingame chat height.",
  3666. "Alt >":"Highers ingame chat height.",
  3667. "Alt [":"Toggles pan mode. Use Shift+Arrow Keys to move the camera around.",
  3668. "Alt ]":"Resets pan."
  3669. };
  3670. scope.displayadvhelp = function(command){
  3671. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  3672. };
  3673. scope.changemode = function(mode){
  3674. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  3675. RECIEVE('42[26,"b","'+mode+'"]');
  3676. };
  3677. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  3678. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3679. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3680. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3681. document.getElementById('adboxverticalCurse').style["display"] = "none";
  3682. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  3683. elem.onclick=function(e){
  3684. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  3685. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3686. if(reverseqp){
  3687. quicki+=2;
  3688. quicki = quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3689. }
  3690. }
  3691. };
  3692. scope.getCurrentFrame = function(){
  3693. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3694. return currentFrame;
  3695. };
  3696. scope.urlify = function(text) {
  3697. if(!Gdocument.getElementById('bl_Menu')){
  3698. return text.replace(/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:;%.\-_\+~#=]{2,256}\.[\-a-z]{2,6}\b([\-a-zA-Z0-9@:;%_\+.~#?&//=]*)/ig, function(url) {
  3699. var extratext = "";
  3700. var matches = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/);
  3701. if(matches){
  3702. var button = Gdocument.createElement("a");
  3703. button.style["color"] = "green";
  3704. button.textContent = "Play";
  3705. button.href = "javascript:void(0)";
  3706. button.setAttribute("onclick",function(){
  3707. if(Gwindow.ishost){
  3708. Gwindow.SEND("42"+JSON.stringify([4,{"type":"video player","from":Gwindow.username,"url":"URL INSERT HERE","timestamp":Gwindow.Date.now()+2000,"to":[-1]}]));
  3709. Gwindow.displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  3710. Gwindow.changeJukeboxURL("URL INSERT HERE",Gwindow.Date.now()+2000);
  3711. }
  3712. else{
  3713. Gwindow.displayInChat("You need to be host.","#DA0808","#1EBCC1");
  3714. }
  3715. });
  3716. button.attributes["onclick"].nodeValue = button.attributes["onclick"].nodeValue.slice(11,-1).replaceAll("URL INSERT HERE","https://www."+matches[0]);
  3717. var extratext = ' ['+button.outerHTML+']';
  3718. }
  3719. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3720. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3721. })}return text;
  3722. };
  3723. scope.fire = function(type,options,d = Gdocument){
  3724. var event= document.createEvent("HTMLEvents");
  3725. event.initEvent(type,true,false);
  3726. for(var p in options){
  3727. event[p]=options[p];
  3728. }
  3729. d.dispatchEvent(event);
  3730. };
  3731. scope.chat = function(message){
  3732. SEND('42[10,{"message":'+JSON.stringify(message)+'}]');
  3733. };
  3734. scope.chat2 = function(message,enteragain=false){
  3735. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  3736. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  3737. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  3738. Gdocument.getElementById("ingamechatinputtext").value = message;
  3739. fire("keydown",{keyCode:13});
  3740. if(!enteragain){
  3741. fire("keydown",{keyCode:13});
  3742. }
  3743. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  3744. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  3745. };
  3746. scope.sanitize = function(message){
  3747. return message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;');
  3748. };
  3749. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown) {
  3750. options = options ?? {};
  3751. BringDown = BringDown ?? false;
  3752. message2 = message2 ?? "";
  3753. LobbyColor = LobbyColor ?? "#8800FF";
  3754. InGameColor = InGameColor ?? "#AA88FF";
  3755. var A = Gdocument.createElement("div");
  3756. var B = Gdocument.createElement("span");
  3757. B.className = "newbonklobby_chat_status";
  3758. B.style.color = LobbyColor;
  3759. A.appendChild(B);
  3760. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3761. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3762. var C = Gdocument.createElement("div");
  3763. var D = Gdocument.createElement("span");
  3764. D.style.color = InGameColor;
  3765. C.appendChild(D);
  3766. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3767. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3768. var a = BringDown;
  3769. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  3770. a = true;
  3771. }
  3772. var b = BringDown;
  3773. if(Gdocument.getElementById("ingamechatcontent").clientHeight + Gdocument.getElementById("ingamechatcontent").scrollTop >= Gdocument.getElementById("ingamechatcontent").scrollHeight-1) {
  3774. b = true;
  3775. }
  3776. A.style["parsed"] = true;
  3777. C.style["parsed"] = true;
  3778. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  3779. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  3780. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Gdocument.getElementById("newbonklobby_chat_content").scrollHeight;};
  3781. if (b) { Gdocument.getElementById("ingamechatcontent").scrollTop = Gdocument.getElementById("ingamechatcontent").scrollHeight;};
  3782. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"]!="auto" && !Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  3783. chat2("");
  3784. }
  3785. };
  3786. scope.lobby = function(){
  3787. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  3788. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3789. Gdocument.getElementById("mapeditor_close").click();
  3790. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  3791. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  3792. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  3793. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  3794. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  3795. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  3796. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  3797. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  3798. debuggermenu.style["z-index"] = 2;
  3799. }
  3800. else{
  3801. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3802. Gdocument.getElementById("newbonklobby").style["display"]="none";
  3803. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3804. }
  3805. }
  3806. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3807. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3808. Gdocument.getElementById("newbonklobby").style["display"]="none";
  3809. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3810. }
  3811. };
  3812. scope.lastmessage = function(){
  3813. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  3814. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  3815. var lm2 = "";
  3816. for(var i = 0; i<lm.length;i++){
  3817. lm2+=" "+lm[i].textContent.trim();
  3818. }
  3819. lm2 = lm2.trim();
  3820. if(lm2.startsWith("*")){
  3821. return lm2;
  3822. }
  3823. }
  3824. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  3825. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  3826. var lm2 = "";
  3827. for(var i = 0; i<lm.length;i++){
  3828. lm2+=" "+lm[i].textContent.trim();
  3829. }
  3830. return lm2.trim();
  3831. }
  3832. return "";
  3833. };
  3834. scope.map = function(e,t=timedelay){
  3835. if(e<0){
  3836. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3837. quicki = 0;
  3838. return;
  3839. }
  3840. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3841. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3842. return;
  3843. }
  3844. setTimeout(function(){if(!canceled){
  3845. startedinqp = true;
  3846. if(roundsperqp2>=roundsperqp){
  3847. roundsperqp2 = 0;
  3848. }
  3849. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3850. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3851. if(recmodebool && ishost){
  3852. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3853. if(mode == "" && defaultmode!="d"){
  3854. mode = defaultmode;
  3855. }
  3856. if(mode != ""){
  3857. RECIEVE('42[26,"b","'+mode+'"]');
  3858. }
  3859. }
  3860. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3861. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3862. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3863. if(displayblock){
  3864. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3865. }
  3866. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  3867. canceled = false;
  3868. transitioning = false;
  3869. },t);
  3870. };
  3871. scope.gotonextmap = function(e){
  3872. if(e<0){
  3873. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3874. quicki = 0;
  3875. return;
  3876. }
  3877. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3878. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3879. return;
  3880. }
  3881. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3882. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3883. if(recmodebool && ishost){
  3884. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3885. if(mode == "" && defaultmode!="d"){
  3886. mode = defaultmode;
  3887. }
  3888. if(mode != ""){
  3889. RECIEVE('42[26,"b","'+mode+'"]');
  3890. }
  3891. }
  3892. startedinqp = true;
  3893. if(roundsperqp2>=roundsperqp){
  3894. roundsperqp2 = 0;
  3895. }
  3896. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3897. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3898. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3899. if(displayblock){
  3900. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3901. }
  3902. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3903. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  3904. };
  3905. scope.commandhandle = function(chat_val){
  3906. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3907. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")==username){
  3908. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  3909. return "";
  3910. }
  3911. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))===-1) {
  3912. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  3913. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is being echoed.","#DA0808","#1EBCC1");
  3914. return "";
  3915. }
  3916. else{
  3917. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is already being echoed.","#DA0808","#1EBCC1");
  3918. return "";
  3919. }
  3920. }
  3921. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3922. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))!==-1){
  3923. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")),1);
  3924. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+" is not being echoed.","#DA0808","#1EBCC1");
  3925. return "";
  3926. }
  3927. else{
  3928. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  3929. return "";
  3930. }
  3931. }
  3932. else if (chat_val.substring(1,10)=="echotext " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  3933. echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3934. displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  3935. displayInChat("Type '/echotext' to reset echotext.","#DA0808","#1EBCC1");
  3936. return "";
  3937. }
  3938. else if (chat_val.substring(1,9)=="echotext"){
  3939. echotext = "message";
  3940. displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  3941. return "";
  3942. }
  3943. else if (chat_val.substring(1,10)=="clearecho"){
  3944. echo_list = [];
  3945. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  3946. return "";
  3947. }
  3948. else if (chat_val.substring(1,11)=="randomchat"){
  3949. if(randomchat == true){
  3950. displayInChat("Random chat is now off.","#DA0808","#1EBCC1");
  3951. randomchat = false;
  3952. }
  3953. else{
  3954. displayInChat("Random chat is now on.","#DA0808","#1EBCC1");
  3955. randomchat = true;
  3956. }
  3957. return "";
  3958. }
  3959. else if (chat_val.substring(1,12)=="autocorrect"){
  3960. if(autocorrect == true){
  3961. displayInChat("Autocorrect is now off.","#DA0808","#1EBCC1");
  3962. autocorrect = false;
  3963. }
  3964. else{
  3965. displayInChat("Autocorrect is now on.","#DA0808","#1EBCC1");
  3966. autocorrect = true;
  3967. }
  3968. return "";
  3969. }
  3970. else if (chat_val.substring(1,13)=="translateto " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3971. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '').toLowerCase();
  3972. var keys = Object.keys(translatingkeys);
  3973. if(keys.includes(text)){
  3974. translating2 = [true,translatingkeys[text]];
  3975. displayInChat("You will now speak the "+text+" language.","#DA0808","#1EBCC1");
  3976. }
  3977. else{
  3978. displayInChat("Invalid language. Here are the current language options:","#DA0808","#1EBCC1");
  3979. for(var i = 0;i<keys.length;i++){
  3980. displayInChat(keys[i],"#DA0808","#1EBCC1");
  3981. }
  3982. }
  3983. return "";
  3984. }
  3985. else if (chat_val.substring(1,12)=="translateto"){
  3986. translating2 = [false,""];
  3987. displayInChat("You will not speak another language anymore.","#DA0808","#1EBCC1");
  3988. return "";
  3989. }
  3990. else if (chat_val.substring(1,11)=="translate " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3991. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '').toLowerCase();
  3992. var keys = Object.keys(translatingkeys);
  3993. if(keys.includes(text)){
  3994. translating = [true,translatingkeys[text]];
  3995. displayInChat("Translator has been set to the "+text+" language.","#DA0808","#1EBCC1");
  3996. }
  3997. else{
  3998. displayInChat("Invalid language. Here are the current language options:","#DA0808","#1EBCC1");
  3999. for(var i = 0;i<keys.length;i++){
  4000. displayInChat(keys[i],"#DA0808","#1EBCC1");
  4001. }
  4002. }
  4003. return "";
  4004. }
  4005. else if (chat_val.substring(1,10)=="translate"){
  4006. translating = [false,""];
  4007. displayInChat("Translator has been turned off.","#DA0808","#1EBCC1");
  4008. return "";
  4009. }
  4010. else if (chat_val.substring(1,6)=="space"){
  4011. if(space_flag == true){
  4012. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  4013. space_flag = false;
  4014. }
  4015. else{
  4016. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  4017. space_flag = true;
  4018. }
  4019. return "";
  4020. }
  4021. else if (chat_val.substring(1,6)=="rcaps"){
  4022. if(rcaps_flag == true){
  4023. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  4024. rcaps_flag = false;
  4025. }
  4026. else{
  4027. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  4028. rcaps_flag = true;
  4029. }
  4030. return "";
  4031. }
  4032. else if (chat_val.substring(1,7)=="number"){
  4033. if(number_flag == true){
  4034. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  4035. number_flag = false;
  4036. }
  4037. else{
  4038. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  4039. number_flag = true;
  4040. }
  4041. return "";
  4042. }
  4043. else if (chat_val.substring(1,8)=="reverse"){
  4044. if(reverse_flag == true){
  4045. displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  4046. reverse_flag = false;
  4047. }
  4048. else{
  4049. displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  4050. reverse_flag = true;
  4051. }
  4052. return "";
  4053. }
  4054. else if (chat_val.substring(1,7)=="speech"){
  4055. if(text2speech == true){
  4056. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  4057. text2speech = false;
  4058. }
  4059. else{
  4060. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  4061. text2speech = true;
  4062. }
  4063. return "";
  4064. }
  4065. else if (chat_val.substring(1,7)=="maxfps"){
  4066. if(maxfps){
  4067. displayInChat("Max FPS is now off.","#DA0808","#1EBCC1");
  4068. maxfps = false;
  4069. }
  4070. else{
  4071. displayInChat("Max FPS is now on.","#DA0808","#1EBCC1");
  4072. maxfps = true;
  4073. }
  4074. return "";
  4075. }
  4076. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4077. var ev = "";
  4078. try{
  4079. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  4080. }
  4081. catch(e){
  4082. displayInChat(e.message,"#DA0808","#1EBCC1");
  4083. }
  4084. try{
  4085. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  4086. }
  4087. catch{
  4088. }
  4089. return "";
  4090. }
  4091. else if (chat_val.substring(1,10)=="textmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4092. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  4093. var parsed = parseInt(text);
  4094. if(!isNaN(parsed)){
  4095. if(parsed<=7 && parsed>=1){
  4096. textmode = parsed-1;
  4097. displayInChat("Type '/textmode' to reset textmode.","#DA0808","#1EBCC1");
  4098. }
  4099. else{
  4100. displayInChat("Please enter a integer from 1-7 inclusive.","#DA0808","#1EBCC1");
  4101. }
  4102. }
  4103. else{
  4104. displayInChat("Please enter a integer from 1-7 inclusive.","#DA0808","#1EBCC1");
  4105. }
  4106. return "";
  4107.  
  4108. }
  4109. else if (chat_val.substring(1,9)=="textmode"){
  4110. textmode = -1;
  4111. displayInChat("Reset textmode.","#DA0808","#1EBCC1");
  4112. return "";
  4113. }
  4114. else if (chat_val.substring(1,10)=="savedroom"){
  4115. if(savedrooms.length == 0){
  4116. displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  4117. return "";
  4118. }
  4119. else{
  4120. var keys = Object.keys(savedroomsdata);
  4121. for(var i = 0;i<keys.length;i++){
  4122. var code = 'this.parentElement.remove();delete Gwindow.savedroomsdata["'+keys[i]+'"];Gwindow.savedrooms.splice(Gwindow.savedrooms.indexOf('+keys[i]+'),1);';
  4123. 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.");
  4124. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  4125. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  4126. Laster_message = lastmessage();
  4127. }
  4128. }
  4129. return "";
  4130. }
  4131. else if (chat_val.substring(1,15)=="clearsavedroom"){
  4132. if(savedrooms.length == 0){
  4133. displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  4134. return "";
  4135. }
  4136. else{
  4137. var keys = Object.keys(savedroomsdata);
  4138. for(var i = 0;i<keys.length;i++){
  4139. savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])),1);
  4140. delete savedroomsdata[keys[i]];
  4141. }
  4142. }
  4143. return "";
  4144. }
  4145. else if (chat_val.substring(1,10)=="followcam"){
  4146. if(FollowCam == true){
  4147. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  4148. FollowCam = false;
  4149. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4150. var addto = {"children":[]};
  4151. for(var i = 0;i<parentDraw.children.length;i++){
  4152. if(parentDraw.children[i].constructor.name == "e"){
  4153. addto = parentDraw.children[i];
  4154. break;
  4155. }
  4156. }
  4157. var canv = 0;
  4158. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4159. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4160. canv = Gdocument.getElementById("gamerenderer").children[i];
  4161. break;
  4162. }
  4163. }
  4164. var width = parseInt(canv.style["width"]);
  4165. var height = parseInt(canv.style["height"]);
  4166. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4167. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4168. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4169. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4170. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  4171. pixiCircle.visible = false;
  4172. }
  4173. else{
  4174. pixiCircle.visible = true;
  4175. }
  4176. }
  4177. }
  4178. else{
  4179. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  4180. FollowCam = true;
  4181. }
  4182. return "";
  4183. }
  4184. else if (chat_val.substring(1,8)=="autocam"){
  4185. if(autocam == true){
  4186. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  4187. autocam = false
  4188. }
  4189. else{
  4190. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  4191. autocam = true;
  4192. }
  4193. return "";
  4194. }
  4195. else if (chat_val.substring(1,4)=="pan"){
  4196. if(pan_enabled == true){
  4197. displayInChat("Pan is now off.","#DA0808","#1EBCC1");
  4198. pan_enabled = false;
  4199. pan = {"x":0,"y":0};
  4200. }
  4201. else{
  4202. displayInChat("Pan is now on. Shift + Arrow Keys to pan.","#DA0808","#1EBCC1");
  4203. pan_enabled = true;
  4204. }
  4205. return "";
  4206. }
  4207. else if (chat_val.substring(1,9)=="resetpan"){
  4208. pan = {"x":0,"y":0};
  4209. displayInChat("Reset pan.","#DA0808","#1EBCC1");
  4210. return "";
  4211. }
  4212. else if (chat_val.substring(1,7)=="aimbot"){
  4213. if(aimbot == true){
  4214. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  4215. aimbot = false;
  4216. }
  4217. else{
  4218. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  4219. aimbot = true;
  4220. getplayerkeys();
  4221. }
  4222. return "";
  4223. }
  4224. else if (chat_val.substring(1,8)=="volume " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4225. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4226. if(!isNaN(parseInt(text))){
  4227. int_text = parseInt(text);
  4228. if(int_text>=0 && int_text<=100){
  4229. jukeboxplayer.volume = int_text/100;
  4230. jukeboxplayervolume = int_text;
  4231. displayInChat("Jukebox volume set to: "+int_text.toString()+" percent.","#DA0808","#1EBCC1");
  4232. }
  4233. else{
  4234. displayInChat("Volume must be between 0 and 100 percent.","#DA0808","#1EBCC1");
  4235. }
  4236. }
  4237. return "";
  4238. }
  4239. else if (chat_val.substring(1,6)=="still"){
  4240. if(staystill == true){
  4241. displayInChat("Still is now off.","#DA0808","#1EBCC1");
  4242. staystill = false;
  4243. staystillpos = [0,0];
  4244. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  4245. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  4246. }
  4247. else{
  4248. if(playerids[myid].playerData?.transform){
  4249. displayInChat("Still is now on.","#DA0808","#1EBCC1");
  4250. staystill = true;
  4251. staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  4252. getplayerkeys();
  4253. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  4254. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  4255. }
  4256. else{
  4257. displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  4258. }
  4259. }
  4260. return "";
  4261. }
  4262. else if (chat_val.substring(1,9)=="heavybot"){
  4263. if(heavybot == true){
  4264. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  4265. heavybot = false;
  4266. }
  4267. else{
  4268. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  4269. heavybot = true;
  4270. getplayerkeys();
  4271. }
  4272. return "";
  4273. }
  4274. else if (chat_val.substring(1,5)=="xray"){
  4275. Gdocument.getElementById("pretty_top_settings").click();
  4276. Gdocument.getElementById("settings_close").click();
  4277. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  4278. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  4279. return "";
  4280. }
  4281. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4282. var addto = {"children":[]};
  4283. for(var i = 0;i<parentDraw.children.length;i++){
  4284. if(parentDraw.children[i].constructor.name == "e"){
  4285. addto = parentDraw.children[i];
  4286. break;
  4287. }
  4288. }
  4289. var addto2 = {"children":[]};
  4290. for(var i = 0;i<addto.children.length;i++){
  4291. if(addto.children[i].constructor.name == "e"){
  4292. addto2 = addto.children[i];
  4293. break;
  4294. }
  4295. }
  4296. var checkxray = addto2.children[0];
  4297. var addto3 = addto2.children[0].children;
  4298. if(addto3.length==1){
  4299. checkxray = checkxray.children[0];
  4300. addto3 = addto3[0].children;
  4301. }
  4302. var xrayon = false;
  4303. if(checkxray.xrayon){
  4304. checkxray.xrayon = false;
  4305. xrayon = false;
  4306. }
  4307. else{
  4308. checkxray.xrayon = true;
  4309. xrayon = true;
  4310. }
  4311. if(xrayon){
  4312. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  4313. for(var i = 0;i<addto3.length;i++){
  4314. if(addto3[i].children.length>0){
  4315. var ids = [];
  4316. var ids2 = [];
  4317. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4318. addto3[i].children[i3].visible = false;
  4319. if(addto3[i].children[i3].children.length>0){
  4320. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  4321. if(addto3[i].children[i3].children[i4].geometry?.id){
  4322. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  4323. }
  4324. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  4325. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  4326. }
  4327. }
  4328. }
  4329. }
  4330. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4331. if(addto3[i].children[i3].children.length==0){
  4332. if(addto3[i].children[i3].geometry?.id){
  4333. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  4334. addto3[i].children[i3].visible = true;
  4335. addto3[i].children[i3].alpha = 0.5;
  4336. }
  4337. }
  4338. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  4339. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  4340. addto3[i].children[i3].visible = true;
  4341. addto3[i].children[i3].alpha = 0.5;
  4342. }
  4343. }
  4344. }
  4345. }
  4346. }
  4347. }
  4348. }
  4349. else{
  4350. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  4351. for(var i = 0;i<addto3.length;i++){
  4352. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  4353. addto3[i].children[i2].visible = true;
  4354. addto3[i].children[i2].alpha = 1;
  4355. }
  4356. }
  4357. }
  4358. }
  4359. return "";
  4360. }
  4361. else if (chat_val.substring(1,6)=="zoom "){
  4362. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4363. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4364. var addto = 0;
  4365. for(var i = 0;i<parentDraw.children.length;i++){
  4366. if(parentDraw.children[i].constructor.name == "e"){
  4367. addto = parentDraw.children[i];
  4368. break;
  4369. }
  4370. }
  4371. var canv = 0;
  4372. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4373. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4374. canv = Gdocument.getElementById("gamerenderer").children[i];
  4375. break;
  4376. }
  4377. }
  4378. var width = parseInt(canv.style["width"]);
  4379. var height = parseInt(canv.style["height"]);
  4380. if(addto){
  4381. if(text == "in"){
  4382. zoom *= 1.1;
  4383. }
  4384. else if(text == "out"){
  4385. zoom /= 1.1;
  4386. }
  4387. else if(text == "reset"){
  4388. zoom = 1;
  4389. }
  4390. else{
  4391. displayInChat("Options for zooming:","#DA0808","#1EBCC1");
  4392. displayInChat("in","#DA0808","#1EBCC1");
  4393. displayInChat("out","#DA0808","#1EBCC1");
  4394. displayInChat("reset","#DA0808","#1EBCC1");
  4395. return "";
  4396. }
  4397. addto.scale.x=zoom;
  4398. addto.scale.y=zoom;
  4399. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4400. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4401. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4402. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4403. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  4404. pixiCircle.visible = false;
  4405. }
  4406. else{
  4407. pixiCircle.visible = true;
  4408. }
  4409. }
  4410. }
  4411. return "";
  4412. }
  4413. else if (chat_val.substring(1,9)=="hidechat"){
  4414. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  4415. return "";
  4416. }
  4417. else if (chat_val.substring(1,9)=="showchat"){
  4418. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4419. return "";
  4420. }
  4421. else if (chat_val.substring(1,6)=="score"){
  4422. var element = Gdocument.getElementById("ingamewinner_scores");
  4423. if(element.style["opacity"]<1){
  4424. element.style["opacity"] = 1;
  4425. element.style["visibility"] = "visible";
  4426. }
  4427. else{
  4428. element.style["opacity"] = 0;
  4429. element.style["visibility"] = "unset";
  4430. }
  4431. return "";
  4432. }
  4433. else if (chat_val.substring(1,7)=="scroll"){
  4434. if(scroll==false){
  4435. scroll = true;
  4436. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  4437. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  4438. }
  4439. else if(scroll==true){
  4440. scroll = false;
  4441. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  4442. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  4443. }
  4444. return "";
  4445. }
  4446. else if (chat_val.substring(1,7)=="chatw "){
  4447. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4448. if(username == text){
  4449. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  4450. return "";
  4451. }
  4452. private_chat = text;
  4453. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  4454. request_public_key_time_stamp = Date.now();
  4455. 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);
  4456. return "";
  4457. }
  4458. else if (chat_val.substring(1,8)=="lagbot " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4459. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4460. if(!isNaN(parseInt(text))){
  4461. int_text = parseInt(text);
  4462. if(int_text == 0){
  4463. causelag = false;
  4464. causelag2 = 0;
  4465. displayInChat("Lagbot is now off.","#DA0808","#1EBCC1");
  4466. displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4467. }
  4468. else if(int_text>0 && int_text<=10){
  4469. causelag = true;
  4470. causelag2 = 45*int_text;
  4471. displayInChat("Lagbot is now on with a lag setting of "+int_text.toString()+" (~"+(45*int_text).toString()+"MS).","#DA0808","#1EBCC1");
  4472. displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4473. }
  4474. else{
  4475. displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4476. displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4477. }
  4478. return "";
  4479. }
  4480. }
  4481. else if (chat_val.substring(1,8)=="record " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4482. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4483. var keys = Object.keys(playerids);
  4484. var recordingid2 = -1;
  4485. for(var i = 0;i<keys.length;i++){
  4486. if(playerids[keys[i]].userName == text){
  4487. recordingid2 = keys[i];
  4488. }
  4489. }
  4490. if(recordingid2 == -1){
  4491. displayInChat("Player not found. Please type a valid username.","#DA0808","#1EBCC1");
  4492. return "";
  4493. }
  4494. else{
  4495. recording = true;
  4496. recordingid = recordingid2;
  4497. displayInChat(playerids[recordingid].userName+" is now being recorded.","#DA0808","#1EBCC1");
  4498. if(recordingdata.length>0){
  4499. displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4500. }
  4501. recordingdata = [];
  4502. }
  4503. return "";
  4504. }
  4505. else if (chat_val.substring(1,11)=="stoprecord"){
  4506. if(recording){
  4507. displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4508. displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4509. recording = false;
  4510. recordingid = -1;
  4511. recordingdata[0][1] = 0;
  4512. }
  4513. else{
  4514. displayInChat("No one is being recorded.","#DA0808","#1EBCC1");
  4515. }
  4516. return "";
  4517. }
  4518. else if (chat_val.substring(1,15)=="saverecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4519. var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4520. if(Object.keys(recorddata).includes(text)){
  4521. displayInChat("This recording already exists. Please use a different name or type '/delrecording "+text+"'.","#DA0808","#1EBCC1");
  4522. }
  4523. else if(recordingdata.length>0){
  4524. recorddata[text] = JSON.parse(JSON.stringify(recordingdata));
  4525. displayInChat("Recording saved as: "+text,"#DA0808","#1EBCC1");
  4526. }
  4527. else{
  4528. displayInChat("There is no recording data to save. Please record data using '/record [username]'","#DA0808","#1EBCC1");
  4529. }
  4530. return "";
  4531. }
  4532. else if (chat_val.substring(1,14)=="delrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=15){
  4533. var text = chat_val.substring(14).replace(/^\s+|\s+$/g, '');
  4534. if(Object.keys(recorddata).includes(text)){
  4535. displayInChat("Recording deleted.","#DA0808","#1EBCC1");
  4536. delete recorddata[text];
  4537. }
  4538. else{
  4539. displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4540. }
  4541. return "";
  4542. }
  4543. else if (chat_val.substring(1,15)=="loadrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4544. var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4545. if(!Object.keys(recorddata).includes(text)){
  4546. displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4547. }
  4548. else{
  4549. if(recordingdata.length>0){
  4550. displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4551. }
  4552. recordingdata = JSON.parse(JSON.stringify(recorddata[text]));
  4553. displayInChat("Recording data is now loaded.","#DA0808","#1EBCC1");
  4554. }
  4555. return "";
  4556. }
  4557. else if (chat_val.substring(1,7)=="replay"){
  4558. if(recording){
  4559. displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4560. displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4561. recordingid = -1;
  4562. recording = false;
  4563. recordingdata[0][1] = 0;
  4564. }
  4565. replay();
  4566. return "";
  4567. }
  4568. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4569. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  4570. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  4571. pmlastmessage = text.slice(0,400);
  4572. ENCRYPT_MESSAGE(private_chat_public_key[1],text).then(function(e){
  4573. SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"message":e}]));
  4574. });
  4575. displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  4576. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  4577. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  4578. Laster_message = lastmessage();
  4579. }
  4580. return "";
  4581. }
  4582. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4583. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4584. if(ignorepmlist.includes(text)){
  4585. var index = ignorepmlist.indexOf(text);
  4586. ignorepmlist.splice(index,1);
  4587. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4588. }
  4589. else{
  4590. ignorepmlist.push(text);
  4591. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4592. }
  4593. return "";
  4594. }
  4595. else if (chat_val.substring(1,8)=="pmusers"){
  4596. pmusers = [];
  4597. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  4598. pmuserstimestamp = Date.now();
  4599. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  4600. }else{displayInChat("You can private chat with:","#DA0808","#1EBCC1");for(var i = 0;i<pmusers.length;i++){var code = 'Gwindow.private_chat = '+JSON.stringify(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);
  4601. return "";
  4602. }
  4603. else if (chat_val.substring(1,6)=="lobby"){
  4604. lobby();
  4605. return "";
  4606. }
  4607. else if (chat_val.substring(1,7)=="style " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4608. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  4609. var text2 = text.split(" ");
  4610. var array = [];
  4611. for(var i = 0;i<text2.length;i++){
  4612. var parsed = parseInt(text2[i]);
  4613. if(!isNaN(parsed)){
  4614. array.push(parsed);
  4615. }
  4616. }
  4617. if(array[0]+array[1]+array[2] == 0){
  4618. array = [1,1,1];
  4619. }
  4620. if(array.length == 3){
  4621. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":array}]));
  4622. allstyles[username] = array;
  4623. mystyle = [...array];
  4624. displayInChat("Set style to ("+array.toString()+"). Type '/style' to reset style.","#DA0808","#1EBCC1");
  4625. }
  4626. else{
  4627. 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");
  4628. }
  4629. return "";
  4630. }
  4631. else if (chat_val.substring(1,6)=="style"){
  4632. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":[0,0,0]}]));
  4633. allstyles[username] = [0,0,0];
  4634. mystyle = [0,0,0];
  4635. displayInChat("Reset style.","#DA0808","#1EBCC1");
  4636. return "";
  4637. }
  4638. else if (chat_val.substring(1,6)=="lobby"){
  4639. lobby();
  4640. return "";
  4641. }
  4642. else if (chat_val.substring(1,9)=="debugger"){
  4643. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  4644. debuggeropen = true;
  4645. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  4646. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  4647. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  4648. }
  4649. else{
  4650. debuggeropen = false;
  4651. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  4652. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  4653. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  4654. }
  4655. return "";
  4656. }
  4657. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4658. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4659. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  4660. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  4661. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  4662. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  4663. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  4664. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  4665. return "";
  4666. }
  4667. else if (chat_val.substring(1,7)=="notify"){
  4668. npermissions = 1;
  4669. return "";
  4670. }
  4671. else if (chat_val.substring(1,11)=="stopnotify"){
  4672. npermissions = 0;
  4673. return "";
  4674. }
  4675. else if (chat_val.substring(1,8)=="support"){
  4676. displayInChat("Thanks everyone for helping me make this mod - LEGENDBOSS123","#0000FF","#FFFFFF");
  4677. displayInChat("mastery3","#0000FF","#FFFFFF");
  4678. displayInChat("UnmatchedBracket aka Left Paren","#0000FF","#FFFFFF");
  4679. displayInChat("iNeonz","#0000FF","#FFFFFF");
  4680. return "";
  4681. }
  4682. else if (chat_val.substring(1,9)=="pollstat"){
  4683. if(pollactive[0] || pollactive2[0]){
  4684. var count = [0,0,0,0];
  4685. var keys = Object.keys(playerids);
  4686. for(var i = 0;i<keys.length;i++){
  4687. if(ishost){
  4688. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  4689. count[playerids[keys[i]].vote.poll]++;
  4690. }
  4691. }
  4692. else{
  4693. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  4694. count[playerids[keys[i]].vote.poll]++;
  4695. }
  4696. }
  4697. }
  4698. for(var i = 0;i<count.length;i++){
  4699. if(count[i]>1){
  4700. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4701. }
  4702. if(count[i]==1){
  4703. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4704. }
  4705. }
  4706. if(ishost){
  4707. displayInChat("The poll will end in: "+((pollactive[2]-Date.now())/1000).toString()+" seconds.","#DA0808","#1EBCC1");
  4708. }
  4709. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4710. if(ishost){
  4711. for(var i = 0;i<pollactive[3].length;i++){
  4712. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  4713. }
  4714. }
  4715. else{
  4716. for(var i = 0;i<pollactive2[2].length;i++){
  4717. displayInChat(letters[i]+") "+pollactive2[2][i],"#DA0808","#1EBCC1");
  4718. }
  4719. }
  4720. }
  4721. else{
  4722. displayInChat("No poll has been started.","#DA0808","#1EBCC1");
  4723. if(ishost){
  4724. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  4725. if(poll.length>0){
  4726. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4727. for(var i = 0;i<poll.length;i++){
  4728. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4729. }
  4730. }
  4731. }
  4732. }
  4733. return "";
  4734. }
  4735. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  4736. for(var i = 0;i<help.length;i++){
  4737. if(help[i].startsWith("/")){
  4738. var splitted = help[i].substring(1).split(" ");
  4739. var command = splitted[0];
  4740. var rest = "";
  4741. if(splitted.length>1){
  4742. rest = " "+splitted.slice(1).join(" ");
  4743. }
  4744. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4745. }
  4746. else if(help[i].startsWith("Alt ")){
  4747. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4748. }
  4749. else{
  4750. displayInChat(help[i],"#DA0808","#1EBCC1");
  4751. }
  4752. }
  4753. return "";
  4754. }
  4755. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4756. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4757. if(typeof(adv_help[text])!='undefined'){
  4758. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  4759. }
  4760. return "";
  4761. }
  4762. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4763. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4764. var mode = "";
  4765. var text2 = text;
  4766. if(text == "arrows"){
  4767. text2 = "Arrows";
  4768. mode = "ar";
  4769. }
  4770. else if(text == "death arrows"){
  4771. mode = "ard";
  4772. text2 = "Death Arrows";
  4773. }
  4774. else if(text == "grapple"){
  4775. mode = "sp";
  4776. text2 = "Grapple";
  4777. }
  4778. else if(text == "classic"){
  4779. mode = "b";
  4780. text2 = "Classic";
  4781. }
  4782. else{
  4783. displayInChat("Mode options:","#DA0808","#1EBCC1");
  4784. displayInChat("classic","#DA0808","#1EBCC1");
  4785. displayInChat("arrows","#DA0808","#1EBCC1");
  4786. displayInChat("death arrows","#DA0808","#1EBCC1");
  4787. displayInChat("grapple","#DA0808","#1EBCC1");
  4788. }
  4789. if(mode != ""){
  4790. if(ishost){
  4791. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  4792. RECIEVE('42[26,"b","'+mode+'"]');
  4793. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  4794. }
  4795. else{
  4796. if(playerids[myid].ratelimit.mode+1000<Date.now()){
  4797. playerids[myid].ratelimit.mode=Date.now();
  4798. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  4799. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  4800. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  4801. }
  4802. else{
  4803. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  4804. }
  4805. }
  4806. }
  4807. return "";
  4808. }
  4809. else if(ishost){
  4810. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4811. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4812. if(isNaN(text)){
  4813. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4814. return "";
  4815. }
  4816. else if(text<=0){
  4817. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4818. return "";
  4819. }
  4820. nextafter = text;
  4821. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  4822. displayInChat("Type '/nextafter' to reset next after.","#DA0808","#1EBCC1");
  4823. return "";
  4824. }
  4825. else if (chat_val.substring(1,10)=="nextafter"){
  4826. nextafter = 0;
  4827. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  4828. return "";
  4829. }
  4830. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  4831. roundsperqp2 = 0;
  4832. if(shuffle){
  4833. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4834. var available = [];
  4835. var availableindexes = [];
  4836. var notempty = false;
  4837. for(var i = 0; i<e.length;i++){
  4838. var a = false;
  4839. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4840. available.push(a);
  4841. if(a){
  4842. availableindexes.push(i);
  4843. notempty = true;
  4844. }
  4845. }
  4846. if(notempty){
  4847. if(availableindexes.length!=1){
  4848. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4849. }
  4850. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4851. }
  4852. }
  4853. else{
  4854. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4855. var available = [];
  4856. var availableindexes = [];
  4857. var notempty = false;
  4858. for(var i = 0; i<e.length;i++){
  4859. var a = false;
  4860. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4861. available.push(a);
  4862. if(a){
  4863. availableindexes.push(i);
  4864. notempty = true;
  4865. }
  4866. }
  4867. if(notempty){
  4868. var above = [];
  4869. for(var i = 0;i<availableindexes.length;i++){
  4870. if(availableindexes[i]>quicki && !reverseqp){
  4871. above.push(availableindexes[i]);
  4872. }
  4873. else if(availableindexes[i]<quicki && reverseqp){
  4874. above.push(availableindexes[i])
  4875. }
  4876. }
  4877. if(above.length>0){
  4878. quicki = above[0];
  4879. if(reverseqp){
  4880. quicki = above[above.length-1];
  4881. }
  4882. }
  4883. else{
  4884. quicki = availableindexes[0];
  4885. if(reverseqp){
  4886. quicki = availableindexes[availableindexes.length-1];
  4887. }
  4888. }
  4889. }
  4890. }
  4891. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4892. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  4893. return "";
  4894. }
  4895. else if (chat_val.substring(1,9)=="freejoin"){
  4896. if(freejoin == false){
  4897. freejoin = true;
  4898. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  4899. }
  4900. else{
  4901. freejoin = false;
  4902. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  4903. }
  4904. return "";
  4905. }
  4906. else if (chat_val.substring(1,8)=="instaqp"){
  4907. if(instaqp == false){
  4908. instaqp = true;
  4909. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  4910. }
  4911. else{
  4912. instaqp = false;
  4913. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  4914. }
  4915. return "";
  4916. }
  4917. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  4918. roundsperqp2 = 0;
  4919. if(shuffle){
  4920. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4921. var available = [];
  4922. var availableindexes = [];
  4923. var notempty = false;
  4924. for(var i = 0; i<e.length;i++){
  4925. var a = false;
  4926. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4927. available.push(a);
  4928. if(a){
  4929. availableindexes.push(i);
  4930. notempty = true;
  4931. }
  4932. }
  4933. if(notempty){
  4934. if(availableindexes.length!=1){
  4935. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4936. }
  4937. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4938. }
  4939. }
  4940. else{
  4941. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4942. var available = [];
  4943. var availableindexes = [];
  4944. var notempty = false;
  4945. for(var i = 0; i<e.length;i++){
  4946. var a = false;
  4947. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4948. available.push(a);
  4949. if(a){
  4950. availableindexes.push(i);
  4951. notempty = true;
  4952. }
  4953. }
  4954. if(notempty){
  4955. var above = [];
  4956. for(var i = 0;i<availableindexes.length;i++){
  4957. if(availableindexes[i]<quicki && !reverseqp){
  4958. above.push(availableindexes[i]);
  4959. }
  4960. else if(availableindexes[i]>quicki && reverseqp){
  4961. above.push(availableindexes[i])
  4962. }
  4963. }
  4964. if(above.length>0){
  4965. quicki = above[above.length-1];
  4966. if(reverseqp){
  4967. quicki = above[0];
  4968. }
  4969. }
  4970. else{
  4971. quicki = availableindexes[availableindexes.length-1];
  4972. if(reverseqp){
  4973. quicki = availableindexes[0];
  4974. }
  4975. }
  4976. }
  4977. }
  4978. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4979. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  4980. return "";
  4981. }
  4982. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  4983. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  4984. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4985. }
  4986. if(recmodebool && ishost){
  4987. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  4988. if(mode == "" && defaultmode!="d"){
  4989. mode = defaultmode;
  4990. }
  4991. if(mode != ""){
  4992. RECIEVE('42[26,"b","'+mode+'"]');
  4993. }
  4994. }
  4995. Gdocument.getElementById("mapeditor_close").click();
  4996. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  4997. roundsperqp2 = 0;
  4998. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  4999. return "";
  5000. }
  5001. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  5002. stopquickplay = 0;
  5003. quicki = 0;
  5004. qppaused = false;
  5005. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  5006. return "";
  5007. }
  5008. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  5009. stopquickplay = 1;
  5010. quicki = 0;
  5011. qppaused = false;
  5012. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  5013. return "";
  5014. }
  5015. else if (chat_val.substring(1,8)=="pauseqp" && stopquickplay == 0){
  5016. if(qppaused == false){
  5017. qppaused = true;
  5018. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  5019. }
  5020. else{
  5021. qppaused = false;
  5022. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  5023. }
  5024. return "";
  5025. }
  5026. else if (chat_val.substring(1,6)=="revqp" && stopquickplay == 0){
  5027. if(reverseqp == false){
  5028. reverseqp = true;
  5029. displayInChat("Reverseqp is now on..","#DA0808","#1EBCC1");
  5030. }
  5031. else{
  5032. reverseqp = false;
  5033. displayInChat("Reverseqp is now off.","#DA0808","#1EBCC1");
  5034. }
  5035. return "";
  5036. }
  5037. else if (chat_val.substring(1,9)=="jukebox " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5038. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  5039. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":text,"timestamp":Date.now()+2000,"to":[-1]}]));
  5040. displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  5041. changeJukeboxURL(text,Date.now()+2000);
  5042. return "";
  5043. }
  5044. else if (chat_val.substring(1,13)=="pausejukebox"){
  5045. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  5046. displayInChat("Jukebox is now paused.","#DA0808","#1EBCC1");
  5047. jukeboxplayer.pause();
  5048. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":"","timestamp":Date.now(),"to":[-1]}]));
  5049. }
  5050. return "";
  5051. }
  5052. else if (chat_val.substring(1,13)=="resetjukebox"){
  5053. if(jukeboxplayer.src!=""){
  5054. jukeboxplayer.currentTime = 0;
  5055. displayInChat("Jukebox has reset.","#DA0808","#1EBCC1");
  5056. changeJukeboxURL(jukeboxplayerURL,Date.now()+2000);
  5057. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()+2000,"to":[-1]}]));
  5058. }
  5059. return "";
  5060. }
  5061. else if (chat_val.substring(1,12)=="playjukebox"){
  5062. if(jukeboxplayer.src!="" && jukeboxplayer.paused){
  5063. changeJukeboxURL(jukeboxplayerURL,Date.now()-jukeboxplayer.currentTime*1000);
  5064. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[-1]}]));
  5065. }
  5066. return "";
  5067. }
  5068. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  5069. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  5070. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+".","#DA0808","#1EBCC1");
  5071. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + "'";
  5072. }
  5073. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  5074. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5075. var keys = Object.keys(playerids);
  5076. var killid = undefined;
  5077. for(var i = 0; i<keys.length; i++){
  5078. if(playerids[keys[i]].userName == text){
  5079. killid = keys[i];
  5080. }
  5081. }
  5082. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  5083. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  5084. killedids.push(killid);
  5085. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  5086. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  5087. }
  5088. return "";
  5089. }
  5090. else if (chat_val.substring(1,6)=="killA"){
  5091. var keys = Object.keys(playerids);
  5092. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5093. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  5094. SEND('42[25,{"a":{"playersLeft":['+keys.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  5095. RECIEVE('42[31,{"a":{"playersLeft":['+keys.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  5096. }
  5097. return "";
  5098. }
  5099. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5100. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5101. if(!isNaN(parseInt(text))){
  5102. if(parseInt(text)>=-100 && parseInt(text)<=100){
  5103. var keys = Object.keys(playerids);
  5104. for(var i = 0; i<keys.length;i++){
  5105. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  5106. RECIEVE('42[36,'+keys[i]+','+text+']');
  5107. }
  5108. }
  5109. }
  5110. return "";
  5111. }
  5112. else if (chat_val.substring(1, 10) == "brighten " && chat_val.replace(/^\s+|\s+$/g, '').length >= 11) {
  5113. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5114. if (!isNaN(parseFloat(text))) {
  5115. var intText = parseFloat(text);
  5116. var f = function(x){
  5117. return x * intText;
  5118. };
  5119. loadMap(changeColor(currentmap[currentmap.length-1], f,f,f));
  5120. }
  5121. return "";
  5122. }
  5123. else if (chat_val.substring(1, 12) == "colorshift " && chat_val.replace(/^\s+|\s+$/g, '').length >= 13) {
  5124. var text = chat_val.substring(12).replace(/^\s+|\s+$/g, '');
  5125. if (!isNaN(parseFloat(text))) {
  5126. var intText = parseFloat(text);
  5127. var seed = [Math.random()-0.5, Math.random()-0.5, Math.random()-0.5, Math.random()-0.5];
  5128. var f = function(x, ind){
  5129. return x * 1 + seed[ind] * intText;
  5130. };
  5131. loadMap(changeColor(currentmap[currentmap.length-1], f,f,f));
  5132. }
  5133. return "";
  5134. }
  5135. else if (chat_val.substring(1,10)=="balanceT " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5136. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5137. var text2 = text.split(" ").filter(function(e){if(e!=""){return true;}return false;});
  5138. if(text2.length!=2 || isNaN(parseInt(text2[1])) || !["s","r","b","y","g","f"].includes(text2[0])){
  5139. displayInChat("Please enter a team letter and a number to balance.","#DA0808","#1EBCC1");
  5140. return "";
  5141. }
  5142. var teamdict = {"s":0,"f":1,"r":2,"b":3,"g":4,"y":5};
  5143. if(parseInt(text2[1])>=-100 && parseInt(text2[1])<=100){
  5144. var keys = Object.keys(playerids);
  5145. for(var i = 0; i<keys.length;i++){
  5146. if(playerids[keys[i]].team == teamdict[text2[0]]){
  5147. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text2[1]+'}]');
  5148. RECIEVE('42[36,'+keys[i]+','+text2[1]+']');
  5149. }
  5150. }
  5151. }
  5152. return "";
  5153. }
  5154. else if (chat_val.substring(1,10)=="resetpoll"){
  5155. poll = [];
  5156. displayInChat("The poll has been reset.","#DA0808","#1EBCC1");
  5157. return "";
  5158. }
  5159. else if (chat_val.substring(1,11)=="addoption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5160. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5161. if(text.length>50){
  5162. displayInChat("Your option is greater than 50 characters.","#DA0808","#1EBCC1");
  5163. return "";
  5164. }
  5165. if(poll.includes(text)){
  5166. displayInChat("This option already exists.","#DA0808","#1EBCC1");
  5167. }
  5168. else if(poll.length>=4){
  5169. displayInChat("Your poll already has the max 4 amounts of options.","#DA0808","#1EBCC1");
  5170. displayInChat("Type '/deloption [letter]' to remove a option.","#DA0808","#1EBCC1");
  5171. displayInChat("The poll is:","#DA0808","#1EBCC1");
  5172. for(var i = 0;i<poll.length;i++){
  5173. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5174. }
  5175. }
  5176. else{
  5177. poll.push(text);
  5178. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  5179. for(var i = 0;i<poll.length;i++){
  5180. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5181. }
  5182. }
  5183. return "";
  5184. }
  5185. else if (chat_val.substring(1,11)=="deloption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5186. var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  5187. if(text==-1 || text>=poll.length){
  5188. if(poll.length>0){
  5189. displayInChat("Available options are:","#DA0808","#1EBCC1");
  5190. for(var i = 0;i<poll.length;i++){
  5191. displayInChat(letters[i],"#DA0808","#1EBCC1");
  5192. }
  5193. }
  5194. else{
  5195. displayInChat("Your poll is empty.","#DA0808","#1EBCC1");
  5196. displayInChat("Type '/addoption [text]' to add an option.","#DA0808","#1EBCC1");
  5197. }
  5198. }
  5199. else{
  5200. poll.splice(text,1);
  5201. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  5202. for(var i = 0;i<poll.length;i++){
  5203. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5204. }
  5205. }
  5206. return "";
  5207. }
  5208. else if (chat_val.substring(1,11)=="startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5209. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  5210. if(isNaN(text)){
  5211. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5212. return "";
  5213. }
  5214. else if(text<=0){
  5215. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5216. return "";
  5217. }
  5218. else if(text<10){
  5219. displayInChat("Your poll has to last for at least 10 seconds.","#DA0808","#1EBCC1");
  5220. return "";
  5221. }
  5222. if(pollactive[0]){
  5223. displayInChat("There is already an ongoing poll.","#DA0808","#1EBCC1");
  5224. displayInChat("Type '/endpoll' to end the poll.","#DA0808","#1EBCC1");
  5225. return "";
  5226. }
  5227. if(poll.length<2){
  5228. displayInChat("Your poll needs at least 2 options.","#DA0808","#1EBCC1");
  5229. displayInChat("Type '/addoption' to add to the poll.","#DA0808","#1EBCC1");
  5230. return "";
  5231. }
  5232. var now = Date.now();
  5233. pollactive = [true,now,now+text*1000,[...poll]];
  5234. playerids[myid].ratelimit.poll = now;
  5235. var chatpoll = [...poll];
  5236. chatpoll.push("Cancel vote.");
  5237. pollactive[3].push("Cancel vote.");
  5238. for(var i = 0;i<chatpoll.length;i++){
  5239. chatpoll[i] = letters[i]+") "+chatpoll[i];
  5240. }
  5241. chat(chatpoll.join("     "));
  5242. setTimeout(function(){
  5243. if(pollactive[0]){
  5244. SEND("42"+JSON.stringify([4,{"type":"poll","from":username,"poll":pollactive[3]}]));
  5245. var keys = Object.keys(playerids);
  5246. for(var i = 0;i<keys.length;i++){
  5247. playerids[keys[i]].vote.poll = -1;
  5248. }
  5249. displayInChat("The poll will end in: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5250. displayInChat("Type '/endpoll' to end the poll early.","#DA0808","#1EBCC1");
  5251. }
  5252. },200);
  5253. return "";
  5254. }
  5255. else if (chat_val.substring(1,8)=="endpoll"){
  5256. if(pollactive[0]){
  5257. if(playerids[myid].ratelimit.poll+10000>Date.now()){
  5258. displayInChat("Your poll has to be at least 10 seconds.","#DA0808","#1EBCC1");
  5259. displayInChat("There are "+((playerids[myid].ratelimit.poll+10000-Date.now())/1000).toString()+" seconds left until you can end the poll early.","#DA0808","#1EBCC1");
  5260. return "";
  5261. }
  5262. playerids[myid].ratelimit.poll = Date.now();
  5263. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  5264. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  5265. var count = [0,0,0,0];
  5266. var keys = Object.keys(playerids);
  5267. for(var i = 0;i<keys.length;i++){
  5268. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  5269. count[playerids[keys[i]].vote.poll]++;
  5270. }
  5271. playerids[keys[i]].vote.poll = -1;
  5272. }
  5273. for(var i = 0;i<count.length;i++){
  5274. if(count[i]>1){
  5275. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5276. }
  5277. if(count[i]==1){
  5278. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5279. }
  5280. }
  5281. displayInChat("The poll was:","#DA0808","#1EBCC1");
  5282. for(var i = 0;i<pollactive[3].length;i++){
  5283. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  5284. }
  5285. pollactive = [false,0,0,[]];
  5286. }
  5287. else{
  5288. displayInChat("No poll has been started","#DA0808","#1EBCC1");
  5289. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  5290. }
  5291. return "";
  5292. }
  5293. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5294. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  5295. var keys = Object.keys(playerids);
  5296. var t = -1;
  5297. if(text == "f"){
  5298. t = 1;
  5299. }
  5300. else if(text == "b"){
  5301. t = 3;
  5302. }
  5303. else if(text == "g"){
  5304. t = 4;
  5305. }
  5306. else if(text == "r"){
  5307. t = 2;
  5308. }
  5309. else if(text == "y"){
  5310. t = 5;
  5311. }
  5312. else if(text == "s"){
  5313. t = 0;
  5314. }
  5315. if(t == -1){
  5316. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5317. displayInChat("/moveA [letter]","#DA0808","#1EBCC1");
  5318. displayInChat("For example: '/moveA r' would move everyone to red team.","#DA0808","#1EBCC1");
  5319. return "";
  5320. }
  5321. for(var i = 0;i<keys.length;i++){
  5322. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+t.toString()+'}]');
  5323. if(playerids[keys[i]].peerID!="sandbox"){
  5324. RECIEVE('42[18,'+keys[i].toString()+','+t.toString()+']');
  5325. }
  5326. }
  5327. return "";
  5328. }
  5329. else if (chat_val.substring(1,7)=="moveT " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5330. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').split(" ").filter(function(i){if(i==""){return false}else{return true}});
  5331. if(text.length == 2){
  5332. var firstteam = -1;
  5333. var secondteam = -1;
  5334. for(var i = 0;i<2;i++){
  5335. var t = -1;
  5336. if(text[i] == "f"){
  5337. t = 1;
  5338. }
  5339. else if(text[i] == "b"){
  5340. t = 3;
  5341. }
  5342. else if(text[i] == "g"){
  5343. t = 4;
  5344. }
  5345. else if(text[i] == "r"){
  5346. t = 2;
  5347. }
  5348. else if(text[i] == "y"){
  5349. t = 5;
  5350. }
  5351. else if(text[i] == "s"){
  5352. t = 0;
  5353. }
  5354. if(t==-1){
  5355. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5356. displayInChat("/moveT [letter] [letter]","#DA0808","#1EBCC1");
  5357. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5358. return "";
  5359. }
  5360. else{
  5361. if(i == 0){
  5362. firstteam = t;
  5363. }
  5364. else{
  5365. secondteam = t;
  5366. }
  5367. }
  5368. }
  5369. var keys = Object.keys(playerids);
  5370. for(var i = 0;i<keys.length;i++){
  5371. if(playerids[keys[i]].team == firstteam){
  5372. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+secondteam.toString()+'}]');
  5373. if(playerids[keys[i]].peerID!="sandbox"){
  5374. RECIEVE('42[18,'+keys[i].toString()+','+secondteam.toString()+']');
  5375. }
  5376. }
  5377. }
  5378. }
  5379. else{
  5380. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5381. displayInChat("/moveT [team] [team]","#DA0808","#1EBCC1");
  5382. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5383. return "";
  5384. }
  5385. return "";
  5386. }
  5387. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5388. var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  5389. if(isNaN(text)){
  5390. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5391. return "";
  5392. }
  5393. else if(text<=0){
  5394. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5395. return "";
  5396. }
  5397. roundsperqp = text;
  5398. roundsperqp2 = 0;
  5399. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  5400. displayInChat("Type '/roundsperqp' to reset rounds per quickplay.","#DA0808","#1EBCC1");
  5401. return "";
  5402. }
  5403. else if (chat_val.substring(1,12)=="roundsperqp"){
  5404. roundsperqp = 1;
  5405. roundsperqp2 = 0;
  5406. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  5407. return "";
  5408. }
  5409. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  5410. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  5411. if(!isNaN(parseInt(text))){
  5412. text = parseInt(text).toString();
  5413. SEND('42[21,{"w":'+text+'}]');
  5414. RECIEVE('42[27,'+text+']');
  5415. }
  5416. return "";
  5417. }
  5418. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5419. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5420. var keys = text.split(" ");
  5421. var disabledkeys2 = [];
  5422. var possiblekeys = ["left","right","up","down","heavy","special"];
  5423. for(var i = 0; i<keys.length; i++){
  5424. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  5425. if(possiblekeys.includes(keys[i])){
  5426. disabledkeys2.push(keys[i]);
  5427. }
  5428. else{
  5429. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  5430. return "";
  5431. }
  5432. }
  5433. }
  5434. disabledkeys = disabledkeys2;
  5435. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  5436. displayInChat("Type '/disablekeys' to reset disabled keys.","#DA0808","#1EBCC1");
  5437. return "";
  5438. }
  5439. else if (chat_val.substring(1,12)=="disablekeys"){
  5440. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  5441. disabledkeys = [];
  5442. return "";
  5443. }
  5444. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5445. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5446. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  5447. displayInChat("Type '/jointext' to reset jointext.","#DA0808","#1EBCC1");
  5448. return "";
  5449. }
  5450. else if (chat_val.substring(1,9)=="jointext"){
  5451. jointext = "";
  5452. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  5453. return "";
  5454. }
  5455. else if (chat_val.substring(1,10)=="jointeam " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5456. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5457. var keys = Object.keys(playerids);
  5458. var t = -1;
  5459. if(text == "f"){
  5460. t = 1;
  5461. displayInChat("Set jointeam to FFA.","#DA0808","#1EBCC1");
  5462. }
  5463. else if(text == "b"){
  5464. t = 3;
  5465. displayInChat("Set jointeam to blue team.","#DA0808","#1EBCC1");
  5466. }
  5467. else if(text == "g"){
  5468. t = 4;
  5469. displayInChat("Set jointeam to green team.","#DA0808","#1EBCC1");
  5470. }
  5471. else if(text == "r"){
  5472. t = 2;
  5473. displayInChat("Set jointeam to red team.","#DA0808","#1EBCC1");
  5474. }
  5475. else if(text == "y"){
  5476. t = 5;
  5477. displayInChat("Set jointeam to yellow team.","#DA0808","#1EBCC1");
  5478. }
  5479. else if(text == "s"){
  5480. t = 0;
  5481. displayInChat("Set jointeam to spectate.","#DA0808","#1EBCC1");
  5482. }
  5483. if(t == -1){
  5484. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5485. displayInChat("/jointeam [letter]","#DA0808","#1EBCC1");
  5486. displayInChat("For example: '/jointeam r' would move every joined person to red team.","#DA0808","#1EBCC1");
  5487. return "";
  5488. }
  5489. displayInChat("Type '/jointeam' to reset jointeam.","#DA0808","#1EBCC1");
  5490. jointeam = t;
  5491. return "";
  5492. }
  5493. else if (chat_val.substring(1,9)=="jointeam"){
  5494. jointeam = -1;
  5495. displayInChat("Reset jointeam.","#DA0808","#1EBCC1");
  5496. return "";
  5497. }
  5498. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5499. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  5500. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  5501. displayInChat("Type '/wintext' to reset wintext.","#DA0808","#1EBCC1");
  5502. return "";
  5503. }
  5504. else if (chat_val.substring(1,8)=="wintext"){
  5505. wintext = "";
  5506. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  5507. return "";
  5508. }
  5509. else if (chat_val.substring(1,11)=="autorecord"){
  5510. if(autorecord){
  5511. autorecord = false;
  5512. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  5513. }
  5514. else{
  5515. autorecord = true;
  5516. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  5517. }
  5518. return "";
  5519. }
  5520. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5521. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  5522. if(!isNaN(text)){
  5523. if(text>0){
  5524. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5525. displayInChat("Type '/afkkill' to reset afk kill.","#DA0808","#1EBCC1");
  5526. var keys = Object.keys(playerids);
  5527. var now = Date.now();
  5528. for(var i = 0;i<keys.length;i++){
  5529. playerids[keys[i]].lastmove = now;
  5530. }
  5531. afkkill = text;
  5532. }
  5533. else{
  5534. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5535. }
  5536. }
  5537. else{
  5538. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5539. }
  5540. return "";
  5541. }
  5542. else if (chat_val.substring(1,9)=="afkkill"){
  5543. afkkill = -1;
  5544. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  5545. return "";
  5546. }
  5547. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5548. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5549. if(text == "default"){
  5550. defaultmode = "";
  5551. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  5552. }
  5553. else if(text == "arrows"){
  5554. defaultmode = "ar";
  5555. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  5556. }
  5557. else if(text == "death arrows"){
  5558. defaultmode = "ard";
  5559. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  5560. }
  5561. else if(text == "grapple"){
  5562. defaultmode = "sp";
  5563. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  5564. }
  5565. else if(text == "classic"){
  5566. defaultmode = "b";
  5567. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  5568. }
  5569. else{
  5570. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  5571. displayInChat("default","#DA0808","#1EBCC1");
  5572. displayInChat("classic","#DA0808","#1EBCC1");
  5573. displayInChat("arrows","#DA0808","#1EBCC1");
  5574. displayInChat("death arrows","#DA0808","#1EBCC1");
  5575. displayInChat("grapple","#DA0808","#1EBCC1");
  5576. }
  5577. return "";
  5578. }
  5579. else if (chat_val.substring(1,8)=="recmode"){
  5580. if(recmodebool == true){
  5581. recmodebool = false;
  5582. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  5583. }
  5584. else{
  5585. recmodebool = true;
  5586. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  5587. }
  5588. return "";
  5589. }
  5590. else if (chat_val.substring(1,8)=="recteam"){
  5591. if(recteams == true){
  5592. recteams = false;
  5593. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  5594. }
  5595. else{
  5596. recteams = true;
  5597. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  5598. }
  5599. return "";
  5600. }
  5601. else if (chat_val.substring(1,8)=="shuffle"){
  5602. if(shuffle == true){
  5603. shuffle = false;
  5604. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  5605. }
  5606. else{
  5607. shuffle = true;
  5608. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  5609. }
  5610. return "";
  5611. }
  5612. else if (chat_val.substring(1,9)=="autokick"){
  5613. if(autokickban == 0){
  5614. displayInChat("Autokick is now on.","#DA0808","#1EBCC1");
  5615. autokickban = 1;
  5616. }
  5617. else if(autokickban == 1){
  5618. autokickban = 0;
  5619. displayInChat("Autokick is now off.","#DA0808","#1EBCC1");
  5620. }
  5621. else{
  5622. autokickban = 1;
  5623. displayInChat("Autokick is now on, and Autoban is now off.","#DA0808","#1EBCC1");
  5624. }
  5625. return "";
  5626. }
  5627. else if (chat_val.substring(1,8)=="autoban"){
  5628. if(autokickban == 0){
  5629. displayInChat("Autoban is now on.","#DA0808","#1EBCC1");
  5630. autokickban = 2;
  5631. }
  5632. else if(autokickban == 2){
  5633. autokickban = 0;
  5634. displayInChat("Autoban is now off.","#DA0808","#1EBCC1");
  5635. }
  5636. else{
  5637. autokickban = 2;
  5638. displayInChat("Autoban is now on, and Autokick is now off.","#DA0808","#1EBCC1");
  5639. }
  5640. return "";
  5641. }
  5642. else if (chat_val.substring(1,8)=="sandbox"){
  5643. if(sandboxon == false){
  5644. displayInChat("This room is now a sandbox room.","#DA0808","#1EBCC1");
  5645. sandboxon = true;
  5646. SEND('42[4,{"type":"sandboxon"}]');
  5647. var sandboxkeys = Object.keys(sandboxplayerids);
  5648. var packets = [];
  5649. for(var i = 0;i<sandboxkeys.length;i++){
  5650. var p = playerids[sandboxkeys[i]];
  5651. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  5652. packets.push(packet);
  5653. }
  5654. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5655. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[-1]}]));
  5656. }
  5657. else{
  5658. displayInChat("You cannot turn a sandbox room back into a normal room.","#DA0808","#1EBCC1");
  5659. }
  5660. return "";
  5661. }
  5662. else if(sandboxon){
  5663. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5664. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5665. if(!isNaN(parseInt(text))){
  5666. var text2 = parseInt(text);
  5667. if(text2>0){
  5668. for(var i = 0;i<text2;i++){
  5669. while(playerids[sandboxid]){
  5670. sandboxid+=1;
  5671. }
  5672. var color = Math.floor(Math.random() * 16777215).toString();
  5673. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",sandboxid.toString(),true,0,0,{"layers":[],"bc":color}]);
  5674. RECIEVE(packet);
  5675. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5676. sandboxplayerids[sandboxid] = sandboxid.toString();
  5677. sandboxid+=1;
  5678. }
  5679. }
  5680. }
  5681. return "";
  5682. }
  5683. if (chat_val.substring(1,9)=="addname " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5684. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5685. while(playerids[sandboxid]){
  5686. sandboxid+=1;
  5687. }
  5688. var keys = Object.keys(playerids);
  5689. var addon = "";
  5690. var escape = false;
  5691. var keysi = -1;
  5692. while(!escape){
  5693. escape = true;
  5694. for(var i = 0;i<keys.length;i++){
  5695. if(playerids[keys[i]].userName == text+addon){
  5696. addon+="‎";
  5697. var escape = false;
  5698. }
  5699. if(playerids[keys[i]].userName == text){
  5700. keysi = keys[i];
  5701. }
  5702. }
  5703. }
  5704. if(keysi!=-1){
  5705. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,playerids[keysi].guest,playerids[keysi].level,0,playerids[keysi].avatar]);
  5706. RECIEVE(packet);
  5707. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5708. }
  5709. else{
  5710. var color = Math.floor(Math.random() * 16777215).toString();
  5711. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,true,0,0,{"layers":[],"bc":color}]);
  5712. RECIEVE(packet);
  5713. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5714. }
  5715. sandboxplayerids[sandboxid] = sandboxid.toString();
  5716. sandboxid+=1;
  5717. return "";
  5718. }
  5719. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5720. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5721. if(!isNaN(parseInt(text))){
  5722. var text2 = parseInt(text);
  5723. if(text2>0){
  5724. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  5725. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  5726. var packets = [];
  5727. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  5728. var packet = '42[5,'+jsonkeys[i]+',0]';
  5729. RECIEVE(packet);
  5730. packets.push(packet);
  5731. delete sandboxplayerids[jsonkeys[i]];
  5732. }
  5733. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5734. }
  5735. else{
  5736. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  5737. }
  5738. }
  5739. }
  5740. return "";
  5741. }
  5742. else if (chat_val.substring(1,6)=="copy " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  5743. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5744. var keys = Object.keys(playerids);
  5745. var keys2 = Object.keys(sandboxplayerids);
  5746. var copiedperson = -1;
  5747. for(var i = 0;i<keys.length;i++){
  5748. if(playerids[keys[i]].userName==text){
  5749. copiedperson = keys[i];
  5750. }
  5751. }
  5752. if(copiedperson==-1){
  5753. displayInChat(playerids[copiedperson].userName + " was not found in this room.","#DA0808","#1EBCC1");
  5754. return "";
  5755. }
  5756. if(keys2.includes(copiedperson.toString())){
  5757. displayInChat("Bots cannot copy a bot.","#DA0808","#1EBCC1");
  5758. return "";
  5759. }
  5760. displayInChat("All bots will now copy "+playerids[copiedperson].userName+".","#DA0808","#1EBCC1");
  5761. displayInChat("To reset copy, type '/copy'.","#DA0808","#1EBCC1");
  5762. sandboxcopyme = copiedperson;
  5763. return "";
  5764. }
  5765. else if (chat_val.substring(1,5)=="copy"){
  5766. sandboxcopyme = -1;
  5767. displayInChat("Copy is now off.","#DA0808","#1EBCC1");
  5768. return "";
  5769. }
  5770. }
  5771. }
  5772. return chat_val;
  5773. };
  5774. scope.flag_manage = function(t){
  5775. var text = t;
  5776. if(autocorrect == true){
  5777. var text2 = text.split(" ");
  5778. for(var i = 0;i<text2.length;i++){
  5779. text2[i] = closestWord(text2[i]);
  5780. }
  5781. text = text2.join(" ");
  5782. }
  5783. if(reverse_flag == true){
  5784. text = text.split("").reverse().join("")
  5785. }
  5786. if(rcaps_flag == true){
  5787. text = text.split('');
  5788. for(var i = 0; i<text.length;i++){
  5789. if(Math.floor(Math.random()*2)){
  5790. text[i] = text[i].toUpperCase();
  5791. }
  5792. else{
  5793. text[i] = text[i].toLowerCase();
  5794. }
  5795. }
  5796. text = text.join('');
  5797. }
  5798. if(space_flag == true){
  5799. text = text.split('').join(' ')
  5800. }
  5801. if(textmode!=-1){
  5802. newtext = "";
  5803. for(var i = 0;i<text.length;i++){
  5804. if(letter_dictionary[text[i]]){
  5805. newtext+=letter_dictionary[text[i]][textmode];
  5806. }
  5807. else{
  5808. newtext+=text[i];
  5809. }
  5810. }
  5811. text = newtext;
  5812. }
  5813. if(number_flag == true){
  5814. text = text.replace(/[t|T][Oo]+/g,"2");
  5815. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  5816. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  5817. text = text.replace(/[e|E]/g,"3");
  5818. text = text.replace(/[a|A]/g,"4");
  5819. text = text.replace(/[o|O]/g,"0");
  5820. text = text.replace(/[s|S]/g,"5");
  5821. text = text.replace(/[i|I|l|L]/g,"1");
  5822. }
  5823. return text;
  5824. };
  5825. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  5826. if(e.keyCode==13){
  5827. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  5828. if (chat_val!="" && chat_val[0]=="/"){
  5829. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5830. chat2(commandhandle(chat_val));
  5831. }
  5832. else{
  5833. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5834. chat2(flag_manage(chat_val));
  5835. }
  5836. }
  5837. };
  5838. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  5839. if(e.keyCode==13){
  5840. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  5841. if (chat_val!="" && chat_val[0]=="/"){
  5842. Gdocument.getElementById("ingamechatinputtext").value = "";
  5843. chat2(commandhandle(chat_val));
  5844. }
  5845. else{
  5846. Gdocument.getElementById("ingamechatinputtext").value = "";
  5847. chat2(flag_manage(chat_val));
  5848. }
  5849. }
  5850. };
  5851. scope.Last_message = "";
  5852. scope.Laster_message = "";
  5853. scope.new_message = false;
  5854. scope.changed_chat = false;
  5855. scope.injectedBonkCommandsScript = setInterval(timeout123,60);
  5856.  
  5857. scope.pan_enabled = false;
  5858. scope.pan = {"x":0,"y":0};
  5859. scope.pan_speed = 5;
  5860. scope.keys_being_held = {};
  5861. scope.hotkeys_keyup = function(e){
  5862. if(keys_being_held[e.code]){
  5863. keys_being_held[e.code] = false;
  5864. }
  5865. };
  5866. Gdocument.onkeyup = hotkeys_keyup;
  5867. scope.hotkeys = function(e){
  5868. var keycode = e.code;
  5869. if(!keys_being_held[keycode]){
  5870. keys_being_held[keycode] = true;
  5871. }
  5872. if(!e.altKey && e.shiftKey && !e.ctrlKey && !e.metaKey){
  5873. if(pan_enabled && Gdocument.getElementById("gamerenderer")?.childElementCount>0){
  5874. if(keycode == "ArrowUp"){
  5875. e.stopPropagation();
  5876. e.preventDefault();
  5877. }
  5878. else if(keycode == "ArrowDown"){
  5879. e.stopPropagation();
  5880. e.preventDefault();
  5881. }
  5882. else if(keycode == "ArrowLeft"){
  5883. e.stopPropagation();
  5884. e.preventDefault();
  5885. }
  5886. else if(keycode == "ArrowRight"){
  5887. e.stopPropagation();
  5888. e.preventDefault();
  5889. }
  5890. }
  5891. }
  5892.  
  5893. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5894. if(keycode == "Period"){
  5895. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5896. chatheight+=5;
  5897. if(chatheight>600){chatheight = 600;}
  5898. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5899. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5900. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5901. }
  5902. e.preventDefault();
  5903. }
  5904. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5905. if(keycode == "KeyG"){
  5906. var addto = 0;
  5907. for(var i = 0;i<parentDraw.children.length;i++){
  5908. if(parentDraw.children[i].constructor.name == "e"){
  5909. addto = parentDraw.children[i];
  5910. break;
  5911. }
  5912. }
  5913. var canv = 0;
  5914. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5915. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5916. canv = Gdocument.getElementById("gamerenderer").children[i];
  5917. break;
  5918. }
  5919. }
  5920. var width = parseInt(canv.style["width"]);
  5921. var height = parseInt(canv.style["height"]);
  5922. if(addto){
  5923. zoom *= 1.1;
  5924. }
  5925. addto.scale.x = zoom;
  5926. addto.scale.y = zoom;
  5927. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5928. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5929. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5930. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5931. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5932. pixiCircle.visible = false;
  5933. }
  5934. else{
  5935. pixiCircle.visible = true;
  5936. }
  5937. e.preventDefault();
  5938. }
  5939. if(keycode == "KeyH"){
  5940. var addto = 0;
  5941. for(var i = 0;i<parentDraw.children.length;i++){
  5942. if(parentDraw.children[i].constructor.name == "e"){
  5943. addto = parentDraw.children[i];
  5944. break;
  5945. }
  5946. }
  5947. var canv = 0;
  5948. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5949. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5950. canv = Gdocument.getElementById("gamerenderer").children[i];
  5951. break;
  5952. }
  5953. }
  5954. var width = parseInt(canv.style["width"]);
  5955. var height = parseInt(canv.style["height"]);
  5956. if(addto){
  5957. zoom = 1;
  5958. }
  5959. addto.scale.x = zoom;
  5960. addto.scale.y = zoom;
  5961. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5962. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5963. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5964. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5965. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5966. pixiCircle.visible = false;
  5967. }
  5968. else{
  5969. pixiCircle.visible = true;
  5970. }
  5971. e.preventDefault();
  5972. }
  5973. if(keycode == "KeyJ"){
  5974. var addto = 0;
  5975. for(var i = 0;i<parentDraw.children.length;i++){
  5976. if(parentDraw.children[i].constructor.name == "e"){
  5977. addto = parentDraw.children[i];
  5978. break;
  5979. }
  5980. }
  5981. var canv = 0;
  5982. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5983. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5984. canv = Gdocument.getElementById("gamerenderer").children[i];
  5985. break;
  5986. }
  5987. }
  5988. var width = parseInt(canv.style["width"]);
  5989. var height = parseInt(canv.style["height"]);
  5990. if(addto){
  5991. zoom /= 1.1;
  5992. }
  5993. addto.scale.x = zoom;
  5994. addto.scale.y = zoom;
  5995. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5996. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5997. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5998. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5999. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  6000. pixiCircle.visible = false;
  6001. }
  6002. else{
  6003. pixiCircle.visible = true;
  6004. }
  6005. e.preventDefault();
  6006. }
  6007. }
  6008. if(keycode == "Comma"){
  6009. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  6010. chatheight-=5;
  6011. if(chatheight<100){chatheight = 100;}
  6012. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6013. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  6014. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  6015. }
  6016. e.preventDefault();
  6017. }
  6018. }
  6019. if(e.repeat){return;}
  6020. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  6021. if(ishost){
  6022. if(keycode == "KeyE"){
  6023. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  6024. Gdocument.getElementById("newbonklobby_editorbutton").click();
  6025. }
  6026. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  6027. Gdocument.getElementById("mapeditor_close").click();
  6028. }
  6029. e.preventDefault();
  6030. }
  6031. else if(keycode == "KeyT"){
  6032. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  6033. e.preventDefault();
  6034. }
  6035. else if(keycode == "KeyM"){
  6036. Gdocument.getElementById("newbonklobby_modebutton").click();
  6037. e.preventDefault();
  6038. }
  6039. else if(keycode == "KeyK"){
  6040. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6041. Gdocument.getElementById("pretty_top_exit").click();
  6042. }
  6043. e.preventDefault();
  6044. }
  6045. else if(keycode == "KeyS"){
  6046. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  6047. Gdocument.getElementById("newbonklobby_editorbutton").click();
  6048. }
  6049. if(recmodebool && ishost){
  6050. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  6051. if(mode == "" && defaultmode!="d"){
  6052. mode = defaultmode;
  6053. }
  6054. if(mode != ""){
  6055. RECIEVE('42[26,"b","'+mode+'"]');
  6056. }
  6057. }
  6058. Gdocument.getElementById("mapeditor_close").click();
  6059. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  6060. roundsperqp2 = 0;
  6061. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  6062. e.preventDefault();
  6063. }
  6064. else if(keycode == "KeyD"){
  6065. roundsperqp2 = 0;
  6066. if(stopquickplay == 0){
  6067. if(shuffle){
  6068. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6069. var available = [];
  6070. var availableindexes = [];
  6071. var notempty = false;
  6072. for(var i = 0; i<e2.length;i++){
  6073. var a = false;
  6074. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6075. available.push(a);
  6076. if(a){
  6077. availableindexes.push(i);
  6078. notempty = true;
  6079. }
  6080. }
  6081. if(notempty){
  6082. if(availableindexes.length!=1){
  6083. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6084. }
  6085. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6086. }
  6087. }
  6088. else{
  6089. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6090. var available = [];
  6091. var availableindexes = [];
  6092. var notempty = false;
  6093. for(var i = 0; i<e2.length;i++){
  6094. var a = false;
  6095. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6096. available.push(a);
  6097. if(a){
  6098. availableindexes.push(i);
  6099. notempty = true;
  6100. }
  6101. }
  6102. if(notempty){
  6103. var above = [];
  6104. for(var i = 0;i<availableindexes.length;i++){
  6105. if(availableindexes[i]>quicki && !reverseqp){
  6106. above.push(availableindexes[i]);
  6107. }
  6108. else if(availableindexes[i]<quicki && reverseqp){
  6109. above.push(availableindexes[i])
  6110. }
  6111. }
  6112. if(above.length>0){
  6113. quicki = above[0];
  6114. if(reverseqp){
  6115. quicki = above[above.length-1];
  6116. }
  6117. }
  6118. else{
  6119. quicki = availableindexes[0];
  6120. if(reverseqp){
  6121. quicki = availableindexes[availableindexes.length-1];
  6122. }
  6123. }
  6124. }
  6125. }
  6126. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6127. }
  6128. e.preventDefault();
  6129. }
  6130. else if(keycode == "KeyA"){
  6131. if(stopquickplay == 0){
  6132. roundsperqp2 = 0;
  6133. if(shuffle){
  6134. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6135. var available = [];
  6136. var availableindexes = [];
  6137. var notempty = false;
  6138. for(var i = 0; i<e2.length;i++){
  6139. var a = false;
  6140. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6141. available.push(a);
  6142. if(a){
  6143. availableindexes.push(i);
  6144. notempty = true;
  6145. }
  6146. }
  6147. if(notempty){
  6148. if(availableindexes.length!=1){
  6149. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6150. }
  6151. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6152. }
  6153. }
  6154. else{
  6155. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6156. var available = [];
  6157. var availableindexes = [];
  6158. var notempty = false;
  6159. for(var i = 0; i<e2.length;i++){
  6160. var a = false;
  6161. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6162. available.push(a);
  6163. if(a){
  6164. availableindexes.push(i);
  6165. notempty = true;
  6166. }
  6167. }
  6168. if(notempty){
  6169. var above = [];
  6170. for(var i = 0;i<availableindexes.length;i++){
  6171. if(availableindexes[i]<quicki && !reverseqp){
  6172. above.push(availableindexes[i]);
  6173. }
  6174. else if(availableindexes[i]>quicki && reverseqp){
  6175. above.push(availableindexes[i])
  6176. }
  6177. }
  6178. if(above.length>0){
  6179. quicki = above[above.length-1];
  6180. if(reverseqp){
  6181. quicki = above[0];
  6182. }
  6183. }
  6184. else{
  6185. quicki = availableindexes[availableindexes.length-1];
  6186. if(reverseqp){
  6187. quicki = availableindexes[0];
  6188. }
  6189. }
  6190. }
  6191. }
  6192. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6193. }
  6194. e.preventDefault();
  6195. }
  6196. else if(keycode == "KeyQ"){
  6197. if(stopquickplay == 1){
  6198. stopquickplay = 0;
  6199. quicki = 0;
  6200. qppaused = false;
  6201. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  6202. }
  6203. else{
  6204. stopquickplay = 1;
  6205. quicki = 0;
  6206. qppaused = false;
  6207. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  6208. }
  6209. e.preventDefault();
  6210. }
  6211. else if(keycode == "KeyP" && stopquickplay==0){
  6212. if(qppaused == true){
  6213. qppaused = false;
  6214. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  6215. }
  6216. else{
  6217. qppaused = true;
  6218. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  6219. }
  6220. e.preventDefault();
  6221. }
  6222. else if(keycode == "KeyR"){
  6223. if(recmodebool == true){
  6224. recmodebool = false;
  6225. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  6226. }
  6227. else{
  6228. recmodebool = true;
  6229. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  6230. }
  6231. }
  6232. else if(keycode == "KeyF"){
  6233. if(freejoin == false){
  6234. freejoin = true;
  6235. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  6236. }
  6237. else{
  6238. freejoin = false;
  6239. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  6240. }
  6241. e.preventDefault();
  6242. }
  6243. }
  6244. else{
  6245. if(keycode == "KeyE"){
  6246. e.preventDefault();
  6247. }
  6248. else if(keycode == "KeyT"){
  6249. e.preventDefault();
  6250. }
  6251. else if(keycode == "KeyM"){
  6252. e.preventDefault();
  6253. }
  6254. else if(keycode == "KeyK"){
  6255. e.preventDefault();
  6256. }
  6257. else if(keycode == "KeyS"){
  6258. e.preventDefault();
  6259. }
  6260. else if(keycode == "KeyD"){
  6261. e.preventDefault();
  6262. }
  6263. else if(keycode == "KeyA"){
  6264. e.preventDefault();
  6265. }
  6266. else if(keycode == "KeyQ"){
  6267. e.preventDefault();
  6268. }
  6269. else if(keycode == "KeyP"){
  6270. e.preventDefault();
  6271. }
  6272. else if(keycode == "KeyF"){
  6273. e.preventDefault();
  6274. }
  6275. else if(keycode == "KeyR"){
  6276. e.preventDefault();
  6277. }
  6278. }
  6279. if(keycode == "KeyL"){
  6280. lobby();
  6281. e.preventDefault();
  6282. }
  6283. if(keycode == "KeyC"){
  6284. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6285. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  6286. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6287. }
  6288. else{
  6289. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  6290. }
  6291. }
  6292. e.preventDefault();
  6293. }
  6294. if(keycode == "KeyI"){
  6295. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  6296. debuggeropen = true;
  6297. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  6298. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  6299. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  6300. }
  6301. else{
  6302. debuggeropen = false;
  6303. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  6304. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  6305. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  6306. }
  6307. e.preventDefault();
  6308. }
  6309. if(keycode == "KeyB"){
  6310. var element = Gdocument.getElementById("ingamewinner_scores");
  6311. if(element.style["opacity"]<1){
  6312. element.style["opacity"] = 1;
  6313. element.style["visibility"] = "visible";
  6314. }
  6315. else{
  6316. element.style["opacity"] = 0;
  6317. element.style["visibility"] = "unset";
  6318. }
  6319. e.preventDefault();
  6320. }
  6321. if(keycode == "KeyY"){
  6322. Gdocument.getElementById("pretty_top_settings").click();
  6323. Gdocument.getElementById("settings_close").click();
  6324. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  6325. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  6326. return "";
  6327. }
  6328. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6329. var addto = {"children":[]};
  6330. for(var i = 0;i<parentDraw.children.length;i++){
  6331. if(parentDraw.children[i].constructor.name == "e"){
  6332. addto = parentDraw.children[i];
  6333. break;
  6334. }
  6335. }
  6336. var addto2 = {"children":[]};
  6337. for(var i = 0;i<addto.children.length;i++){
  6338. if(addto.children[i].constructor.name == "e"){
  6339. addto2 = addto.children[i];
  6340. break;
  6341. }
  6342. }
  6343. var checkxray = addto2.children[0];
  6344. var addto3 = addto2.children[0].children;
  6345. if(addto3.length==1){
  6346. checkxray = checkxray.children[0];
  6347. addto3 = addto3[0].children;
  6348. }
  6349. var xrayon = false;
  6350. if(checkxray.xrayon){
  6351. checkxray.xrayon = false;
  6352. xrayon = false;
  6353. }
  6354. else{
  6355. checkxray.xrayon = true;
  6356. xrayon = true;
  6357. }
  6358. if(xrayon){
  6359. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  6360. for(var i = 0;i<addto3.length;i++){
  6361. if(addto3[i].children.length>0){
  6362. var ids = [];
  6363. var ids2 = [];
  6364. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6365. addto3[i].children[i3].visible = false;
  6366. if(addto3[i].children[i3].children.length>0){
  6367. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  6368. if(addto3[i].children[i3].children[i4].geometry?.id){
  6369. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  6370. }
  6371. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  6372. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  6373. }
  6374. }
  6375. }
  6376. }
  6377. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6378. if(addto3[i].children[i3].children.length==0){
  6379. if(addto3[i].children[i3].geometry?.id){
  6380. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  6381. addto3[i].children[i3].visible = true;
  6382. addto3[i].children[i3].alpha = 0.5;
  6383. }
  6384. }
  6385. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  6386. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  6387. addto3[i].children[i3].visible = true;
  6388. addto3[i].children[i3].alpha = 0.5;
  6389. }
  6390. }
  6391. }
  6392. }
  6393. }
  6394. }
  6395. }
  6396. else{
  6397. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  6398. for(var i = 0;i<addto3.length;i++){
  6399. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  6400. addto3[i].children[i2].visible = true;
  6401. addto3[i].children[i2].alpha = 1;
  6402. }
  6403. }
  6404. }
  6405. }
  6406. e.preventDefault();
  6407. }
  6408. if(keycode == "KeyN"){
  6409. if(FollowCam == true){
  6410. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  6411. FollowCam = false;
  6412. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6413. var addto = {"children":[]};
  6414. for(var i = 0;i<parentDraw.children.length;i++){
  6415. if(parentDraw.children[i].constructor.name == "e"){
  6416. addto = parentDraw.children[i];
  6417. break;
  6418. }
  6419. }
  6420. var canv = 0;
  6421. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  6422. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  6423. canv = Gdocument.getElementById("gamerenderer").children[i];
  6424. break;
  6425. }
  6426. }
  6427. var width = parseInt(canv.style["width"]);
  6428. var height = parseInt(canv.style["height"]);
  6429. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  6430. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  6431. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  6432. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  6433. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  6434. pixiCircle.visible = false;
  6435. }
  6436. else{
  6437. pixiCircle.visible = true;
  6438. }
  6439. }
  6440. }
  6441. else{
  6442. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  6443. FollowCam = true;
  6444. }
  6445. e.preventDefault();
  6446. }
  6447. if(keycode == "KeyV"){
  6448. if(autocam == true){
  6449. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  6450. autocam = false
  6451. }
  6452. else{
  6453. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  6454. autocam = true;
  6455. }
  6456. e.preventDefault();
  6457. }
  6458. if (keycode == "BracketLeft"){
  6459. if(pan_enabled == true){
  6460. displayInChat("Pan is now off.","#DA0808","#1EBCC1");
  6461. pan = {"x":0,"y":0};
  6462. pan_enabled = false;
  6463. }
  6464. else{
  6465. displayInChat("Pan is now on. Shift + Arrow Keys to pan.","#DA0808","#1EBCC1");
  6466. pan_enabled = true;
  6467. }
  6468. return "";
  6469. }
  6470. if (keycode == "BracketRight"){
  6471. pan = {"x":0,"y":0};
  6472. displayInChat("Reset pan.","#DA0808","#1EBCC1");
  6473. return "";
  6474. }
  6475. if(keycode == "KeyO"){
  6476. if(heavybot == true){
  6477. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  6478. heavybot = false;
  6479. }
  6480. else{
  6481. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  6482. heavybot = true;
  6483. getplayerkeys();
  6484. }
  6485. e.preventDefault();
  6486. }
  6487. if(keycode == "KeyU"){
  6488. if(aimbot == true){
  6489. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  6490. aimbot = false;
  6491. }
  6492. else{
  6493. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  6494. aimbot = true;
  6495. getplayerkeys();
  6496. }
  6497. e.preventDefault();
  6498. }
  6499. if(keycode == "KeyW"){
  6500. if(staystill == true){
  6501. displayInChat("Still is now off.","#DA0808","#1EBCC1");
  6502. staystill = false;
  6503. staystillpos = [0,0];
  6504. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6505. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6506. }
  6507. else{
  6508. if(playerids[myid].playerData?.transform){
  6509. displayInChat("Still is now on.","#DA0808","#1EBCC1");
  6510. staystill = true;
  6511. staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  6512. getplayerkeys();
  6513. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6514. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6515. }
  6516. else{
  6517. displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  6518. }
  6519. }
  6520. e.preventDefault();
  6521. }
  6522. }
  6523. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  6524. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  6525. 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"]==""){
  6526. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  6527. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  6528. fire("keydown",{keyCode:13});
  6529. }
  6530. else{
  6531. Gdocument.getElementById("newbonklobby_chat_input").focus();
  6532. }
  6533. e.preventDefault();
  6534. }
  6535. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  6536. Gdocument.getElementById("ingamechatinputtext").value = "/";
  6537. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  6538. fire("keydown",{keyCode:13});
  6539. }
  6540. else{
  6541. Gdocument.getElementById("ingamechatinputtext").focus();
  6542. }
  6543. e.preventDefault();
  6544. }
  6545. }
  6546. }
  6547. };
  6548. Gdocument.onkeydown = hotkeys;
  6549. Gwindow.addEventListener('resize',function(e){
  6550. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  6551. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  6552. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  6553. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  6554. logmenu.style["width"] = width.toString()+"px";
  6555. logmenu.style["height"] = height.toString()+"px";
  6556. logmenutopleft.style["width"] = (width/2).toString()+"px";
  6557. logmenutopright.style["width"] = (width/2).toString()+"px";
  6558. logmenutopright.style["left"] = (width/2).toString()+"px";
  6559. debuggerinput.style["width"] = width.toString()+"px";
  6560. debuggerinput.style["top"] = (height+90).toString()+"px";
  6561. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  6562. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  6563. debuggereval.style["width"] = (width-150).toString()+"px";
  6564. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  6565. function timeout123() {
  6566. updateWssLog();
  6567. EVENTLOOPFUNCTION();
  6568. var now = Date.now();
  6569. var keys = Object.keys(playerids);
  6570. if(getroomslastcheck+3000<now){
  6571. getroomslastcheck = now;
  6572. if(inroom && savedrooms.length>0){
  6573. Gdocument.getElementById("roomlistrefreshbutton").click();
  6574. }
  6575. }
  6576. var namelist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  6577. for(var i = 0;i<namelist.length;i++){
  6578. var level = 0;
  6579. var levelelement = 0;
  6580. var pingelement = 0;
  6581. var avatarelement = 0;
  6582. var children = namelist[i].parentElement.children;
  6583. for(var i2 = 0;i2<children.length;i2++){
  6584. if(children[i2].className == "newbonklobby_playerentry_level"){
  6585. levelelement = children[i2];
  6586. level = parseInt(children[i2].textContent.slice(6));
  6587. }
  6588. else if(children[i2].className == "newbonklobby_playerentry_pingtext"){
  6589. pingelement = children[i2];
  6590. }
  6591. else if(children[i2].className == "newbonklobby_playerentry_avatar"){
  6592. avatarelement = children[i2];
  6593. }
  6594. }
  6595. var isadmin = [false,0];
  6596. for(var i3 = 0;i3<admins.length;i3++){
  6597. if(admins[i3][0] == namelist[i].textContent){
  6598. isadmin = [true,i3];
  6599. break;
  6600. }
  6601. }
  6602. if(level){
  6603. if(isadmin[0]){
  6604. namelist[i].style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6605. if(isadmin[1]<=3){
  6606. var rotatevalue = 0;
  6607. if(admins[isadmin[1]][1][3]<90){
  6608. rotatevalue = admins[isadmin[1]][1][3]/2;
  6609. }
  6610. else if(admins[isadmin[1]][1][3]<270){
  6611. rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  6612. }
  6613. else if(admins[isadmin[1]][1][3]<360){
  6614. rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  6615. }
  6616. namelist[i].parentElement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6617. namelist[i].parentElement.style["font-size"] = "17px";
  6618. 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()+")";
  6619. if(levelelement){
  6620. levelelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6621. }
  6622. if(pingelement){
  6623. pingelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6624. }
  6625. if(avatarelement){
  6626. avatarelement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6627. }
  6628. }
  6629. }
  6630. }
  6631. var stylekeys = Object.keys(allstyles);
  6632. for(var i3 = 0;i3<stylekeys.length;i3++){
  6633. if(stylekeys[i3] == namelist[i].textContent){
  6634. 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])){
  6635. var rgbvalue = [allstyles[stylekeys[i3]][0],allstyles[stylekeys[i3]][1],allstyles[stylekeys[i3]][2]];
  6636. namelist[i].style["color"] = "rgb("+rgbvalue.toString()+")";
  6637. if(!isadmin[0]){
  6638. var n = 255;
  6639. namelist[i].parentElement.style["background"] = "rgb("+[(203+rgbvalue[0])%n,(212+rgbvalue[1])%n,(215+rgbvalue[2])%n].toString()+")";
  6640. }
  6641. if(levelelement){
  6642. levelelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6643. }
  6644. if(pingelement){
  6645. pingelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6646. }
  6647. }
  6648. }
  6649. }
  6650. }
  6651. for(var i3 = 0;i3<admins.length;i3++){
  6652. if(admins[i3][1][0]==0 && admins[i3][1][1]==0 && admins[i3][1][2]==0){
  6653. admins[i3][1][2] = 180;
  6654. admins[i3][1][1] = 0;
  6655. admins[i3][1][0] = 0;
  6656. }
  6657. var rate = 5;
  6658. var lowest = 0;
  6659. var number = 360;
  6660. admins[i3][1][3] = (admins[i3][1][3]%number+4+number)%number;
  6661. if(admins[i3][1][0]>lowest && admins[i3][1][1] == lowest){
  6662. admins[i3][1][0]-=rate;
  6663. admins[i3][1][2]+=rate;
  6664. }
  6665. if(admins[i3][1][2]>lowest && admins[i3][1][0] == lowest){
  6666. admins[i3][1][2]-=rate;
  6667. admins[i3][1][1]+=rate;
  6668. }
  6669. if(admins[i3][1][1]>lowest && admins[i3][1][2] == lowest){
  6670. admins[i3][1][0]+=rate;
  6671. admins[i3][1][1]-=rate;
  6672. }
  6673. for(var i4 = 0;i4<3;i4++){
  6674. if(admins[i3][1][i4]<lowest){
  6675. admins[i3][1][i4]=lowest;
  6676. }
  6677. else if(admins[i3][1][i4]>255){
  6678. admins[i3][1][i4]=255;
  6679. }
  6680. }
  6681. }
  6682. if(randomchat){
  6683. if(randomchat_timestamp+randomchat_randomtimestamp<now){
  6684. randomchat_timestamp = now;
  6685. randomchat_randomtimestamp = 2000+Math.random()*2000;
  6686. var randnumber = Math.floor(Math.random()*randomchatpriority[0])-randomchatlastmessage[1];
  6687. for(var i = 0;i<randomchatpriority[1].length;i++){
  6688. if(randomchatpriority[1][i][0]!=randomchatlastmessage[0]){
  6689. randnumber-=randomchatpriority[1][i][1];
  6690. if(randnumber<=0){
  6691. chat(flag_manage(randomchatpriority[1][i][0]));
  6692. randomchatpriority[1][i][1]+=2;
  6693. randomchatpriority[0]+=2;
  6694. randomchatlastmessage = randomchatpriority[1][i];
  6695. break;
  6696. }
  6697. }
  6698. }
  6699. }
  6700. }
  6701. for(var i = 0;i<keys.length;i++){
  6702. 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){
  6703. SEND('42[9,{"banshortid":'+keys[i].toString()+',"kickonly":'+(autokickban == 1).toString()+'}]');
  6704. autokickbantimestamp = now;
  6705. }
  6706. if(playerids[keys[i]].playerData){
  6707. if(playerids[keys[i]].playerData2){
  6708. if(playerids[keys[i]].playerData.transform){
  6709. playerids[keys[i]].playerData2.alive = true;
  6710. if(playerids[keys[i]].playerData2.timeStamp == 0){
  6711. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6712. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6713. playerids[keys[i]].playerData2.timeStamp = performance.now();
  6714. }
  6715. else{
  6716. playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x)/(playerids[keys[i]].playerData2.timeStamp-performance.now());
  6717. playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y)/(playerids[keys[i]].playerData2.timeStamp-performance.now());
  6718. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6719. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6720. playerids[keys[i]].playerData2.timeStamp = performance.now();
  6721. }
  6722. if(playerids[keys[i]].playerData2.timeStamp2 == 0){
  6723. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6724. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6725. playerids[keys[i]].playerData2.timeStamp2 = performance.now();
  6726. }
  6727. else{
  6728. playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel)/((playerids[keys[i]].playerData2.timeStamp2-performance.now()));
  6729. playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel)/((playerids[keys[i]].playerData2.timeStamp2-performance.now()));
  6730. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6731. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6732. playerids[keys[i]].playerData2.timeStamp2 = performance.now();
  6733. }
  6734. }
  6735. else{
  6736. if(playerids[keys[i]].playerData2.alive){
  6737. }
  6738. playerids[keys[i]].playerData2.alive = false;
  6739. }
  6740. }
  6741. else{
  6742. 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};
  6743. }
  6744. }
  6745. }
  6746. for(var i = 0;i<keys.length;i++){
  6747. if(!playerids[keys[i]].playerData2){
  6748. 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};
  6749. }
  6750. }
  6751. if(Gdocument.getElementById("redefineControls_table").children[0].children.length<=1 && keys.length>0){
  6752. Gdocument.getElementById("pretty_top_settings").click();
  6753. Gdocument.getElementById("settings_close").click();
  6754. }
  6755. if(pollactive[0] && pollactive[2]<now && ishost){
  6756. playerids[myid].ratelimit.poll = Date.now();
  6757. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  6758. var count = [0,0,0,0];
  6759. var keys = Object.keys(playerids);
  6760. for(var i = 0;i<keys.length;i++){
  6761. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  6762. count[playerids[keys[i]].vote.poll]++;
  6763. }
  6764. playerids[keys[i]].vote.poll = -1;
  6765. }
  6766. displayInChat("The poll ended due to time.","#DA0808","#1EBCC1");
  6767. for(var i = 0;i<count.length;i++){
  6768. if(count[i]>1){
  6769. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6770. }
  6771. if(count[i]==1){
  6772. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6773. }
  6774. }
  6775. displayInChat("The poll was:","#DA0808","#1EBCC1");
  6776. for(var i = 0;i<pollactive[3].length;i++){
  6777. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  6778. }
  6779. pollactive = [false,0,0,[]];
  6780. }
  6781. if(!ishost && sandboxcopyme!=-1){
  6782. sandboxcopyme = -1;
  6783. }
  6784. if(afkkill>0 && ishost){
  6785. var keys = Object.keys(playerids);
  6786. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  6787. for(var i = 0; i<keys.length;i++){
  6788. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  6789. playerids[keys[i]].lastmove = now;
  6790. }
  6791. else{
  6792. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  6793. killedids.push(keys[i]);
  6794. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6795. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6796. break;
  6797. }
  6798. }
  6799. }
  6800. }
  6801. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  6802. clearmaprequests.style["display"] = "block";
  6803. refreshmaprequests.style["display"] = "block";
  6804. }
  6805. else{
  6806. clearmaprequests.style["display"] = "none";
  6807. refreshmaprequests.style["display"] = "none";
  6808. }
  6809. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  6810. Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";
  6811. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6812. pan = {"x":0,"y":0};
  6813. }
  6814. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  6815. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  6816. }
  6817. 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"] == "")){
  6818. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  6819. while (chatbox.firstChild) {
  6820. chatbox.removeChild(chatbox.firstChild);
  6821. }
  6822. chatbox = Gdocument.getElementById("ingamechatcontent");
  6823. while (chatbox.firstChild) {
  6824. chatbox.removeChild(chatbox.firstChild);
  6825. }
  6826. rcaps_flag = false;
  6827. space_flag = false;
  6828. number_flag = false;
  6829. reverse_flag = false;
  6830. autocorrect = false;
  6831. translating2 = [false,""];
  6832. translating = [false,""];
  6833. echo_list = [];
  6834. scroll = false;
  6835. FollowCam = false;
  6836. autocam = false;
  6837. aimbot = false;
  6838. recievedinitdata = false;
  6839. zoom = 1;
  6840. zoom2 = 1;
  6841. newzoom = 1;
  6842. newzoom2 = 1;
  6843. FFA = true;
  6844. mode = "b";
  6845. ghostroomwss = -1;
  6846. heavybot = false;
  6847. stopquickplay = 1;
  6848. roundsperqp = 1;
  6849. roundsperqp2 = 0;
  6850. staystill = false;
  6851. staystillpos = [0,0];
  6852. recording = false;
  6853. recordingid = -1;
  6854. reverseqp = false;
  6855. jointeam = -1;
  6856. currentroomaddress = -1;
  6857. checkboxhidden = false;
  6858. freejoin = false;
  6859. shuffle = false;
  6860. textmode = -1;
  6861. defaultmode = "";
  6862. recmodebool = false;
  6863. recteams = false;
  6864. autorecord = false;
  6865. pollactive = [false,0,0,[]];
  6866. pollactive2 = [false,0,[]];
  6867. afkkill = -1;
  6868. nextafter = 0;
  6869. jointext = "";
  6870. ishost = false;
  6871. parentDraw = 0;
  6872. sandboxplayerids = {};
  6873. sandboxcopyme = -1;
  6874. wintext = "";
  6875. sandboxon = false;
  6876. sandboxid = 200;
  6877. disabledkeys = [];
  6878. myid = -1;
  6879. randomchat = false;
  6880. savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
  6881. randomchatpriority = [0,[]];
  6882. randomchatlastmessage = ["",0];
  6883. autokickbantimestamp = 0;
  6884. autokickban = 0;
  6885. inroom = false;
  6886. causelag = false;
  6887. causelag2 = 0;
  6888. jukeboxplayerURL = "";
  6889. jukeboxplayer.src = "";
  6890. jukeboxplayervolume = 20;
  6891. allstyles = {};
  6892. pan = {"x":0, "y":0};
  6893. if(!bonkwss){
  6894. playerids = {};
  6895. }
  6896. qppaused = false;
  6897. nextafterbuffer = -1;
  6898. hostid = -1;
  6899. if(chatlog[chatlog.length-1]!="ROOM END"){
  6900. chatlog.push("ROOM END");
  6901. }
  6902. }
  6903. else{
  6904. if(chatlog[chatlog.length-1]=="ROOM END"){
  6905. chatlog.push("ROOM START");
  6906. }
  6907. }
  6908. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  6909. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  6910. }
  6911. else{
  6912. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  6913. }
  6914. if((myid == hostid && myid!=-1) || Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  6915. ishost = true;
  6916. }
  6917. else{
  6918. ishost = actuallyhost;
  6919. }
  6920. if(Gdocument.getElementById("pretty_top_name")!=null){
  6921. username = Gdocument.getElementById("pretty_top_name").textContent;
  6922. if(myid!=-1){
  6923. username = playerids[myid].userName;
  6924. }
  6925. }
  6926. try{
  6927. Last_message = lastmessage()
  6928. } catch{
  6929. Last_message = "";
  6930. }
  6931. if (Laster_message != Last_message){
  6932. Laster_message = Last_message;
  6933. if(changed_chat==false){
  6934. new_message = true;
  6935. }
  6936. else{
  6937. changed_chat = false;
  6938. }
  6939. }
  6940. if(new_message){
  6941. chatlog.push(Last_message);
  6942. var lm = "";
  6943. try{
  6944. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  6945. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  6946. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  6947. lm[2].innerHTML = urlify(lm[2].innerHTML);
  6948. Laster_message = lastmessage();
  6949. lm[0].parentElement.style["parsed"] = true;
  6950. }
  6951. if (lm[0].className == "newbonklobby_chat_status"){
  6952. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6953. Laster_message = lastmessage();
  6954. lm[0].parentElement.style["parsed"] = true;
  6955. }
  6956. }
  6957. }
  6958. catch{
  6959. lm = "";
  6960. }
  6961. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  6962. if(Notification.requestPermission()){
  6963. var n = new Notification(Last_message);
  6964. }
  6965. }
  6966. try{
  6967. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  6968. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  6969. if(lm[0].className == "ingamechatname"){
  6970. lm[1].innerHTML = urlify(lm[1].innerHTML);
  6971. Laster_message = lastmessage();
  6972. lm[0].parentElement.style["parsed"] = true;
  6973. }
  6974. if(lm[0].className == ""){
  6975. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6976. Laster_message = lastmessage();
  6977. lm[0].parentElement.style["parsed"] = true;
  6978. }
  6979. }
  6980. }
  6981. catch{
  6982. lm = "";
  6983. }
  6984. if(text2speech){
  6985. if(!sayer.speaking){
  6986. if(Last_message.includes(": ")){
  6987. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  6988. speech.rate = 2.25;
  6989. sayer.speak(speech);
  6990. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  6991. speech.rate = 1.25;
  6992. sayer.speak(speech);
  6993. }
  6994. else{
  6995. speech.text = Last_message.toLowerCase();
  6996. sayer.speak(speech);
  6997. }
  6998. }
  6999. }
  7000. }
  7001. if (ishost==true && new_message){
  7002. for(i=0;i<banned.length;i++){
  7003. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  7004. chat2("/kick '"+banned[i]+"'");
  7005. }
  7006. }
  7007. }
  7008. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  7009. roundsperqp2 = 0;
  7010. }
  7011. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  7012. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  7013. if(stopquickplay!=1){
  7014. roundsperqp2++;
  7015. }
  7016. if(autorecord){
  7017. Gdocument.getElementById("pretty_top_replay").click();
  7018. }
  7019. }
  7020. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  7021. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  7022. }
  7023. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  7024. }
  7025. else{
  7026. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  7027. }
  7028. if(ishost && stopquickplay == 0){
  7029. if(checkboxhidden){
  7030. checkboxhidden = false;
  7031. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  7032. for(var i = 0; i<classes.length;i++){
  7033. classes[i].style["display"] = "block";
  7034. classes[i].className = "quickplaycheckbox quickplaychecked";
  7035. }
  7036. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  7037. }
  7038. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit" && !qppaused){
  7039. roundsperqp2 = 0;
  7040. if(shuffle){
  7041. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  7042. var available = [];
  7043. var availableindexes = [];
  7044. var notempty = false;
  7045. for(var i = 0; i<e.length;i++){
  7046. var a = false;
  7047. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  7048. available.push(a);
  7049. if(a){
  7050. availableindexes.push(i);
  7051. notempty = true;
  7052. }
  7053. }
  7054. if(notempty){
  7055. if(availableindexes.length!=1){
  7056. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  7057. }
  7058. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  7059. }
  7060. }
  7061. else{
  7062. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  7063. var available = [];
  7064. var availableindexes = [];
  7065. var notempty = false;
  7066. for(var i = 0; i<e.length;i++){
  7067. var a = false;
  7068. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  7069. available.push(a);
  7070. if(a){
  7071. availableindexes.push(i);
  7072. notempty = true;
  7073. }
  7074. }
  7075. if(notempty){
  7076. var above = [];
  7077. for(var i = 0;i<availableindexes.length;i++){
  7078. if(availableindexes[i]>quicki && !reverseqp){
  7079. above.push(availableindexes[i]);
  7080. }
  7081. else if(availableindexes[i]<quicki && reverseqp){
  7082. above.push(availableindexes[i]);
  7083. }
  7084. }
  7085. if(above.length>0){
  7086. quicki = above[0];
  7087. if(reverseqp){
  7088. above[above.length-1];
  7089. }
  7090. }
  7091. else{
  7092. quicki = availableindexes[0];
  7093. if(reverseqp){
  7094. quicki = availableindexes[availableindexes.length-1];
  7095. }
  7096. }
  7097. }
  7098. }
  7099. startedinqp = true;
  7100. dontswitch = true;
  7101. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  7102. }
  7103. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden && !qppaused){
  7104. if(roundsperqp2>=roundsperqp){
  7105. if(shuffle){
  7106. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  7107. var available = [];
  7108. var availableindexes = [];
  7109. var notempty = false;
  7110. for(var i = 0; i<e.length;i++){
  7111. var a = false;
  7112. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  7113. available.push(a);
  7114. if(a){
  7115. availableindexes.push(i);
  7116. notempty = true;
  7117. }
  7118. }
  7119. if(notempty){
  7120. if(availableindexes.length!=1){
  7121. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  7122. }
  7123. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  7124. }
  7125. }
  7126. else{
  7127. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  7128. var available = [];
  7129. var availableindexes = [];
  7130. var notempty = false;
  7131. for(var i = 0; i<e.length;i++){
  7132. var a = false;
  7133. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  7134. available.push(a);
  7135. if(a){
  7136. availableindexes.push(i);
  7137. notempty = true;
  7138. }
  7139. }
  7140. if(notempty){
  7141. var above = [];
  7142. for(var i = 0;i<availableindexes.length;i++){
  7143. if(availableindexes[i]>quicki && !reverseqp){
  7144. above.push(availableindexes[i]);
  7145. }
  7146. else if(availableindexes[i]<quicki && reverseqp){
  7147. above.push(availableindexes[i])
  7148. }
  7149. }
  7150. if(above.length>0){
  7151. quicki = above[0];
  7152. if(reverseqp){
  7153. quicki = above[above.length-1];
  7154. }
  7155. }
  7156. else{
  7157. quicki = availableindexes[0];
  7158. if(reverseqp){
  7159. quicki = availableindexes[availableindexes.length-1];
  7160. }
  7161. }
  7162. }
  7163. }
  7164. }
  7165. transitioning = true;
  7166. startedinqp = true;
  7167. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  7168. dontswitch = true;
  7169. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  7170. }
  7171. }
  7172. else{
  7173. if(!checkboxhidden){
  7174. checkboxhidden = true;
  7175. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  7176. for(var i = 0; i<classes.length;i++){
  7177. classes[i].style["display"] = "none";
  7178. classes[i].className = "quickplaycheckbox quickplayunchecked";
  7179. }
  7180. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  7181. }
  7182. }
  7183. new_message = false;
  7184. };
  7185. });