Bonk Commands

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

当前为 2023-11-17 提交的版本,查看 最新版本

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