Bonk Commands

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

目前為 2024-07-26 提交的版本,檢視 最新版本

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