Bonk Commands

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

当前为 2024-06-19 提交的版本,查看 最新版本

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