Bonk Commands

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

当前为 2024-01-08 提交的版本,查看 最新版本

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