Bonk Commands

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

当前为 2024-05-31 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bonk Commands
  3. // @namespace https://gf.qytechs.cn/en/scripts/451341-bonk-commands
  4. // @version 20.1
  5. // @description Adds lots of commands to bonk.io. Type /? or /help in bonk chat to get started.
  6. // @author LEGENDBOSS123 + left paren + mastery3
  7. // @match https://bonk.io/*
  8. // @match https://bonkisback.io/*
  9. // @match https://multiplayer.gg/physics/*
  10. // @run-at document-idle
  11. // @grant none
  12. // @unwrap
  13. // ==/UserScript==
  14.  
  15. function BonkCommandsScriptInjector(f){
  16. if(window.location == window.parent.location){
  17. if(document.readyState == "complete"){f();}
  18. else{document.addEventListener('readystatechange',function(){setTimeout(f,1500);});}
  19. }
  20. }
  21. BonkCommandsScriptInjector(function(){
  22. var scope = window;
  23. scope.scope = scope;
  24. scope.Gwindow = document.getElementById("maingameframe").contentWindow;
  25. scope.Gdocument = document.getElementById("maingameframe").contentDocument;
  26. Gwindow.Gwindow = window;
  27. Gwindow.Gdocument = document;
  28. scope.link2pastebin = "https://pastebin.com/2b8XqqYu";
  29. scope.link2greasyfork = "https://gf.qytechs.cn/en/scripts/451341-bonk-commands";
  30. if(typeof(scope.injectedBonkCommandsScript)=='undefined'){
  31. scope.injectedBonkCommandsScript = true;
  32. }
  33. else{
  34. clearInterval(injectedBonkCommandsScript);
  35. }
  36. scope.GENERATE_COPRIME_NUMBER = function(mini = 0,maxi = 0,coprimewith = 0,choices = []){
  37. if(choices.length == 0){
  38. for(var i = mini;i<maxi+1;i++){
  39. choices.push(i);
  40. }
  41. }
  42. firstTry = choices[Math.floor(Math.random()*choices.length)];
  43. for(var i = 2; i<firstTry+1;i++){
  44. if(firstTry%i == 0 && coprimewith%i == 0){
  45. choices.splice(choices.indexOf(firstTry),1);
  46. if(choices.length == 0){
  47. return 0;
  48. }
  49. return GENERATE_COPRIME_NUMBER(mini,maxi,coprimewith,choices);
  50. }
  51. }
  52. return firstTry;
  53. };
  54. scope.GENERATE_PRIME_NUMBER = function(mini = 0,maxi = 0,choices = []){
  55. if(choices.length == 0){
  56. for(var i = mini;i<maxi+1;i++){
  57. choices.push(i);
  58. }
  59. }
  60. firstTry = choices[Math.floor(Math.random()*choices.length)];
  61. for(var i = 2; i<Math.floor(Math.sqrt(firstTry)+1);i++){
  62. if(i!=firstTry){
  63. if(firstTry%i == 0){
  64. choices.splice(choices.indexOf(firstTry),1);
  65. if(choices.length == 0){
  66. return 0;
  67. }
  68. return GENERATE_PRIME_NUMBER(mini,maxi,choices);
  69. }
  70. }
  71. }
  72. return firstTry;
  73. };
  74. scope.SHUFFLE_LIST = function(x){
  75. var nl = x.slice();
  76. for(var i = nl.length - 1;i>0;i--){
  77. var r = Math.floor(Math.random()*(i+1));
  78. var t = nl[i];
  79. nl[i] = nl[r];
  80. nl[r] = t;
  81. }
  82. return nl;
  83. };
  84. scope.str2ab = function(str) {
  85. const buf = new ArrayBuffer(str.length);
  86. const bufView = new Uint8Array(buf);
  87. for (let i = 0, strLen = str.length; i < strLen; i++) {
  88. bufView[i] = str.charCodeAt(i);
  89. }
  90. return buf;
  91. };
  92. scope.ab2str = function(buffer) {
  93. return String.fromCharCode.apply(null, new Uint8Array(buffer));
  94. };
  95. scope.GENERATE_KEYS = async function(){
  96. return crypto.subtle.generateKey({name: "RSA-OAEP",modulusLength: 2048,publicExponent: new Uint8Array([1, 0, 1]),hash: {name: "SHA-256"}},true,["encrypt","decrypt"]);
  97. };
  98. scope.CRYPT_NUMBER = function(key, data){
  99. result = 1;
  100. for(var i = 0;i<key[1];i++){
  101. result*=data;
  102. result = result%key[0];
  103. }
  104. return result%key[0];
  105. };
  106. scope.ENCRYPT_MESSAGE = async function(key,data){
  107. try{
  108. var encrypted = await window.crypto.subtle.encrypt(
  109. {
  110. name: "RSA-OAEP"
  111. },
  112. key,
  113. new TextEncoder().encode(data)
  114. );
  115. return btoa(ab2str(encrypted));
  116. }
  117. catch(E){
  118. console.log(E);
  119. return 0;
  120. }
  121. };
  122. scope.DECRYPT_MESSAGE = async function(key,data){
  123. try{
  124. var decrypted = await window.crypto.subtle.decrypt(
  125. {
  126. name: "RSA-OAEP"
  127. },
  128. key,
  129. str2ab(atob(data))
  130. );
  131. return new TextDecoder().decode(decrypted);
  132. }
  133. catch{
  134. return 0;
  135. }
  136. };
  137. scope.IMPORT_KEY = async function(key){
  138. return await crypto.subtle.importKey("spki", str2ab(atob(key)),public_key.algorithm,true,["encrypt"]);
  139. };
  140. scope.EXPORT_KEY = async function(key){
  141. var result = await crypto.subtle.exportKey("spki",key);
  142. return btoa(ab2str(result));
  143. };
  144. if(typeof(scope.textdecoder)=='undefined'){scope.textdecoder = new Gwindow.TextDecoder;}
  145. if(typeof(scope.textencoder)=='undefined'){scope.textencoder = new Gwindow.TextEncoder;}
  146. class bytebuffer2 {
  147. constructor() {
  148. var g1d = [arguments];
  149. this.index = 0;
  150. this.buffer = new ArrayBuffer(100*1024);
  151. this.view = new DataView(this.buffer);
  152. this.implicitClassAliasArray = [];
  153. this.implicitStringArray = [];
  154. this.bodgeCaptureZoneDataIdentifierArray = [];
  155. }
  156. readByte() {
  157. var N0H = [arguments];
  158. N0H[4] = this.view.getUint8(this.index);
  159. this.index += 1;
  160. return N0H[4];
  161. }
  162. writeByte(z0w) {
  163. var v8$ = [arguments];
  164. this.view.setUint8(this.index, v8$[0][0]);
  165. this.index += 1;
  166. }
  167. readInt() {
  168. var A71 = [arguments];
  169. A71[6] = this.view.getInt32(this.index);
  170. this.index += 4;
  171. return A71[6];
  172. }
  173. writeInt(W6i) {
  174. var p5u = [arguments];
  175. this.view.setInt32(this.index, p5u[0][0]);
  176. this.index += 4;
  177. }
  178. readShort() {
  179. var R1R = [arguments];
  180. R1R[9] = this.view.getInt16(this.index);
  181. this.index += 2;
  182. return R1R[9];
  183. }
  184. writeShort(H8B) {
  185. var d_3 = [arguments];
  186. this.view.setInt16(this.index, d_3[0][0]);
  187. this.index += 2;
  188. }
  189. readUint() {
  190. var W2$ = [arguments];
  191. W2$[8] = this.view.getUint32(this.index);
  192. this.index += 4;
  193. return W2$[8];
  194. }
  195. writeUint(B2X) {
  196. var f8B = [arguments];
  197. this.view.setUint32(this.index, f8B[0][0]);
  198. this.index += 4;
  199. }
  200. readBoolean() {
  201. var h6P = [arguments];
  202. h6P[6] = this.readByte();
  203. return h6P[6] == 1;
  204. }
  205. writeBoolean(Y3I) {
  206. var l79 = [arguments];
  207. if (l79[0][0]) {
  208. this.writeByte(1);
  209. } else {
  210. this.writeByte(0);
  211. }
  212. }
  213. readDouble() {
  214. var V60 = [arguments];
  215. V60[4] = this.view.getFloat64(this.index);
  216. this.index += 8;
  217. return V60[4];
  218. }
  219. writeDouble(z4Z) {
  220. var O41 = [arguments];
  221. this.view.setFloat64(this.index, O41[0][0]);
  222. this.index += 8;
  223. }
  224. readFloat() {
  225. var I0l = [arguments];
  226. I0l[5] = this.view.getFloat32(this.index);
  227. this.index += 4;
  228. return I0l[5];
  229. }
  230. writeFloat(y4B) {
  231. var B0v = [arguments];
  232. this.view.setFloat32(this.index, B0v[0][0]);
  233. this.index += 4;
  234. }
  235. readUTF() {
  236. var d6I = [arguments];
  237. d6I[8] = this.readByte();
  238. d6I[7] = this.readByte();
  239. d6I[9] = d6I[8] * 256 + d6I[7];
  240. d6I[1] = new Uint8Array(d6I[9]);
  241. for (d6I[6] = 0; d6I[6] < d6I[9]; d6I[6]++) {
  242. d6I[1][d6I[6]] = this.readByte();
  243. }
  244. return textdecoder.decode(d6I[1]);
  245. }
  246. writeUTF(L3Z) {
  247. var Z75 = [arguments];
  248. Z75[4] = textencoder.encode(Z75[0][0]);
  249. Z75[3] = Z75[4].length;
  250. Z75[5] = Math.floor(Z75[3]/256);
  251. Z75[8] = Z75[3] % 256;
  252. this.writeByte(Z75[5]);
  253. this.writeByte(Z75[8]);
  254. Z75[7] = this;
  255. Z75[4].forEach(I_O);
  256. function I_O(s0Q, H4K, j$o) {
  257. var N0o = [arguments];
  258. Z75[7].writeByte(N0o[0][0]);
  259. }
  260. }
  261. toBase64() {
  262. var P4$ = [arguments];
  263. P4$[4] = "";
  264. P4$[9] = new Uint8Array(this.buffer);
  265. P4$[8] = this.index;
  266. for (P4$[7] = 0; P4$[7] < P4$[8]; P4$[7]++) {
  267. P4$[4] += String.fromCharCode(P4$[9][P4$[7]]);
  268. }
  269. return Gwindow.btoa(P4$[4]);
  270. }
  271. fromBase64(W69, A8Q) {
  272. var o0n = [arguments];
  273. o0n[8] = Gwindow.pako;
  274. o0n[6] = Gwindow.atob(o0n[0][0]);
  275. o0n[9] = o0n[6].length;
  276. o0n[4] = new Uint8Array(o0n[9]);
  277. for (o0n[1] = 0; o0n[1] < o0n[9]; o0n[1]++) {
  278. o0n[4][o0n[1]] = o0n[6].charCodeAt(o0n[1]);
  279. }
  280. if (o0n[0][1] === true) {
  281. o0n[5] = o0n[8].inflate(o0n[4]);
  282. o0n[4] = o0n[5];
  283. }
  284. this.buffer = o0n[4].buffer.slice(
  285. o0n[4].byteOffset,
  286. o0n[4].byteLength + o0n[4].byteOffset
  287. );
  288. this.view = new DataView(this.buffer);
  289. this.index = 0;
  290. }
  291. };
  292. if(typeof(scope.originalSend)=='undefined'){scope.originalSend = Gwindow.WebSocket.prototype.send;}
  293. if(typeof(scope.originalDatenow)=='undefined'){scope.originalDatenow = Gwindow.Date.now;}
  294. if(typeof(scope.originalXMLOpen)=='undefined'){scope.originalXMLOpen = Gwindow.XMLHttpRequest.prototype.open;}
  295. if(typeof(scope.originalXMLSend)=='undefined'){scope.originalXMLSend = Gwindow.XMLHttpRequest.prototype.send;}
  296. if(typeof(scope.searchrequested)=='undefined'){scope.searchrequested = 0;}
  297. if(typeof(scope.originalDrawCircle)=='undefined'){scope.originalDrawCircle = Gwindow.PIXI.Graphics.prototype.drawCircle;}
  298. if(typeof(scope.parentDraw)=='undefined'){scope.parentDraw = 0;}
  299. if(typeof(scope.pixiCircle)=='undefined'){scope.pixiCircle = new Gwindow.PIXI.Graphics();}
  300. if(typeof(scope.container)=='undefined'){scope.container = new Gwindow.PIXI.Container();container.addChild(pixiCircle);}
  301. if(typeof(scope.canvasWidth)=='undefined'){scope.canvasWidth = -1;}
  302. if(typeof(scope.savedrooms)=='undefined'){scope.savedrooms = [];}
  303. if(typeof(scope.inroom)=='undefined'){scope.inroom = false;}
  304. if(typeof(scope.currentroomaddress)=='undefined'){scope.currentroomaddress = -1;}
  305. if(typeof(scope.savedroomsdata)=='undefined'){scope.savedroomsdata = {};}
  306. if(typeof(scope.jukeboxplayerURL)=='undefined'){scope.jukeboxplayerURL = "";}
  307. if(typeof(scope.jukeboxplayervolume)=='undefined'){scope.jukeboxplayervolume = 20;}
  308. if(typeof(scope.gameStartTimeStamp)=='undefined'){scope.gameStartTimeStamp = 0;}
  309. scope.checkInstance = async function(index){
  310. var doesitwork = false;
  311. await fetch(pipedurllist[index]+"dQw4w9WgXcQ").then(
  312. function(r){
  313. return r.json();
  314. }
  315. ).then(async function(r){
  316. if (r.audioStreams && !r.error){
  317. for(var i2 = 0;i2<r.audioStreams.length;i2++){
  318. if(r.audioStreams[i2].url){
  319. try{
  320. var f = await fetch(r.audioStreams[i2].url);
  321. if(f.ok){
  322. doesitwork = true;
  323. return;
  324. }
  325. }
  326. catch(e){}
  327. }
  328. }
  329. }
  330. }).catch(function(e){});
  331. if(!doesitwork){
  332. return -1;
  333. }
  334. return index;
  335. };
  336. scope.checkJukeboxStream = async function(index,id){
  337. var doesitwork = false;
  338. var urlreturn = [];
  339. await fetch(pipedurllist[index]+id).then(
  340. function(r){
  341. return r.json();
  342. }
  343. ).then(async function(r){
  344. if (r.audioStreams && !r.error){
  345. for(var i2 = 0;i2<r.audioStreams.length;i2++){
  346. if(r.audioStreams[i2].url){
  347. try{
  348. var f = await fetch(r.audioStreams[i2].url);
  349. if(f.ok){
  350. doesitwork = true;
  351. urlreturn = [r.audioStreams[i2].url,r.title,r.uploader];
  352. return;
  353. }
  354. }
  355. catch(e){}
  356. }
  357. }
  358. }
  359. }).catch(function(e){});
  360. if(!doesitwork){
  361. return -1;
  362. }
  363. return urlreturn;
  364. };
  365. scope.checkInstances = async function (){
  366. pipedindexes = [];
  367. for (var index = 0;index<pipedurllist.length;index++){
  368. checkInstance(index).then(function(value){
  369. if(value!=-1){
  370. pipedindexes.push(value);
  371. }
  372. });
  373. }
  374. };
  375. if(typeof(scope.pipedurllist)=='undefined'){
  376. scope.pipedurllist = [
  377. "https://pipedapi.kavin.rocks/streams/",
  378. "https://pipedapi.syncpundit.io/streams/",
  379. "https://api-piped.mha.fi/streams/",
  380. "https://piped-api.garudalinux.org/streams/",
  381. "https://pipedapi.rivo.lol/streams/",
  382. "https://pipedapi.leptons.xyz/streams/",
  383. "https://piped-api.lunar.icu/streams/",
  384. "https://ytapi.dc09.ru/streams/",
  385. "https://piped.tokhmi.xyz/streams/",
  386. "https://pipedapi.aeong.one/streams/"];
  387. scope.pipedindexes = [];
  388. checkInstances();
  389. }
  390. if(typeof(scope.requestAnimationFrameOriginal)=='undefined'){scope.requestAnimationFrameOriginal = Gwindow.requestAnimationFrame;}
  391. if(typeof(scope.bonkwss)=='undefined'){scope.bonkwss = 0;}
  392. if(typeof(scope.bonkwssextra)=='undefined'){scope.bonkwssextra = [];}
  393. if(typeof(scope.chatlog)=='undefined'){scope.chatlog = ["ROOM START"];}
  394. if(typeof(scope.wsssendrecievelog)=='undefined'){scope.wsssendrecievelog = [];}
  395. if(typeof(scope.wsssendlog)=='undefined'){scope.wsssendlog = [];}
  396. if(typeof(scope.wssrecievelog)=='undefined'){scope.wssrecievelog = [];}
  397. if(typeof(scope.wsslogpaused)=='undefined'){scope.wsslogpaused = false;}
  398. if(typeof(scope.debuggeropen)=='undefined'){scope.debuggeropen = false;}
  399. if(typeof(scope.debuggercount)=='undefined'){scope.debuggercount = true;}
  400. if(typeof(scope.packetcount)=='undefined'){scope.packetcount = 0;}
  401. if(typeof(scope.requestedmaps)=='undefined'){scope.requestedmaps = [];}
  402. if(typeof(scope.maponclick)=='undefined'){scope.maponclick = 0;}
  403. if(typeof(scope.LZString)=='undefined'){scope.LZString = Gwindow.LZString;}
  404. if(typeof(scope.PSON)=='undefined'){scope.PSON = Gwindow.dcodeIO.PSON;}
  405. if(typeof(scope.bytebuffer)=='undefined'){scope.bytebuffer = Gwindow.dcodeIO.ByteBuffer;}
  406. if(typeof(scope.speech)=='undefined'){scope.speech = new SpeechSynthesisUtterance();speech.pitch = 0.75;}
  407. if(typeof(scope.sayer)=='undefined'){scope.sayer = speechSynthesis;sayer.volume = 0.5;sayer.rate = 1.25;}
  408. if(typeof(scope.pollactive)=='undefined'){scope.pollactive = [false,0,0,[]];}
  409. if(typeof(scope.pollactive2)=='undefined'){scope.pollactive2 = [false,0,[]];}
  410. if(typeof(scope.mode)=='undefined'){scope.mode = '';}
  411. if(typeof(scope.FFA)=='undefined'){scope.FFA = true;}
  412. if(typeof(scope.recording)=='undefined'){scope.recording = false;}
  413. if(typeof(scope.recordingdata)=='undefined'){scope.recordingdata = [];}
  414. if(typeof(scope.recorddata)=='undefined'){scope.recorddata = {};}
  415. if(typeof(scope.recordingid)=='undefined'){scope.recordingid = -1;}
  416. if(typeof(scope.wordlist)=='undefined'){
  417. scope.wordlist = [];
  418. fetch("https://api.github.com/repos/first20hours/google-10000-english/contents/20k.txt").then(function(data){
  419. return data.json();
  420. }).then(function(data){
  421. fetch("https://api.github.com/repos/first20hours/google-10000-english/git/blobs/"+data.sha).then(function(data){
  422. return data.json();
  423. }).then(function(data){
  424. scope.wordlist = atob(data.content).split("\n");
  425. });
  426. });
  427. }
  428. if(typeof(scope.allstyles)=='undefined'){scope.allstyles = {};}
  429. if(typeof(scope.mystyle)=='undefined'){scope.mystyle = [0,0,0];}
  430. if(typeof(scope.ISpsonpair)=='undefined'){scope.ISpsonpair = new Gwindow.dcodeIO.PSON.StaticPair(["physics", "shapes", "fixtures", "bodies", "bro", "joints", "ppm", "lights", "spawns", "lasers", "capZones", "type", "w", "h", "c", "a", "v", "l", "s", "sh", "fr", "re", "de", "sn", "fc", "fm", "f", "d", "n", "bg", "lv", "av", "ld", "ad", "fr", "bu", "cf", "rv", "p", "d", "bf", "ba", "bb", "aa", "ab", "axa", "dr", "em", "mmt", "mms", "ms", "ut", "lt", "New body", "Box Shape", "Circle Shape", "Polygon Shape", "EdgeChain Shape", "priority", "Light", "Laser", "Cap Zone", "BG Shape", "Background Layer", "Rotate Joint", "Slider Joint", "Rod Joint", "Gear Joint", 65535, 16777215]);}
  431. if(typeof(scope.sandboxon)=='undefined'){scope.sandboxon = false;}
  432. if(typeof(scope.sandboxid)=='undefined'){scope.sandboxid = 200;}
  433. if(typeof(scope.playerids)=='undefined'){scope.playerids = {};}
  434. if(typeof(scope.delplayerids)=='undefined'){scope.delplayerids = {};}
  435. if(typeof(scope.myid)=='undefined'){scope.myid = -1;}
  436. if(typeof(scope.hostid)=='undefined'){scope.hostid = -1;}
  437. if(typeof(scope.sandboxplayerids)=='undefined'){scope.sandboxplayerids = {};}
  438. if(typeof(scope.originalMapLoad)=='undefined'){scope.originalMapLoad = Gdocument.getElementById("maploadwindowmapscontainer").appendChild;}
  439. if(typeof(scope.originalLobbyChat)=='undefined'){scope.originalLobbyChat = Gdocument.getElementById("newbonklobby_chat_content").appendChild;}
  440. if(typeof(scope.originalIngameChat)=='undefined'){scope.originalIngameChat = Gdocument.getElementById("ingamechatcontent").appendChild;}
  441. if(typeof(scope.private_chat_keys)=='undefined'){GENERATE_KEYS().then(function(e){scope.private_chat_keys = e;scope.private_key = private_chat_keys.privateKey;scope.public_key = private_chat_keys.publicKey;});}
  442. if(typeof(scope.jukeboxplayer)=='undefined'){
  443. scope.jukeboxplayer = Gdocument.createElement("audio");
  444. jukeboxplayer.controls = true;
  445. jukeboxplayer.loop = true;
  446. }
  447. if(Gdocument.getElementById("savedroombutton") == null){
  448. scope.savedroombutton = Gdocument.createElement("div");
  449. savedroombutton.id = "savedroombutton";
  450. savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
  451. savedroombutton.textContent = "Save Room";
  452. savedroombutton.style["left"] = "120px";
  453. savedroombutton.style["position"] = "absolute";
  454. savedroombutton.style["width"] = "90px";
  455. savedroombutton.style["height"] = "30px";
  456. savedroombutton.style["color"] = "#ffffff";
  457. savedroombutton.style["text-align"] = "center";
  458. savedroombutton.style["vertical-align"] = "middle";
  459. savedroombutton.style["line-height"] = "30px";
  460. savedroombutton.style["right"] = "0";
  461. savedroombutton.style["cursor"] = "pointer";
  462. savedroombutton.style["bottom"] = "10px";
  463. savedroombutton.style["margin"] = "auto";
  464. savedroombutton.style["bottom"] = "10px";
  465. savedroombutton.onclick = function(){
  466. if(!savedrooms.includes(currentroomaddress) && currentroomaddress!=-1){
  467. savedrooms.push(currentroomaddress);
  468. savedroomsdata[currentroomaddress] = {"exists":true};
  469. }
  470. Gdocument.getElementById("sm_connectingWindowCancelButton").click();
  471. };
  472. Gdocument.getElementById("sm_connectingWindowCancelButton").style["left"] = "-120px";
  473. Gdocument.getElementById("sm_connectingWindow").appendChild(savedroombutton)
  474. }
  475. if(Gdocument.getElementById("maploadtypedropdowntitlerequested") == null){
  476. scope.clearmaprequests = Gdocument.createElement("div");
  477. clearmaprequests.id = "clearmaprequests";
  478. clearmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  479. clearmaprequests.textContent = "Clear";
  480. clearmaprequests.style["position"] = "absolute";
  481. clearmaprequests.style["display"] = "none";
  482. if(typeof(ishost)!='undefined'){
  483. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  484. clearmaprequests.style["display"] = "block";
  485. }
  486. }
  487. clearmaprequests.style["right"] = "306px";
  488. clearmaprequests.style["top"] = "57px";
  489. clearmaprequests.style["height"] = "23px";
  490. clearmaprequests.style["width"] = "47px";
  491. clearmaprequests.style["line-height"] = "23px";
  492. clearmaprequests.style["font-size"] = "14px";
  493. clearmaprequests.addEventListener("click",function(){
  494. requestedmaps = [];
  495. Gdocument.getElementById("maploadwindowstatustext").style["visibility"] = "inherit";
  496. Gdocument.getElementById("maploadwindowstatustext").textContent = "No Maps";
  497. while(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0){
  498. Gdocument.getElementById("maploadwindowmapscontainer").removeChild(Gdocument.getElementById("maploadwindowmapscontainer").firstChild);
  499. }
  500. });
  501. Gdocument.getElementById("maploadwindow").insertBefore(clearmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  502. scope.refreshmaprequests = Gdocument.createElement("div");
  503. refreshmaprequests.id = "refreshmaprequests";
  504. refreshmaprequests.classList.value = "brownButton brownButton_classic buttonShadow";
  505. refreshmaprequests.textContent = "Refresh";
  506. refreshmaprequests.style["position"] = "absolute";
  507. refreshmaprequests.style["display"] = "none";
  508. if(typeof(ishost)!='undefined'){
  509. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  510. refreshmaprequests.style["display"] = "block";
  511. }
  512. }
  513. refreshmaprequests.style["right"] = "357px";
  514. refreshmaprequests.style["top"] = "57px";
  515. refreshmaprequests.style["height"] = "23px";
  516. refreshmaprequests.style["width"] = "47px";
  517. refreshmaprequests.style["line-height"] = "23px";
  518. refreshmaprequests.style["font-size"] = "14px";
  519. refreshmaprequests.addEventListener("click",function(){
  520. searchrequested = 1;
  521. Gdocument.getElementById("maploadtypedropdowntitle").click();
  522. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  523. dropdownrequested.style["display"] = "none";
  524. clearmaprequests.style["display"] = "block";
  525. refreshmaprequests.style["display"] = "block";
  526. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  527. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  528. Gdocument.getElementById("maploadtypedropdownoption10").click();
  529. });
  530. Gdocument.getElementById("maploadwindow").insertBefore(refreshmaprequests,Gdocument.getElementById("maploadwindowsearchinput"));
  531. scope.dropdownrequested = Gdocument.createElement("div");
  532. dropdownrequested.classList = "dropdown-option dropdown_classic";
  533. dropdownrequested.style["display"] = "none";
  534. dropdownrequested.id = "maploadtypedropdowntitlerequested";
  535. if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "block"){
  536. dropdownrequested.style["display"] = "block";
  537. }
  538. dropdownrequested.textContent = "MAP REQUESTS";
  539. dropdownrequested.onclick = function(){
  540. searchrequested = 1;
  541. Gdocument.getElementById("maploadtypedropdowntitle").click();
  542. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  543. dropdownrequested.style["display"] = "none";
  544. clearmaprequests.style["display"] = "block";
  545. refreshmaprequests.style["display"] = "block";
  546. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  547. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  548. Gdocument.getElementById("maploadtypedropdownoption10").click();
  549. };
  550. (new MutationObserver(function(){if(Gdocument.getElementById("maploadtypedropdownoption10").style["display"] == "none"){ dropdownrequested.style["display"] = "none"; clearmaprequests.style["display"] = "none";refreshmaprequests.style["display"] = "none"; } else{ dropdownrequested.style["display"] = "block";}})).observe(Gdocument.getElementById("maploadtypedropdownoption10"),{attributes:true,childList:true});
  551. Gdocument.getElementById("maploadtypedropdown").insertBefore(dropdownrequested,Gdocument.getElementById("maploadtypedropdownoption1"));
  552. Gdocument.getElementById("maploadwindowmapscontainer").__defineGetter__("clientHeight",function(){if(Gdocument.getElementById("maploadtypedropdowntitle").textContent != "MAP REQUESTS"){return Gdocument.getElementById("maploadwindowmapscontainer").getClientRects()[0].height;}else{return 0;}});
  553. };
  554. scope.sandboxonclick = function(){
  555. Gdocument.getElementById("roomlistrefreshbutton").click();
  556. Gdocument.getElementById("roomlistcreatebutton").click();
  557. sandboxon = true;
  558. };
  559. scope.checkboxclearbuttononclick = function(){
  560. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  561. var e = true;
  562. for(var i = 0; i<classes.length;i++){
  563. if(classes[i].checked == true){
  564. e = false
  565. }
  566. classes[i].checked = false;
  567. }
  568. if(e){
  569. for(var i = 0; i<classes.length;i++){
  570. classes[i].checked = true;
  571. }
  572. }
  573. };
  574. Gdocument.getElementById("ingamechatcontent").__defineGetter__("childElementCount",function(){return this.children.length/50;});
  575. if(Gdocument.getElementById("classic_mid_sandbox")==null){
  576. Gdocument.getElementById("roomlistrefreshbutton").click();
  577. scope.sandboxbutton = Gdocument.createElement("div");
  578. sandboxbutton.id = "classic_mid_sandbox";
  579. sandboxbutton.classList.value = "brownButton brownButton_classic classic_mid_buttons";
  580. sandboxbutton.textContent = "Sandbox";
  581. sandboxbutton.addEventListener("click",sandboxonclick);
  582. Gdocument.getElementById("classic_mid").insertBefore(sandboxbutton,Gdocument.getElementById("classic_mid_news"));
  583. }
  584. if(Gdocument.getElementById("clearallcheckboxes")==null){
  585. scope.checkboxclearbutton = Gdocument.createElement("div");
  586. checkboxclearbutton.id = "clearallcheckboxes";
  587. checkboxclearbutton.classList.value = "brownButton brownButton_classic buttonShadow";
  588. checkboxclearbutton.textContent = "On/Off";
  589. checkboxclearbutton.style["position"] = "absolute";
  590. checkboxclearbutton.style["display"] = "none";
  591. if(typeof(ishost)!='undefined'){
  592. if(ishost && stopquickplay == 0){
  593. checkboxclearbutton.style["display"] = "block";
  594. }
  595. }
  596. checkboxclearbutton.style["right"] = "255px";
  597. checkboxclearbutton.style["top"] = "57px";
  598. checkboxclearbutton.style["height"] = "23px";
  599. checkboxclearbutton.style["width"] = "47px";
  600. checkboxclearbutton.style["line-height"] = "23px";
  601. checkboxclearbutton.style["font-size"] = "13px";
  602. checkboxclearbutton.addEventListener("click",checkboxclearbuttononclick);
  603. Gdocument.getElementById("maploadwindow").insertBefore(checkboxclearbutton,Gdocument.getElementById("maploadwindowsearchinput"));
  604. }
  605. scope.holdloadbuttonTimeout = [];
  606. scope.holdloadbutton = function(){
  607. var scrollcount = 0;
  608. var mapwindow = Gdocument.getElementById("maploadwindowmapscontainer");
  609. mapwindow.scroll(0,mapwindow.scrollHeight);
  610. };
  611. if(Gdocument.getElementById("mapwindowloadall")==null){
  612. scope.loadall = Gdocument.createElement("div");
  613. loadall.id = "mapwindowloadall";
  614. loadall.classList.value = "brownButton brownButton_classic buttonShadow";
  615. loadall.textContent = "Load";
  616. loadall.style["position"] = "absolute";
  617. loadall.style["display"] = "block";
  618. loadall.style["left"] = "204px";
  619. loadall.style["top"] = "57px";
  620. loadall.style["height"] = "23px";
  621. loadall.style["width"] = "34px";
  622. loadall.style["line-height"] = "23px";
  623. loadall.style["font-size"] = "12px";
  624. var repeat = function(){holdloadbutton();holdloadbuttonTimeout.push(setTimeout(repeat,25));};
  625. loadall.onmousedown = function(){repeat();};
  626. loadall.onmouseup = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  627. loadall.onmouseout = function(){for(var i = 0; i<holdloadbuttonTimeout.length; i++){clearTimeout(holdloadbuttonTimeout[i]);}};
  628. Gdocument.getElementById("maploadwindow").insertBefore(loadall,Gdocument.getElementById("maploadwindowsearchinput"));
  629. }
  630. if(Gdocument.getElementById("BonkCommandsDebuggerContainer")==null){
  631. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  632. scope.debuggermenu = Gdocument.createElement("div");
  633. debuggermenu.id = "BonkCommandsDebuggerContainer";
  634. debuggermenu.style["position"] = "absolute";
  635. debuggermenu.style["display"] = "none";
  636. if(typeof(debuggeropen)!='undefined'){
  637. if(debuggeropen){
  638. debuggermenu.style["display"] = "block";
  639. }
  640. }
  641. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  642. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  643. debuggermenu.style["background"] = "rgb(26, 39, 51)";
  644. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  645. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  646. scope.logmenu = Gdocument.createElement("div");
  647. logmenu.id = "BonkCommandsWebSocketLog";
  648. logmenu.style["position"] = "absolute";
  649. logmenu.style["width"] = width.toString()+"px";
  650. logmenu.style["height"] = height.toString()+"px";
  651. logmenu.style["top"] = "80px";
  652. logmenu.style["left"] = "10px";
  653. logmenu.style["background"] = "rgb(207, 216, 220)";
  654. scope.logmenutopleft = Gdocument.createElement("div");
  655. logmenutopleft.id = "BonkCommandsWebSocketLog";
  656. logmenutopleft.style["position"] = "absolute";
  657. logmenutopleft.textContent = "Sending";
  658. logmenutopleft.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  659. logmenutopleft.style["width"] = (width/2).toString()+"px";
  660. logmenutopleft.style["height"] = "30px";
  661. logmenutopleft.style["top"] = "-30px";
  662. logmenutopleft.style["background"] = "rgb(0, 150, 136)";
  663. logmenu.appendChild(logmenutopleft);
  664. scope.logmenutopright = Gdocument.createElement("div");
  665. logmenutopright.id = "BonkCommandsWebSocketLog";
  666. logmenutopright.style["position"] = "absolute";
  667. logmenutopright.textContent = "Recieving";
  668. logmenutopright.classList = "newbonklobby_boxtop newbonklobby_boxtop_classic";
  669. logmenutopright.style["width"] = (width/2).toString()+"px";
  670. logmenutopright.style["height"] = "30px";
  671. logmenutopright.style["left"] = (width/2).toString()+"px";
  672. logmenutopright.style["top"] = "-30px";
  673. logmenutopright.style["background"] = "rgb(0, 150, 136)";
  674. logmenu.appendChild(logmenutopright);
  675. scope.logmenutable = Gdocument.createElement("table");
  676. logmenutable.id = "BonkCommandsWebSocketTable";
  677. logmenutable.style["position"] = "absolute";
  678. logmenutable.style["border-spacing"] = "0px";
  679. logmenutable.style["font-size"] = "12px";
  680. logmenutable.style["display"] = "table-cell";
  681. logmenutable.style["width"] = "50%";
  682. logmenutable.style["height"] = "100%";
  683. logmenutable.style["table-layout"] = "fixed";
  684. logmenutable.style["overflow-y"] = "scroll";
  685. scope.logmenutable2 = Gdocument.createElement("table");
  686. logmenutable2.id = "BonkCommandsWebSocketTable2";
  687. logmenutable2.style["position"] = "absolute";
  688. logmenutable2.style["width"] = "50%";
  689. logmenutable2.style["left"] = "50%";
  690. logmenutable2.style["font-size"] = "12px";
  691. logmenutable2.style["display"] = "table-cell";
  692. logmenutable2.style["height"] = "100%";
  693. logmenutable2.style["table-layout"] = "fixed";
  694. logmenutable2.style["overflow-y"] = "scroll";
  695. logmenutable2.style["border-spacing"] = "0px";
  696. scope.leftsync = false;
  697. scope.rightsync = false;
  698. logmenutable2.onscroll = function(){
  699. if(!leftsync){
  700. rightsync = true;
  701. logmenutable.scrollTop = this.scrollTop;
  702. }
  703. else{
  704. leftsync = false;
  705. }
  706. };
  707. logmenutable.onscroll = function(){
  708. if(!rightsync){
  709. leftsync = true;
  710. logmenutable2.scrollTop = this.scrollTop;
  711. }
  712. else{
  713. rightsync = false
  714. }
  715. };
  716. logmenu.appendChild(logmenutable);
  717. logmenu.appendChild(logmenutable2);
  718. debuggermenu.appendChild(logmenu);
  719. scope.debuggermenuclose = Gdocument.createElement("div");
  720. debuggermenuclose.id = "debuggerclose";
  721. debuggermenuclose.classList = "windowCloseButton brownButton brownButton_classic buttonShadow";
  722. debuggermenuclose.style["position"] = "absolute";
  723. debuggermenuclose.style["top"] = "40px";
  724. debuggermenuclose.style["right"] = "5px";
  725. debuggermenuclose.onclick = function(){debuggeropen = false;debuggermenu.style["display"] = "none";Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  726. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";};
  727. debuggermenu.appendChild(debuggermenuclose);
  728. scope.debuggerform = Gdocument.createElement("form");
  729. debuggerform.autocomplete = "off";
  730. scope.debuggerinput = Gdocument.createElement("input");
  731. debuggerinput.style["position"] = "absolute";
  732. debuggerinput.style["width"] = width.toString()+"px";
  733. debuggerinput.style["left"] = "10px";
  734. debuggerinput.style["top"] = (height+90).toString()+"px";
  735. debuggerinput.style["font-size"] = "12px";
  736. debuggerinput.style["height"] = "20px";
  737. debuggerform.appendChild(debuggerinput);
  738. scope.debuggersendrecieve = Gdocument.createElement("div");
  739. debuggersendrecieve.style["position"] = "absolute";
  740. debuggersendrecieve.style["width"] = "140px";
  741. debuggersendrecieve.style["left"] = "10px";
  742. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  743. debuggersendrecieve.style["font-size"] = "15px";
  744. debuggersendrecieve.style["height"] = "20px";
  745. debuggersendrecieve.classList = "brownButton brownButton_classic buttonShadow";
  746. debuggersendrecieve.textContent = "Send";
  747. debuggersendrecieve.value = 0;
  748. debuggersendrecieve.onclick = function(){if(this.value == 0){this.textContent = "Recieve";this.value = 1;}else{this.textContent = "Send";this.value = 0;}};
  749. debuggermenu.appendChild(debuggersendrecieve);
  750. scope.debuggerpausebutton = Gdocument.createElement("div");
  751. debuggerpausebutton.style["position"] = "absolute";
  752. debuggerpausebutton.style["width"] = "140px";
  753. debuggerpausebutton.style["left"] = "10px";
  754. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  755. debuggerpausebutton.style["font-size"] = "15px";
  756. debuggerpausebutton.style["height"] = "20px";
  757. debuggerpausebutton.classList = "brownButton brownButton_classic buttonShadow";
  758. debuggerpausebutton.textContent = "Pause";
  759. debuggerpausebutton.value = 0;
  760. debuggerpausebutton.onclick = function(){if(this.value == 0){this.textContent = "Play";this.value = 1;wsslogpaused = true}else{this.textContent = "Pause";this.value = 0;wsslogpaused = false;}};
  761. debuggermenu.appendChild(debuggerpausebutton);
  762. scope.debuggereval = Gdocument.createElement("input");
  763. debuggereval.style["position"] = "absolute";
  764. debuggereval.style["width"] = (width-150).toString()+"px";
  765. debuggereval.style["right"] = "10px";
  766. debuggereval.style["top"] = (height+120).toString()+"px";
  767. debuggereval.style["font-size"] = "12px";
  768. debuggereval.style["height"] = "20px";
  769. debuggereval.addEventListener("keypress",function(e){if(e.repeat){return;}if(e.code == "Enter" && this.value.length>0){if(debuggersendrecieve.value == 0){SEND(this.value);}else{RECIEVE(this.value);}}});
  770. debuggerform.appendChild(debuggereval);
  771. debuggermenu.appendChild(debuggerform);
  772. Gdocument.getElementById("newbonkgamecontainer").appendChild(debuggermenu);
  773. }
  774. scope.ISdecode = function(rawdata) {
  775. rawdata_caseflipped = "";
  776. for (i = 0; i < rawdata.length; i++) {
  777. if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toLowerCase()) {
  778. rawdata_caseflipped += rawdata.charAt(i).toUpperCase();
  779. } else if (i <= 100 && rawdata.charAt(i) === rawdata.charAt(i).toUpperCase()) {
  780. rawdata_caseflipped += rawdata.charAt(i).toLowerCase();
  781. } else {
  782. rawdata_caseflipped += rawdata.charAt(i);
  783. }
  784. }
  785. data_deLZd = LZString.decompressFromEncodedURIComponent(rawdata_caseflipped);
  786. databuffer = bytebuffer.fromBase64(data_deLZd);
  787. data = ISpsonpair.decode(databuffer.buffer);
  788. return data;
  789. };
  790. scope.ISencode = function(obj) {
  791. data = ISpsonpair.encode(obj);
  792. b64 = data.toBase64();
  793. lzd = LZString.compressToEncodedURIComponent(b64);
  794. caseflipped = "";
  795. for (i = 0; i < lzd.length; i++) {
  796. if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toLowerCase()) {
  797. caseflipped += lzd.charAt(i).toUpperCase();
  798. } else if (i <= 100 && lzd.charAt(i) === lzd.charAt(i).toUpperCase()) {
  799. caseflipped += lzd.charAt(i).toLowerCase();
  800. } else {
  801. caseflipped += lzd.charAt(i);
  802. }
  803. }
  804. return caseflipped;
  805. };
  806. scope.decodeIS = function(x){
  807. return ISdecode(x);
  808. };
  809. scope.encodeIS = function(x){
  810. return ISencode(x);
  811. };
  812. scope.encodeToDatabase = function (W2A) {
  813. var M3n = [arguments];
  814. M3n[1] = new bytebuffer2;
  815. M3n[9] = M3n[0][0].physics;
  816. M3n[0][0].v = 15;
  817. M3n[1].writeShort(M3n[0][0].v);
  818. M3n[1].writeBoolean(M3n[0][0].s.re);
  819. M3n[1].writeBoolean(M3n[0][0].s.nc);
  820. M3n[1].writeShort(M3n[0][0].s.pq);
  821. M3n[1].writeFloat(M3n[0][0].s.gd);
  822. M3n[1].writeBoolean(M3n[0][0].s.fl);
  823. M3n[1].writeUTF(M3n[0][0].m.rxn);
  824. M3n[1].writeUTF(M3n[0][0].m.rxa);
  825. M3n[1].writeUint(M3n[0][0].m.rxid);
  826. M3n[1].writeShort(M3n[0][0].m.rxdb);
  827. M3n[1].writeUTF(M3n[0][0].m.n);
  828. M3n[1].writeUTF(M3n[0][0].m.a);
  829. M3n[1].writeUint(M3n[0][0].m.vu);
  830. M3n[1].writeUint(M3n[0][0].m.vd);
  831. M3n[1].writeShort(M3n[0][0].m.cr.length);
  832. for (
  833. M3n[84] = 0;
  834. M3n[84] < M3n[0][0].m.cr.length;
  835. M3n[84]++
  836. ) {
  837. M3n[1].writeUTF(M3n[0][0].m.cr[M3n[84]]);
  838. }
  839. M3n[1].writeUTF(M3n[0][0].m.mo);
  840. M3n[1].writeInt(M3n[0][0].m.dbid);
  841. M3n[1].writeBoolean(M3n[0][0].m.pub);
  842. M3n[1].writeInt(M3n[0][0].m.dbv);
  843. M3n[1].writeShort(M3n[9].ppm);
  844. M3n[1].writeShort(M3n[9].bro.length);
  845. for (M3n[17] = 0; M3n[17] < M3n[9].bro.length; M3n[17]++) {
  846. M3n[1].writeShort(M3n[9].bro[M3n[17]]);
  847. }
  848. M3n[1].writeShort(M3n[9].shapes.length);
  849. for (M3n[80] = 0; M3n[80] < M3n[9].shapes.length; M3n[80]++) {
  850. M3n[2] = M3n[9].shapes[M3n[80]];
  851. if (M3n[2].type == "bx") {
  852. M3n[1].writeShort(1);
  853. M3n[1].writeDouble(M3n[2].w);
  854. M3n[1].writeDouble(M3n[2].h);
  855. M3n[1].writeDouble(M3n[2].c[0]);
  856. M3n[1].writeDouble(M3n[2].c[1]);
  857. M3n[1].writeDouble(M3n[2].a);
  858. M3n[1].writeBoolean(M3n[2].sk);
  859. }
  860. if (M3n[2].type == "ci") {
  861. M3n[1].writeShort(2);
  862. M3n[1].writeDouble(M3n[2].r);
  863. M3n[1].writeDouble(M3n[2].c[0]);
  864. M3n[1].writeDouble(M3n[2].c[1]);
  865. M3n[1].writeBoolean(M3n[2].sk);
  866. }
  867. if (M3n[2].type == "po") {
  868. M3n[1].writeShort(3);
  869. M3n[1].writeDouble(M3n[2].s);
  870. M3n[1].writeDouble(M3n[2].a);
  871. M3n[1].writeDouble(M3n[2].c[0]);
  872. M3n[1].writeDouble(M3n[2].c[1]);
  873. M3n[1].writeShort(M3n[2].v.length);
  874. for (M3n[61] = 0; M3n[61] < M3n[2].v.length; M3n[61]++) {
  875. M3n[1].writeDouble(M3n[2].v[M3n[61]][0]);
  876. M3n[1].writeDouble(M3n[2].v[M3n[61]][1]);
  877. }
  878. }
  879. }
  880. M3n[1].writeShort(M3n[9].fixtures.length);
  881. for (M3n[20] = 0; M3n[20] < M3n[9].fixtures.length; M3n[20]++) {
  882. M3n[7] = M3n[9].fixtures[M3n[20]];
  883. M3n[1].writeShort(M3n[7].sh);
  884. M3n[1].writeUTF(M3n[7].n);
  885. if (M3n[7].fr === null) {
  886. M3n[1].writeDouble(Number.MAX_VALUE);
  887. } else {
  888. M3n[1].writeDouble(M3n[7].fr);
  889. }
  890. if (M3n[7].fp === null) {
  891. M3n[1].writeShort(0);
  892. }
  893. if (M3n[7].fp === false) {
  894. M3n[1].writeShort(1);
  895. }
  896. if (M3n[7].fp === true) {
  897. M3n[1].writeShort(2);
  898. }
  899. if (M3n[7].re === null) {
  900. M3n[1].writeDouble(Number.MAX_VALUE);
  901. } else {
  902. M3n[1].writeDouble(M3n[7].re);
  903. }
  904. if (M3n[7].de === null) {
  905. M3n[1].writeDouble(Number.MAX_VALUE);
  906. } else {
  907. M3n[1].writeDouble(M3n[7].de);
  908. }
  909. M3n[1].writeUint(M3n[7].f);
  910. M3n[1].writeBoolean(M3n[7].d);
  911. M3n[1].writeBoolean(M3n[7].np);
  912. M3n[1].writeBoolean(M3n[7].ng);
  913. M3n[1].writeBoolean(M3n[7].ig);
  914. }
  915. M3n[1].writeShort(M3n[9].bodies.length);
  916. for (M3n[37] = 0; M3n[37] < M3n[9].bodies.length; M3n[37]++) {
  917. M3n[4] = M3n[9].bodies[M3n[37]];
  918. M3n[1].writeUTF(M3n[4].type);
  919. M3n[1].writeUTF(M3n[4].n);
  920. M3n[1].writeDouble(M3n[4].p[0]);
  921. M3n[1].writeDouble(M3n[4].p[1]);
  922. M3n[1].writeDouble(M3n[4].a);
  923. M3n[1].writeDouble(M3n[4].fric);
  924. M3n[1].writeBoolean(M3n[4].fricp);
  925. M3n[1].writeDouble(M3n[4].re);
  926. M3n[1].writeDouble(M3n[4].de);
  927. M3n[1].writeDouble(M3n[4].lv[0]);
  928. M3n[1].writeDouble(M3n[4].lv[1]);
  929. M3n[1].writeDouble(M3n[4].av);
  930. M3n[1].writeDouble(M3n[4].ld);
  931. M3n[1].writeDouble(M3n[4].ad);
  932. M3n[1].writeBoolean(M3n[4].fr);
  933. M3n[1].writeBoolean(M3n[4].bu);
  934. M3n[1].writeDouble(M3n[4].cf.x);
  935. M3n[1].writeDouble(M3n[4].cf.y);
  936. M3n[1].writeDouble(M3n[4].cf.ct);
  937. M3n[1].writeBoolean(M3n[4].cf.w);
  938. M3n[1].writeShort(M3n[4].f_c);
  939. M3n[1].writeBoolean(M3n[4].f_1);
  940. M3n[1].writeBoolean(M3n[4].f_2);
  941. M3n[1].writeBoolean(M3n[4].f_3);
  942. M3n[1].writeBoolean(M3n[4].f_4);
  943. M3n[1].writeBoolean(M3n[4].f_p);
  944. M3n[1].writeBoolean(M3n[4].fz.on);
  945. if (M3n[4].fz.on) {
  946. M3n[1].writeDouble(M3n[4].fz.x);
  947. M3n[1].writeDouble(M3n[4].fz.y);
  948. M3n[1].writeBoolean(M3n[4].fz.d);
  949. M3n[1].writeBoolean(M3n[4].fz.p);
  950. M3n[1].writeBoolean(M3n[4].fz.a);
  951. M3n[1].writeShort(M3n[4].fz.t);
  952. + M3n[1].writeDouble(M3n[4].fz.cf);
  953. }
  954. M3n[1].writeShort(M3n[4].fx.length);
  955. for (M3n[28] = 0; M3n[28] < M3n[4].fx.length; M3n[28]++) {
  956. M3n[1].writeShort(M3n[4].fx[M3n[28]]);
  957. }
  958. }
  959. M3n[1].writeShort(M3n[0][0].spawns.length);
  960. for (
  961. M3n[30] = 0;
  962. M3n[30] < M3n[0][0].spawns.length;
  963. M3n[30]++
  964. ) {
  965. M3n[6] = M3n[0][0].spawns[M3n[30]];
  966. M3n[1].writeDouble(M3n[6].x);
  967. M3n[1].writeDouble(M3n[6].y);
  968. M3n[1].writeDouble(M3n[6].xv);
  969. M3n[1].writeDouble(M3n[6].yv);
  970. M3n[1].writeShort(M3n[6].priority);
  971. M3n[1].writeBoolean(M3n[6].r);
  972. M3n[1].writeBoolean(M3n[6].f);
  973. M3n[1].writeBoolean(M3n[6].b);
  974. M3n[1].writeBoolean(M3n[6].gr);
  975. M3n[1].writeBoolean(M3n[6].ye);
  976. M3n[1].writeUTF(M3n[6].n);
  977. }
  978. M3n[1].writeShort(M3n[0][0].capZones.length);
  979. for (
  980. M3n[74] = 0;
  981. M3n[74] < M3n[0][0].capZones.length;
  982. M3n[74]++
  983. ) {
  984. M3n[3] = M3n[0][0].capZones[M3n[74]];
  985. M3n[1].writeUTF(M3n[3].n);
  986. M3n[1].writeDouble(M3n[3].l);
  987. M3n[1].writeShort(M3n[3].i);
  988. M3n[1].writeShort(M3n[3].ty);
  989. }
  990. M3n[1].writeShort(M3n[9].joints.length);
  991. for (M3n[89] = 0; M3n[89] < M3n[9].joints.length; M3n[89]++) {
  992. M3n[5] = M3n[9].joints[M3n[89]];
  993. if (M3n[5].type == "rv") {
  994. M3n[1].writeShort(1);
  995. M3n[1].writeDouble(M3n[5].d.la);
  996. M3n[1].writeDouble(M3n[5].d.ua);
  997. M3n[1].writeDouble(M3n[5].d.mmt);
  998. M3n[1].writeDouble(M3n[5].d.ms);
  999. M3n[1].writeBoolean(M3n[5].d.el);
  1000. M3n[1].writeBoolean(M3n[5].d.em);
  1001. M3n[1].writeDouble(M3n[5].aa[0]);
  1002. M3n[1].writeDouble(M3n[5].aa[1]);
  1003. }
  1004. if (M3n[5].type == "d") {
  1005. M3n[1].writeShort(2);
  1006. M3n[1].writeDouble(M3n[5].d.fh);
  1007. M3n[1].writeDouble(M3n[5].d.dr);
  1008. M3n[1].writeDouble(M3n[5].aa[0]);
  1009. M3n[1].writeDouble(M3n[5].aa[1]);
  1010. M3n[1].writeDouble(M3n[5].ab[0]);
  1011. M3n[1].writeDouble(M3n[5].ab[1]);
  1012. }
  1013. if (M3n[5].type == "lpj") {
  1014. M3n[1].writeShort(3);
  1015. M3n[1].writeDouble(M3n[5].pax);
  1016. M3n[1].writeDouble(M3n[5].pay);
  1017. M3n[1].writeDouble(M3n[5].pa);
  1018. M3n[1].writeDouble(M3n[5].pf);
  1019. M3n[1].writeDouble(M3n[5].pl);
  1020. M3n[1].writeDouble(M3n[5].pu);
  1021. M3n[1].writeDouble(M3n[5].plen);
  1022. M3n[1].writeDouble(M3n[5].pms);
  1023. }
  1024. if (M3n[5].type == "lsj") {
  1025. M3n[1].writeShort(4);
  1026. M3n[1].writeDouble(M3n[5].sax);
  1027. M3n[1].writeDouble(M3n[5].say);
  1028. M3n[1].writeDouble(M3n[5].sf);
  1029. M3n[1].writeDouble(M3n[5].slen);
  1030. }
  1031. if(M3n[5].type == "g"){
  1032. M3n[1].writeShort(5);
  1033. M3n[1].writeUTF(M3n[5].n);
  1034. M3n[1].writeShort(M3n[5].ja);
  1035. M3n[1].writeShort(M3n[5].jb);
  1036. M3n[1].writeDouble(M3n[5].r);
  1037. }
  1038. if(M3n[5].type != "g"){
  1039. M3n[1].writeShort(M3n[5].ba);
  1040. M3n[1].writeShort(M3n[5].bb);
  1041. M3n[1].writeBoolean(M3n[5].d.cc);
  1042. M3n[1].writeDouble(M3n[5].d.bf);
  1043. M3n[1].writeBoolean(M3n[5].d.dl);
  1044. }
  1045. }
  1046. M3n[32] = M3n[1].toBase64();
  1047. M3n[77] = LZString.compressToEncodedURIComponent(M3n[32]);
  1048. return M3n[77];
  1049. };
  1050. scope.decodeFromDatabase = function (map) {
  1051. var F5W = [arguments];
  1052. var b64mapdata = LZString.decompressFromEncodedURIComponent(map);
  1053. var binaryReader = new bytebuffer2;
  1054. binaryReader.fromBase64(b64mapdata, false);
  1055. map = { v: 1, s: { re: false, nc: false, pq: 1, gd: 25, fl: false }, physics: { shapes: [], fixtures: [], bodies: [], bro: [], joints: [], ppm: 12, }, spawns: [], capZones: [], m: { a: "noauthor", n: "noname", dbv: 2, dbid: -1, authid: -1, date: "", rxid: 0, rxn: "", rxa: "", rxdb: 1, cr: [], pub: false, mo: "", }};
  1056. map.physics = map.physics;
  1057. map.v = binaryReader.readShort();
  1058. if (map.v > 15) {
  1059. throw new Error("Future map version, please refresh page");
  1060. }
  1061. map.s.re = binaryReader.readBoolean();
  1062. map.s.nc = binaryReader.readBoolean();
  1063. if (map.v >= 3) {
  1064. map.s.pq = binaryReader.readShort();
  1065. }
  1066. if (map.v >= 4 && map.v <= 12) {
  1067. map.s.gd = binaryReader.readShort();
  1068. } else if (map.v >= 13) {
  1069. map.s.gd = binaryReader.readFloat();
  1070. }
  1071. if (map.v >= 9) {
  1072. map.s.fl = binaryReader.readBoolean();
  1073. }
  1074. map.m.rxn = binaryReader.readUTF();
  1075. map.m.rxa = binaryReader.readUTF();
  1076. map.m.rxid = binaryReader.readUint();
  1077. map.m.rxdb = binaryReader.readShort();
  1078. map.m.n = binaryReader.readUTF();
  1079. map.m.a = binaryReader.readUTF();
  1080. if (map.v >= 10) {
  1081. map.m.vu = binaryReader.readUint();
  1082. map.m.vd = binaryReader.readUint();
  1083. }
  1084. if (map.v >= 4) {
  1085. F5W[7] = binaryReader.readShort();
  1086. for (F5W[83] = 0; F5W[83] < F5W[7]; F5W[83]++) {
  1087. map.m.cr.push(binaryReader.readUTF());
  1088. }
  1089. }
  1090. if (map.v >= 5) {
  1091. map.m.mo = binaryReader.readUTF();
  1092. map.m.dbid = binaryReader.readInt();
  1093. }
  1094. if (map.v >= 7) {
  1095. map.m.pub = binaryReader.readBoolean();
  1096. }
  1097. if (map.v >= 8) {
  1098. map.m.dbv = binaryReader.readInt();
  1099. }
  1100. map.physics.ppm = binaryReader.readShort();
  1101. F5W[4] = binaryReader.readShort();
  1102. for (F5W[15] = 0; F5W[15] < F5W[4]; F5W[15]++) {
  1103. map.physics.bro[F5W[15]] = binaryReader.readShort();
  1104. }
  1105. F5W[6] = binaryReader.readShort();
  1106. for (F5W[28] = 0; F5W[28] < F5W[6]; F5W[28]++) {
  1107. F5W[5] = binaryReader.readShort();
  1108. if (F5W[5] == 1) {
  1109. map.physics.shapes[F5W[28]] = { type: "bx", w: 10, h: 40, c: [0, 0], a: 0.0, sk: false };
  1110. map.physics.shapes[F5W[28]].w = binaryReader.readDouble();
  1111. map.physics.shapes[F5W[28]].h = binaryReader.readDouble();
  1112. map.physics.shapes[F5W[28]].c = [
  1113. binaryReader.readDouble(),
  1114. binaryReader.readDouble(),
  1115. ];
  1116. map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
  1117. map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
  1118. }
  1119. if (F5W[5] == 2) {
  1120. map.physics.shapes[F5W[28]] = { type: "ci", r: 25, c: [0, 0], sk: false };
  1121. map.physics.shapes[F5W[28]].r = binaryReader.readDouble();
  1122. map.physics.shapes[F5W[28]].c = [
  1123. binaryReader.readDouble(),
  1124. binaryReader.readDouble(),
  1125. ];
  1126. map.physics.shapes[F5W[28]].sk = binaryReader.readBoolean();
  1127. }
  1128. if (F5W[5] == 3) {
  1129. map.physics.shapes[F5W[28]] = { type: "po", v: [], s: 1, a: 0, c: [0, 0] };
  1130. map.physics.shapes[F5W[28]].s = binaryReader.readDouble();
  1131. map.physics.shapes[F5W[28]].a = binaryReader.readDouble();
  1132. map.physics.shapes[F5W[28]].c = [
  1133. binaryReader.readDouble(),
  1134. binaryReader.readDouble(),
  1135. ];
  1136. F5W[74] = binaryReader.readShort();
  1137. map.physics.shapes[F5W[28]].v = [];
  1138. for (F5W[27] = 0; F5W[27] < F5W[74]; F5W[27]++) {
  1139. map.physics.shapes[F5W[28]].v.push([
  1140. binaryReader.readDouble(),
  1141. binaryReader.readDouble(),
  1142. ]);
  1143. }
  1144. }
  1145. }
  1146. F5W[71] = binaryReader.readShort();
  1147. for (F5W[17] = 0; F5W[17] < F5W[71]; F5W[17]++) {
  1148. map.physics.fixtures[F5W[17]] = { sh: 0, n: "Def Fix", fr: 0.3, fp: null, re: 0.8, de: 0.3, f: 0x4f7cac, d: false, np: false, ng: false };
  1149. map.physics.fixtures[F5W[17]].sh = binaryReader.readShort();
  1150. map.physics.fixtures[F5W[17]].n = binaryReader.readUTF();
  1151. map.physics.fixtures[F5W[17]].fr = binaryReader.readDouble();
  1152. if (map.physics.fixtures[F5W[17]].fr == Number.MAX_VALUE) {
  1153. map.physics.fixtures[F5W[17]].fr = null;
  1154. }
  1155. F5W[12] = binaryReader.readShort();
  1156. if (F5W[12] == 0) {
  1157. map.physics.fixtures[F5W[17]].fp = null;
  1158. }
  1159. if (F5W[12] == 1) {
  1160. map.physics.fixtures[F5W[17]].fp = false;
  1161. }
  1162. if (F5W[12] == 2) {
  1163. map.physics.fixtures[F5W[17]].fp = true;
  1164. }
  1165. map.physics.fixtures[F5W[17]].re = binaryReader.readDouble();
  1166. if (map.physics.fixtures[F5W[17]].re == Number.MAX_VALUE) {
  1167. map.physics.fixtures[F5W[17]].re = null;
  1168. }
  1169. map.physics.fixtures[F5W[17]].de = binaryReader.readDouble();
  1170. if (map.physics.fixtures[F5W[17]].de == Number.MAX_VALUE) {
  1171. map.physics.fixtures[F5W[17]].de = null;
  1172. }
  1173. map.physics.fixtures[F5W[17]].f = binaryReader.readUint();
  1174. map.physics.fixtures[F5W[17]].d = binaryReader.readBoolean();
  1175. map.physics.fixtures[F5W[17]].np = binaryReader.readBoolean();
  1176. if (map.v >= 11) {
  1177. map.physics.fixtures[F5W[17]].ng = binaryReader.readBoolean();
  1178. }
  1179. if (map.v >= 12) {
  1180. map.physics.fixtures[F5W[17]].ig = binaryReader.readBoolean();
  1181. }
  1182. }
  1183. F5W[63] = binaryReader.readShort();
  1184. for (F5W[52] = 0; F5W[52] < F5W[63]; F5W[52]++) {
  1185. map.physics.bodies[F5W[52]] ={ type: "s", n: "Unnamed", p: [0, 0], a: 0, fric: 0.3, fricp: false, re: 0.8, de: 0.3, lv: [0, 0], av: 0, ld: 0, ad: 0, fr: false, bu: false, cf: { x: 0, y: 0, w: true, ct: 0 }, fx: [], f_c: 1, f_p: true, f_1: true, f_2: true, f_3: true, f_4: true, fz: { on: false, x: 0, y: 0, d: true, p: true, a: true, t: 0, cf: 0}};
  1186. map.physics.bodies[F5W[52]].type = binaryReader.readUTF();
  1187. map.physics.bodies[F5W[52]].n = binaryReader.readUTF();
  1188. map.physics.bodies[F5W[52]].p = [binaryReader.readDouble(), binaryReader.readDouble()];
  1189. map.physics.bodies[F5W[52]].a = binaryReader.readDouble();
  1190. map.physics.bodies[F5W[52]].fric = binaryReader.readDouble();
  1191. map.physics.bodies[F5W[52]].fricp = binaryReader.readBoolean();
  1192. map.physics.bodies[F5W[52]].re = binaryReader.readDouble();
  1193. map.physics.bodies[F5W[52]].de = binaryReader.readDouble();
  1194. map.physics.bodies[F5W[52]].lv = [
  1195. binaryReader.readDouble(),
  1196. binaryReader.readDouble(),
  1197. ];
  1198. map.physics.bodies[F5W[52]].av = binaryReader.readDouble();
  1199. map.physics.bodies[F5W[52]].ld = binaryReader.readDouble();
  1200. map.physics.bodies[F5W[52]].ad = binaryReader.readDouble();
  1201. map.physics.bodies[F5W[52]].fr = binaryReader.readBoolean();
  1202. map.physics.bodies[F5W[52]].bu = binaryReader.readBoolean();
  1203. map.physics.bodies[F5W[52]].cf.x = binaryReader.readDouble();
  1204. map.physics.bodies[F5W[52]].cf.y = binaryReader.readDouble();
  1205. map.physics.bodies[F5W[52]].cf.ct = binaryReader.readDouble();
  1206. map.physics.bodies[F5W[52]].cf.w = binaryReader.readBoolean();
  1207. map.physics.bodies[F5W[52]].f_c = binaryReader.readShort();
  1208. map.physics.bodies[F5W[52]].f_1 = binaryReader.readBoolean();
  1209. map.physics.bodies[F5W[52]].f_2 = binaryReader.readBoolean();
  1210. map.physics.bodies[F5W[52]].f_3 = binaryReader.readBoolean();
  1211. map.physics.bodies[F5W[52]].f_4 = binaryReader.readBoolean();
  1212. if (map.v >= 2) {
  1213. map.physics.bodies[F5W[52]].f_p = binaryReader.readBoolean();
  1214. }
  1215. if (map.v >= 14) {
  1216. map.physics.bodies[F5W[52]].fz.on = binaryReader.readBoolean();
  1217. if (map.physics.bodies[F5W[52]].fz.on) {
  1218. map.physics.bodies[F5W[52]].fz.x = binaryReader.readDouble();
  1219. map.physics.bodies[F5W[52]].fz.y = binaryReader.readDouble();
  1220. map.physics.bodies[F5W[52]].fz.d = binaryReader.readBoolean();
  1221. map.physics.bodies[F5W[52]].fz.p = binaryReader.readBoolean();
  1222. map.physics.bodies[F5W[52]].fz.a = binaryReader.readBoolean();
  1223. if(map.v >= 15){
  1224. map.physics.bodies[F5W[52]].t = binaryReader.readShort();
  1225. map.physics.bodies[F5W[52]].cf = binaryReader.readDouble();
  1226. }
  1227. }
  1228. }
  1229. F5W[88] = binaryReader.readShort();
  1230. for (F5W[65] = 0; F5W[65] < F5W[88]; F5W[65]++) {
  1231. map.physics.bodies[F5W[52]].fx.push(binaryReader.readShort());
  1232. }
  1233. }
  1234. F5W[97] = binaryReader.readShort();
  1235. for (F5W[41] = 0; F5W[41] < F5W[97]; F5W[41]++) {
  1236. map.spawns[F5W[41]] = {"x":400,"y":300,"xv":0,"yv":0,"priority":5,"r":true,"f":true,"b":true,"gr":false,"ye":false,"n":"Spawn"};
  1237. F5W[35] = map.spawns[F5W[41]];
  1238. F5W[35].x = binaryReader.readDouble();
  1239. F5W[35].y = binaryReader.readDouble();
  1240. F5W[35].xv = binaryReader.readDouble();
  1241. F5W[35].yv = binaryReader.readDouble();
  1242. F5W[35].priority = binaryReader.readShort();
  1243. F5W[35].r = binaryReader.readBoolean();
  1244. F5W[35].f = binaryReader.readBoolean();
  1245. F5W[35].b = binaryReader.readBoolean();
  1246. F5W[35].gr = binaryReader.readBoolean();
  1247. F5W[35].ye = binaryReader.readBoolean();
  1248. F5W[35].n = binaryReader.readUTF();
  1249. }
  1250. F5W[16] = binaryReader.readShort();
  1251. for (F5W[25] = 0; F5W[25] < F5W[16]; F5W[25]++) {
  1252. map.capZones[F5W[25]] = {"n":"Cap Zone","ty":1,"l":10,"i":-1};
  1253. map.capZones[F5W[25]].n = binaryReader.readUTF();
  1254. map.capZones[F5W[25]].l = binaryReader.readDouble();
  1255. map.capZones[F5W[25]].i = binaryReader.readShort();
  1256. if (map.v >= 6) {
  1257. map.capZones[F5W[25]].ty = binaryReader.readShort();
  1258. }
  1259. }
  1260. F5W[98] = binaryReader.readShort();
  1261. for (F5W[19] = 0; F5W[19] < F5W[98]; F5W[19]++) {
  1262. F5W[31] = binaryReader.readShort();
  1263. if (F5W[31] == 1) {
  1264. map.physics.joints[F5W[19]] = {"type":"rv","d":{"la":0,"ua":0,"mmt":0,"ms":0,"el":false,"em":false,"cc":false,"bf":0,"dl":true},"aa":[0,0]};
  1265. F5W[20] = map.physics.joints[F5W[19]];
  1266. F5W[20].d.la = binaryReader.readDouble();
  1267. F5W[20].d.ua = binaryReader.readDouble();
  1268. F5W[20].d.mmt = binaryReader.readDouble();
  1269. F5W[20].d.ms = binaryReader.readDouble();
  1270. F5W[20].d.el = binaryReader.readBoolean();
  1271. F5W[20].d.em = binaryReader.readBoolean();
  1272. F5W[20].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1273. }
  1274. if (F5W[31] == 2) {
  1275. map.physics.joints[F5W[19]] = {"type":"d","d":{"fh":0,"dr":0,"cc":false,"bf":0,"dl":true},"aa":[0,0],"ab":[0,0]};
  1276. F5W[87] = map.physics.joints[F5W[19]];
  1277. F5W[87].d.fh = binaryReader.readDouble();
  1278. F5W[87].d.dr = binaryReader.readDouble();
  1279. F5W[87].aa = [binaryReader.readDouble(), binaryReader.readDouble()];
  1280. F5W[87].ab = [binaryReader.readDouble(), binaryReader.readDouble()];
  1281. }
  1282. if (F5W[31] == 3) {
  1283. map.physics.joints[F5W[19]] = {"type":"lpj","d":{"cc":false,"bf":0,"dl":true},"pax":0,"pay":0,"pa":0,"pf":0,"pl":0,"pu":0,"plen":0,"pms":0};
  1284. F5W[90] = map.physics.joints[F5W[19]];
  1285. F5W[90].pax = binaryReader.readDouble();
  1286. F5W[90].pay = binaryReader.readDouble();
  1287. F5W[90].pa = binaryReader.readDouble();
  1288. F5W[90].pf = binaryReader.readDouble();
  1289. F5W[90].pl = binaryReader.readDouble();
  1290. F5W[90].pu = binaryReader.readDouble();
  1291. F5W[90].plen = binaryReader.readDouble();
  1292. F5W[90].pms = binaryReader.readDouble();
  1293. }
  1294. if (F5W[31] == 4) {
  1295. map.physics.joints[F5W[19]] = {"type":"lsj","d":{"cc":false,"bf":0,"dl":true},"sax":0,"say":0,"sf":0,"slen":0};
  1296. F5W[44] = map.physics.joints[F5W[19]];
  1297. F5W[44].sax = binaryReader.readDouble();
  1298. F5W[44].say = binaryReader.readDouble();
  1299. F5W[44].sf = binaryReader.readDouble();
  1300. F5W[44].slen = binaryReader.readDouble();
  1301. }
  1302. if(F5W[31] == 5){
  1303. map.physics.joints[F5W[19]] = {type:"g",n:"",ja:-1,jb:-1,r:1};
  1304. F5W[91] = map.physics.joints[F5W[19]];
  1305. F5W[91].n = binaryReader.readUTF();
  1306. F5W[91].ja = binaryReader.readShort();
  1307. F5W[91].jb = binaryReader.readShort();
  1308. F5W[91].r = binaryReader.readDouble();
  1309.  
  1310. }
  1311. if(F5W[31]!=5){
  1312. map.physics.joints[F5W[19]].ba = binaryReader.readShort();
  1313. map.physics.joints[F5W[19]].bb = binaryReader.readShort();
  1314. map.physics.joints[F5W[19]].d.cc = binaryReader.readBoolean();
  1315. map.physics.joints[F5W[19]].d.bf = binaryReader.readDouble();
  1316. map.physics.joints[F5W[19]].d.dl = binaryReader.readBoolean();
  1317. }
  1318. }
  1319. return map;
  1320. };
  1321. scope.updateWssLog = function(){
  1322. if(!wsslogpaused){
  1323. if(logmenutable.children.length < wsssendrecievelog.length){
  1324. var bottomscroll = logmenutable.clientHeight + logmenutable.scrollTop >= logmenutable.scrollHeight-1;
  1325. while (logmenutable.children.length>1000) {
  1326. logmenutable.removeChild(logmenutable.firstChild);
  1327. logmenutable2.removeChild(logmenutable2.firstChild);
  1328. }
  1329. var loopthro = wsssendrecievelog.slice(packetcount);
  1330. for(var i = 0; i < loopthro.length;i++){
  1331. packetcount++;
  1332. var row = document.createElement("tr");
  1333. var row2 = document.createElement("tr");
  1334. var cell1 = document.createElement("td");
  1335. cell1.style["overflow-x"] = "scroll";
  1336. cell1.style["padding"] = "0px";
  1337. cell1.style["width"] = "100000px";
  1338. var cell2 = document.createElement("td");
  1339. cell2.style["overflow-x"] = "scroll";
  1340. cell2.style["padding"] = "0px";
  1341. cell2.style["width"] = "100000px";
  1342. if(debuggercount){
  1343. cell1.style["background"] = "rgb(178, 185, 189)";
  1344. debuggercount = false;
  1345. }
  1346. else{
  1347. cell2.style["background"] = "rgb(178, 185, 189)";
  1348. debuggercount = true;
  1349. }
  1350. cell1.textContent = loopthro[i][1];
  1351. cell2.textContent = loopthro[i][1];
  1352. if(loopthro[i][0] == 0){
  1353. cell2.style["color"] = "transparent";
  1354. cell1.onclick = function(){debuggerinput.value = this.textContent};
  1355. }
  1356. else{
  1357. cell1.style["color"] = "transparent";
  1358. cell2.onclick = function(){debuggerinput.value = this.textContent};
  1359. }
  1360. row.appendChild(cell1);
  1361. row2.appendChild(cell2);
  1362. logmenutable.appendChild(row);
  1363. logmenutable2.appendChild(row2);
  1364. }
  1365. while (logmenutable.children.length>1000) {
  1366. logmenutable.removeChild(logmenutable.firstChild);
  1367. logmenutable2.removeChild(logmenutable2.firstChild);
  1368. }
  1369. if(bottomscroll){
  1370. logmenutable.scrollTop = logmenutable.scrollHeight;
  1371. logmenutable2.scrollTop = logmenutable.scrollHeight;
  1372. }
  1373. }
  1374. }
  1375. };
  1376. Gdocument.getElementById("maploadwindowmapscontainer").appendChild = function(args){
  1377. var checkbox = Gdocument.createElement("input");
  1378. checkbox.type = "checkbox";
  1379. checkbox.style["position"]="absolute";
  1380. checkbox.style["margin-top"] = "135px";
  1381. checkbox.style["margin-left"] = "140px";
  1382. checkbox.style["scale"] = "2";
  1383. checkbox.style["display"] = "none";
  1384. checkbox.className = "quickplaycheckbox quickplayunchecked";
  1385. if(ishost && stopquickplay==0){
  1386. checkbox.style["display"] = "block";
  1387. checkbox.className = "quickplaycheckbox quickplaychecked";
  1388. }
  1389. checkbox.checked = true;
  1390. checkbox.onclick = function(e){e.stopPropagation();};
  1391. args.appendChild(checkbox);
  1392. originalMapLoad.call(this,args);
  1393. };
  1394. Gdocument.getElementById("newbonklobby_chat_content").appendChild = function(args){
  1395. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1396. if(args.children[0].textContent.endsWith(" has left the game ") && args.children[0].textContent.startsWith("* ")){
  1397. var kickedorbanned = "banned";
  1398. if(onlykicked){
  1399. kickedorbanned = "kicked";
  1400. }
  1401. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game ";
  1402. }
  1403. }
  1404. setTimeout(function(){
  1405. if(args.textContent.startsWith("* ") && args.children.length>=5){
  1406. var newarg = args.cloneNode();
  1407. for(var i = 0;i<args.children.length;i++){
  1408. var newarg2 = args.children[i].cloneNode();
  1409. newarg2.textContent = args.children[i].textContent;
  1410. newarg2.style.color = '#ffffffd6';
  1411. newarg2.onclick = args.children[i].onclick;
  1412. newarg2.suggestID = args.children[i].suggestID;
  1413. newarg.appendChild(newarg2);
  1414. }
  1415. Gdocument.getElementById("ingamechatcontent").appendChild(newarg);
  1416. Gdocument.getElementById("ingamechatcontent").scrollTop = Number.MAX_SAFE_INTEGER;
  1417. }},0);
  1418. originalLobbyChat.call(this,args);
  1419. };
  1420. Gdocument.getElementById("ingamechatcontent").appendChild = function(args){
  1421. if(beenKickedTimeStamp+100>Date.now() && args.children.length>0){
  1422. if(args.children[0].textContent.endsWith(" has left the game.") && args.children[0].textContent.startsWith("* ")){
  1423. var kickedorbanned = "banned";
  1424. if(onlykicked){
  1425. kickedorbanned = "kicked";
  1426. }
  1427. args.children[0].textContent = args.children[0].textContent.substring(0,args.children[0].textContent.length-19)+" has been "+kickedorbanned+" from the game.";
  1428. }
  1429. }
  1430. if(recordedTimeStamp+100>Date.now() && args.children.length>0){
  1431. if(args.children[0].textContent.includes("seconds") && args.children[0].textContent.startsWith("* ")){
  1432. args.children[0].textContent = args.children[0].textContent + " - " + playerids[recordedId].userName;
  1433. }
  1434. }
  1435. originalIngameChat.call(this,args);
  1436. };
  1437. Gwindow.Date.now = function(){
  1438. if(overideDate[0]){
  1439. return overideDate[1];
  1440. }
  1441. else if(causelag){
  1442. return originalDatenow.call(this,...arguments)-causelag2;
  1443. }
  1444. return originalDatenow.call(this,...arguments);
  1445. };
  1446. Gwindow.XMLHttpRequest.prototype.open = function(_, url) {
  1447. if (url.includes("scripts/map_get") || url.includes("scripts/map_b1_get") || url.includes("scripts/hotmaps/")) {
  1448. if(searchrequested==1){
  1449. Gdocument.getElementById("maploadtypedropdowntitle").click();
  1450. Gdocument.getElementById("maploadtypedropdowntitle").textContent = dropdownrequested.textContent;
  1451. dropdownrequested.style["display"] = "none";
  1452. clearmaprequests.style["display"] = "block";
  1453. refreshmaprequests.style["display"] = "block";
  1454. Gdocument.getElementById("maploadwindowhotnessslider").style["visibility"] = "hidden";
  1455. Gdocument.getElementById("maploadwindowsearchoptions").style["visibility"] = "hidden";
  1456. searchrequested = 0;
  1457. this.isSearchMap = true;
  1458. }
  1459. }
  1460. else if(url.includes("getrooms.php")){
  1461. this.isGetRooms = true;
  1462. }
  1463. else if(url.includes("getroomaddress.php")){
  1464. this.isGetRoomAddress = true;
  1465. }
  1466. originalXMLOpen.call(this, ...arguments);
  1467. };
  1468. Gwindow.XMLHttpRequest.prototype.send = function(data) {
  1469. if(this.isGetRoomAddress){
  1470. currentroomaddress = parseInt(data.slice(3));
  1471. }
  1472. else if(this.isGetRooms && inroom){
  1473. this.onreadystatechange = function(){
  1474. if(this.readyState == 4){
  1475. lastrooms = JSON.parse(this.response)["rooms"];
  1476. if(lastrooms){
  1477. var keys = Object.keys(savedroomsdata);
  1478. for(var i = 0;i<lastrooms.length;i++){
  1479. if(savedrooms.includes(lastrooms[i].id)){
  1480. exists = true;
  1481. savedroomsdata[lastrooms[i].id] = lastrooms[i];
  1482. savedroomsdata[lastrooms[i].id].exists = true;
  1483. savedroomsdata[lastrooms[i].id].exists2 = true;
  1484. if(lastrooms[i].maxplayers>lastrooms[i].players){
  1485. if(inroom){
  1486. if(lastrooms[i].id!=currentroomaddress){
  1487. displayInChat('The room '+JSON.stringify(lastrooms[i].roomname)+' is now open with '+lastrooms[i].players+"/"+lastrooms[i].maxplayers+" players.","#DA0808","#1EBCC1");
  1488. savedrooms.splice(savedrooms.indexOf(lastrooms[i].id),1);
  1489. delete savedroomsdata[lastrooms[i].id];
  1490. keys.splice(keys.indexOf((lastrooms[i].id).toString()),1);
  1491. }
  1492. else{
  1493. savedrooms.splice(savedrooms.indexOf(lastrooms[i].id),1);
  1494. delete savedroomsdata[lastrooms[i].id];
  1495. keys.splice(keys.indexOf((lastrooms[i].id).toString()),1);
  1496. }
  1497. }
  1498. }
  1499. }
  1500. }
  1501. for(var i = 0;i<keys.length;i++){
  1502. if(!savedroomsdata[keys[i]].exists2){
  1503. savedroomsdata[keys[i]].exists = false;
  1504. }
  1505. savedroomsdata[keys[i]].exists2 = false;
  1506. }
  1507. for(var i = 0;i<keys.length;i++){
  1508. if(!savedroomsdata[keys[i]].exists){
  1509. savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])),1);
  1510. displayInChat('The room '+JSON.stringify(savedroomsdata[keys[i]].roomname)+" does not exist anymore.","#DA0808","#1EBCC1");
  1511. delete savedroomsdata[keys[i]];
  1512. }
  1513. }
  1514. }
  1515. }
  1516. }
  1517. }
  1518. else if (this.isSearchMap) {
  1519. this.onreadystatechange = function () {
  1520. if (this.readyState == 4){
  1521. var jsonargs = {r:"success",maps:[],more:true};
  1522. for(var i = 0; i<requestedmaps.length; i++){
  1523. var dec = requestedmaps[i][0];
  1524. var undec = requestedmaps[i][1];
  1525. var map = {};
  1526. map.id = dec["m"]["dbid"];
  1527. map.name = dec["m"]["n"];
  1528. map.authorname = dec["m"]["a"];
  1529. map.leveldata = undec;
  1530. map.publisheddate = dec["m"]["date"];
  1531. map.remixauthor = dec["m"]["rxa"];
  1532. map.remixdb = dec["m"]["rxdb"];
  1533. map.remixid = dec["m"]["rxid"];
  1534. map.remixname = dec["m"]["rxn"];
  1535. map.vd = dec["m"]["vd"];
  1536. map.vu = dec["m"]["vu"];
  1537. jsonargs.maps.push(map);
  1538. }
  1539. jsonargs2 = JSON.stringify(jsonargs);
  1540. function stringifyjsonargs(){
  1541. return jsonargs2;
  1542. }
  1543. this.__defineGetter__("responseText", stringifyjsonargs);
  1544. this.__defineGetter__("response", stringifyjsonargs);
  1545. }
  1546. }
  1547. }
  1548. originalXMLSend.call(this, ...arguments);
  1549. };
  1550. scope.STB = function(x){
  1551. if(x == "0"){
  1552. return 0;
  1553. }
  1554. else{
  1555. return 1;
  1556. }
  1557. };
  1558. scope.BTS = function(x){
  1559. if(x == 0){
  1560. return "0";
  1561. }
  1562. else{
  1563. return "1";
  1564. }
  1565. };
  1566. scope.GET_KEYS = function(x){
  1567. var x2 = ((x+64)>>>0).toString(2).substring(1).split("");
  1568. return {"left":STB(x2[5]),"right":STB(x2[4]),"up":STB(x2[3]),"down":STB(x2[2]),"heavy":STB(x2[1]),"special":STB(x2[0])}
  1569. };
  1570. scope.MAKE_KEYS = function(x){
  1571. return x.special*32+x.heavy*16+x.down*8+x.up*4+x.right*2+x.left
  1572. };
  1573. Gwindow.PIXI.Graphics.prototype.drawCircle = function(...args){
  1574. var This = this;
  1575. var Args = [...args];
  1576. setTimeout(function(){
  1577. if(This.parent){
  1578. var childs = This.parent.children;
  1579. var user = 0;
  1580. for(var i = 0;i<childs.length;i++){
  1581. if(childs[i]._text){
  1582. user = childs[i]._text;
  1583. }
  1584. if(i==2 && childs[i]!=This){
  1585. return;
  1586. }
  1587. }
  1588. var keys = Object.keys(playerids);
  1589. for(var i = 0;i<keys.length;i++){
  1590. if(playerids[keys[i]].userName == user){
  1591. playerids[keys[i]].playerData = This.parent;
  1592. if(!playerids[keys[i]].playerData2){
  1593. playerids[keys[i]].playerData2 = {alive:true,radius:12,timeStamp:0,timeStamp2:0,px:0,py:0,pvx:0,pvy:0,xacc:0,yacc:0,xvel:0,yvel:0,balance:0};
  1594. }
  1595. playerids[keys[i]].playerData2.radius = Args[2];
  1596. parentDraw = This.parent;
  1597. while(parentDraw.parent){
  1598. parentDraw = parentDraw.parent;
  1599. }
  1600. }
  1601. }
  1602. }
  1603. },0);
  1604. return originalDrawCircle.call(this,...args);
  1605. };
  1606. Gwindow.requestAnimationFrame = function(...args){
  1607. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  1608. while(parentDraw.parent){
  1609. parentDraw = parentDraw.parent;
  1610. }
  1611. var canv = 0;
  1612. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  1613. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  1614. canv = Gdocument.getElementById("gamerenderer").children[i];
  1615. break;
  1616. }
  1617. }
  1618. var width = parseInt(canv.style["width"]);
  1619. var height = parseInt(canv.style["height"]);
  1620. scale = (parseInt(canv.style["width"])/730);
  1621. var now = Date.now();
  1622. var keys = Object.keys(playerids);
  1623. addto = {"children":[]};
  1624. for(var i = 0;i<parentDraw.children.length;i++){
  1625. if(parentDraw.children[i].constructor.name == "e"){
  1626. addto = parentDraw.children[i];
  1627. break;
  1628. }
  1629. }
  1630. if(pan_enabled && Gdocument.getElementById("gamerenderer")?.childElementCount>0 && (keys_being_held["ShiftLeft"] || keys_being_held["ShiftRight"])){
  1631. var temp_zoom = zoom;
  1632. if(keys_being_held["ArrowUp"]){
  1633. pan.y+=pan_speed/temp_zoom;
  1634. }
  1635. if(keys_being_held["ArrowDown"]){
  1636. pan.y-=pan_speed/temp_zoom;
  1637. }
  1638. if(keys_being_held["ArrowRight"]){
  1639. pan.x-=pan_speed/temp_zoom;
  1640. }
  1641. if(keys_being_held["ArrowLeft"]){
  1642. pan.x+=pan_speed/temp_zoom;
  1643. }
  1644. }
  1645. var panx = 0;
  1646. var pany = 0;
  1647. if(pan){
  1648. panx = pan.x;
  1649. pany = pan.y;
  1650. }
  1651. if(autocam){
  1652. var autocamx = 365*scale;
  1653. var autocamy = 250*scale;
  1654. if(FollowCam && playerids[myid].playerData?.transform){
  1655. autocamx = playerids[myid].playerData.transform.position.x;
  1656. autocamy = playerids[myid].playerData.transform.position.y;
  1657. }
  1658. var distances = {};
  1659. for(var i = 0;i<keys.length;i++){
  1660. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2){
  1661. if(playerids[keys[i]].playerData.transform){
  1662. var ypos = playerids[keys[i]].playerData.transform.position.y;
  1663. if(ypos>460*scale && ypos< 500 * scale){
  1664. ypos = scale * 460;
  1665. }
  1666. distances[keys[i]] = [playerids[keys[i]].playerData.transform.position.x-autocamx,ypos-autocamy];
  1667. }
  1668. }
  1669. }
  1670. distances["topleft"] = [autocamx-40,autocamy-40];
  1671. distances["topright"] = [690*scale-autocamx,autocamy-40];
  1672. distances["bottomleft"] = [autocamx-40,460*scale-autocamy];
  1673. distances["bottomright"] = [690*scale-autocamx,460*scale-autocamy];
  1674. var lowestD = [-1,-1];
  1675. var keys2 = Object.keys(distances);
  1676. for(var i = 0;i<keys2.length;i++){
  1677. if(Math.abs(distances[keys2[i]][0]/scale)>lowestD[0]){
  1678. lowestD[0] = Math.abs(distances[keys2[i]][0]/scale);
  1679. }
  1680. if(Math.abs(distances[keys2[i]][1]/scale)>lowestD[1]){
  1681. lowestD[1] = Math.abs(distances[keys2[i]][1]/scale);
  1682. }
  1683. }
  1684. var horizontal = (lowestD[0])/345;
  1685. var vertical = (lowestD[1])/230;
  1686. newzoom = Math.min(Math.abs(1/Math.max(horizontal,vertical)),1);
  1687. }
  1688. else{
  1689. newzoom = 1;
  1690. }
  1691. newzoom2 = newzoom2 + 0.15*(newzoom-newzoom2);
  1692. zoom2 = zoom2 + 0.15*(zoom-zoom2);
  1693. addto.scale.x = newzoom2 * zoom2;
  1694. addto.scale.y = newzoom2 * zoom2;
  1695. if(holdheavy>0){
  1696. if(holdheavy==1){
  1697. holdheavy = -1;
  1698. }
  1699. else{
  1700. holdheavy-=1;
  1701. }
  1702. }
  1703. if(playerids[myid].playerData?.children){
  1704. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1705. if(playerids[myid].playerData.children[i].alpha!=1){
  1706. heavyid = i;
  1707. }
  1708. if(playerids[myid].playerData.children[i].vertextData){
  1709. if(playerids[myid].playerData.children[i].vertextData.length == 0){
  1710. specialid = i;
  1711. }
  1712. }
  1713. }
  1714. }
  1715. for(var i = 0;i<keys.length;i++){
  1716. if(allstyles[playerids[keys[i]].userName]){
  1717. var isadmin = [false,0];
  1718. for(var i3 = 0;i3<admins.length;i3++){
  1719. if(admins[i3][0] == playerids[keys[i]].userName && !playerids[keys[i].guest]){
  1720. isadmin = [true,i3];
  1721. break;
  1722. }
  1723. }
  1724. if(playerids[keys[i]].playerData?.children){
  1725. for(var i2 = 0;i2<playerids[keys[i]].playerData.children.length;i2++){
  1726. if(playerids[keys[i]].playerData.children[i2].text){
  1727. if(allstyles[playerids[keys[i]].userName][0]==0 && allstyles[playerids[keys[i]].userName][1]==0 && allstyles[playerids[keys[i]].userName][2]==0){
  1728. playerids[keys[i]].playerData.children[i2].tint = 255*256**3-1;
  1729. }
  1730. else{
  1731. playerids[keys[i]].playerData.children[i2].tint = allstyles[playerids[keys[i]].userName][0]*256**2 + allstyles[playerids[keys[i]].userName][1]*256 + allstyles[playerids[keys[i]].userName][2];
  1732. }
  1733. }
  1734. }
  1735. }
  1736. if(isadmin[1]<=3){
  1737. if(isadmin[0]){
  1738. if(playerids[keys[i]].playerData?.children && playerids[keys[i]].guest==false){
  1739. for(var i2 = 0;i2<playerids[keys[i]].playerData.children.length;i2++){
  1740. if(playerids[keys[i]].playerData.children[i2].text && (allstyles[playerids[keys[i]].userName][0]==0 && allstyles[playerids[keys[i]].userName][1]==0 && allstyles[playerids[keys[i]].userName][2]==0)){
  1741. playerids[keys[i]].playerData.children[i2].tint = (75+Math.abs(180-admins[isadmin[1]][1][0]))*256**2 + (75+Math.abs(180-admins[isadmin[1]][1][1]))*256 + 75+Math.abs(180-admins[isadmin[1]][1][2]);
  1742. }
  1743. if(!Array.isArray(playerids[keys[i]].playerData.children[i2].filters)){
  1744. playerids[keys[i]].playerData.children[i2].filters = [new Gwindow.PIXI.filters.ColorMatrixFilter()];
  1745. playerids[keys[i]].playerData.children[i2].filters[0].resolution = 3;
  1746. }
  1747. var rotatevalue = 0;
  1748. if(admins[isadmin[1]][1][3]<90){
  1749. rotatevalue = admins[isadmin[1]][1][3]/2;
  1750. }
  1751. else if(admins[isadmin[1]][1][3]<270){
  1752. rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  1753. }
  1754. else if(admins[isadmin[1]][1][3]<360){
  1755. rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  1756. }
  1757. playerids[keys[i]].playerData.children[i2].filters[0].hue(rotatevalue);
  1758. }
  1759. }
  1760. }
  1761. }
  1762. }
  1763. }
  1764. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1765. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1766. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1767. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1768. if(canvasWidth!=width){
  1769. canvasWidth = width;
  1770. pixiCircle.clear();
  1771. pixiCircle.x = parseInt(canv.style["width"])/2;
  1772. pixiCircle.y = parseInt(canv.style["height"])/2;
  1773. pixiCircle.lineStyle(3, 0x8B8000);
  1774. pixiCircle.drawRect(-parseInt(canv.style["width"])/2,-parseInt(canv.style["height"])/2,parseInt(canv.style["width"]),parseInt(canv.style["height"]));
  1775. pixiCircle.lineStyle(3, 0xFF0000);
  1776. pixiCircle.arc(0, 0, 850*scale,Math.atan2(250,-100*Math.sqrt(66)),Math.atan2(250,100*Math.sqrt(66)));
  1777. pixiCircle.lineTo(-100*Math.sqrt(66)*scale,250*scale);
  1778. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  1779. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  1780. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  1781. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  1782. }
  1783. if(!addto.children.includes(container)){
  1784. addto.addChild(container);
  1785. }
  1786. if(keys.length>0){
  1787. if(playerids[myid].playerData && playerids[myid].playerData2){
  1788. if(aimbot || heavybot || staystill){
  1789. var targetid = -1;
  1790. var distances = {};
  1791. if(Gdocument.getElementById("ingamecountdown").style["visibility"] == "hidden"){
  1792. if(playerids[myid].playerData.transform){
  1793. var teamok = true;
  1794. if(playerids[myid].team>1){
  1795. teamok = false;
  1796. }
  1797. for(var i = 0;i<keys.length;i++){
  1798. if(playerids[keys[i]].playerData && playerids[keys[i]].playerData2 && keys[i]!=myid){
  1799. if(playerids[keys[i]].playerData.transform && (playerids[keys[i]].team != playerids[myid].team || teamok || FFA)){
  1800. distances[keys[i]] = Math.sqrt((playerids[keys[i]].playerData.transform.position.x-playerids[myid].playerData.transform.position.x)**2+(playerids[keys[i]].playerData.transform.position.y-playerids[myid].playerData.transform.position.y)**2);
  1801. }
  1802. }
  1803. }
  1804. }
  1805. }
  1806. var lowestD = [-1,-1];
  1807. var keys2 = Object.keys(distances);
  1808. for(var i = 0;i<keys2.length;i++){
  1809. if(myid != keys2[i]){
  1810. if(lowestD[1] == -1){
  1811. lowestD[1] = distances[keys2[i]];
  1812. lowestD[0] = keys2[i];
  1813. }
  1814. else if(distances[keys2[i]]<lowestD[1]){
  1815. lowestD[1] = distances[keys2[i]];
  1816. lowestD[0] = keys2[i];
  1817. }
  1818. }
  1819. }
  1820. targetid = lowestD[0];
  1821. if(playerids[myid].playerData?.transform && playerids[myid].playerData2){
  1822. if(staystill & staystillpos[0]!=null){
  1823. var playerpos = playerids[myid].playerData.transform.position;
  1824. if(Math.abs(staystillpos[0]-playerpos.x/scale)<3){
  1825. if(playerids[myid].playerData2.xvel/scale>0){
  1826. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1827. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1828. }
  1829. else if(playerids[myid].playerData2.xvel/scale<0){
  1830. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1831. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1832. }
  1833. else{
  1834. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1835. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1836. }
  1837. }
  1838. else{
  1839. if(staystillpos[0]>playerpos.x/scale){
  1840. if(playerids[myid].playerData2.xvel/scale>10){
  1841. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1842. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1843. }
  1844. else{
  1845. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1846. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1847. }
  1848. }
  1849. else if(staystillpos[0]<playerpos.x/scale){
  1850. if(playerids[myid].playerData2.xvel/scale<-10){
  1851. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1852. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1853. }
  1854. else{
  1855. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1856. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1857. }
  1858. }
  1859. }
  1860. }
  1861. }
  1862. if(targetid != -1 && playerids[myid].playerData?.transform){
  1863. if(playerids[myid].playerData.children.length >= 7 && playerids[targetid].playerData && playerids[targetid].playerData.transform && playerids[targetid].playerData2 && aimbot){
  1864. var indexE = -1;
  1865. for(var i = 0;i<playerids[myid].playerData.children.length;i++){
  1866. if(playerids[myid].playerData.children[i].constructor.name == "e"){
  1867. indexE = i;
  1868. break;
  1869. }
  1870. }
  1871. if(indexE != -1 && playerids[myid].playerData.children[indexE].visible){
  1872. if(started == 0){
  1873. started = now;
  1874. }
  1875. var scale2=1/(parseInt(canv.style["width"])/730);
  1876. scale2 /= scale/(1 + playerids[myid].playerData2.balance*0.0088)*(playerids[myid].playerData2.radius/12);
  1877. var Dstarted = (Math.min((now-started)/1000,10/3)/(10/3));
  1878. var v = multiplier * (Dstarted*100+15)*scale2;
  1879. var g = gravity;
  1880. var mypos = playerids[myid].playerData.transform.position;
  1881. var targetpos = playerids[targetid].playerData.transform.position;
  1882. var deltapos = [(targetpos.x-mypos.x)*scale2,(targetpos.y-mypos.y)*scale2];
  1883. var dis = (Math.sqrt(deltapos[0]**2 + deltapos[1]**2))/v*prediction;
  1884. deltapos[0]+=(playerids[targetid].playerData2.xvel*scale2*dis+(playerids[targetid].playerData2.xacc*scale2*(dis))**2/2);
  1885. deltapos[1]+=(playerids[targetid].playerData2.yvel*scale2*dis+(playerids[targetid].playerData2.yacc*scale2*(dis))**2/2);
  1886. deltapos[1] = -deltapos[1];
  1887. var angle = positive(-Math.atan2(deltapos[1],deltapos[0]));
  1888. var rot = playerids[myid].playerData.children[indexE].transform.rotation;
  1889. rot = positive(rot);
  1890. angle = positive(angle);
  1891. var alpha = deltapos[0];
  1892. var beta = deltapos[1];
  1893. var v_squared = v**2;
  1894. var eff = 2*v_squared/g;
  1895. var rootterm = eff*(eff-2*beta)-2*alpha**2;
  1896. if(rootterm < 0) {
  1897. } else {
  1898. gamma_first = (eff + Math.sqrt(rootterm));
  1899. gamma_second = (eff - Math.sqrt(rootterm));
  1900. theta_first = positive(-Math.atan2(gamma_first, alpha));
  1901. theta_second = positive(-Math.atan2(gamma_second, alpha));
  1902. if(angle_between(angle,theta_first)<angle_between(angle,theta_second)){
  1903. angle = theta_first;
  1904. }
  1905. else{
  1906. angle = theta_second;
  1907. }
  1908. }
  1909. var min = angle_between(angle,rot);
  1910. if(angle_between2(angle,rot)<0){
  1911. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1912. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1913. }
  1914. else{
  1915. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1916. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1917. }
  1918. if(min<0.05){
  1919. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1920. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1921. }
  1922. }
  1923. else if(started>0){
  1924. started = 0;
  1925. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  1926. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  1927. }
  1928. }
  1929. }
  1930. if(playerids[myid].playerData?.transform && heavybot && mode!="f" && mode!="bs"){
  1931. var myradius = playerids[myid].playerData2.radius / scale;
  1932. var mypos = playerids[myid].playerData.transform.position;
  1933. var breakout = false;
  1934. for(var i = 0;i<keys2.length;i++){
  1935. var targetradius = playerids[keys2[i]].playerData2.radius / scale;
  1936. var targetpos = playerids[keys2[i]].playerData.transform.position;
  1937. var deltapos = [(targetpos.x-mypos.x)/scale,(targetpos.y-mypos.y)/scale];
  1938. for(var i2 = 0;i2<160;i2++){
  1939. deltapos2 = [...deltapos];
  1940. var i3 = i2*0.5;
  1941. deltapos2[0]+=((playerids[keys2[i]].playerData2.xvel-playerids[myid].playerData2.xvel)/scale*i3);
  1942. deltapos2[1]+=((playerids[keys2[i]].playerData2.yvel-playerids[myid].playerData2.yvel)/scale*i3);
  1943. var dis = Math.sqrt(deltapos2[0]**2+deltapos2[1]**2);
  1944. if(dis<myradius+targetradius){
  1945. breakout = true;
  1946. holdheavy = 20;
  1947. break;
  1948. }
  1949. }
  1950. if(breakout){
  1951. break;
  1952. }
  1953. }
  1954. if(holdheavy>0){
  1955. if(!heavyheld2){
  1956. heavyheld = playerids[myid].playerData.children[heavyid].alpha>0;
  1957. }
  1958. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1959. heavyheld2 = true;
  1960. if(mode == "sp"){
  1961. if(!grappleheld2){
  1962. grappleheld = playerids[myid].playerData.children[specialid].vertexData?.length>0;
  1963. }
  1964. if(grappleheld){
  1965. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1966. }
  1967. grappleheld2 = true;
  1968. }
  1969. }
  1970. else if(holdheavy<0){
  1971. holdheavy = 0;
  1972. heavyheld2 = false;
  1973. grappleheld2 = false;
  1974. if(!heavyheld){
  1975. heavyheld = false;
  1976. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  1977. }
  1978. if(grappleheld && mode == "sp"){
  1979. grappleheld = false;
  1980. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  1981. }
  1982. }
  1983. else{
  1984. heavyheld2 = false;
  1985. heavyheld = false;
  1986. grappleheld2 = false;
  1987. grappleheld = false;
  1988. }
  1989. }
  1990. }
  1991. if(FollowCam){
  1992. if(playerids[myid].playerData?.transform){
  1993. pixiCircle.visible = true;
  1994. parentDraw.x = -playerids[myid].playerData.x*addto.scale.x+parseInt(width)/2;
  1995. parentDraw.y = -playerids[myid].playerData.y*addto.scale.y+parseInt(height)/2;
  1996. parentDraw.children[0].x = playerids[myid].playerData.x*addto.scale.x-parseInt(width)/2;
  1997. parentDraw.children[0].y = playerids[myid].playerData.y*addto.scale.y-parseInt(height)/2;
  1998. }
  1999. else{
  2000. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  2001. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  2002. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  2003. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  2004. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  2005. pixiCircle.visible = false;
  2006. }
  2007. else{
  2008. pixiCircle.visible = true;
  2009. }
  2010. }
  2011. }
  2012. }
  2013. }
  2014. if(!FollowCam){
  2015. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !pan_enabled){
  2016. pixiCircle.visible = false;
  2017. }
  2018. else{
  2019. pixiCircle.visible = true;
  2020. }
  2021. }
  2022. parentDraw.x+=panx*addto.scale.x;
  2023. parentDraw.y+=pany*addto.scale.y;
  2024. parentDraw.children[0].x-=panx*addto.scale.x;
  2025. parentDraw.children[0].y-=pany*addto.scale.y;
  2026. }
  2027. if(maxfps){
  2028. return setTimeout.call(this,...args);
  2029. }
  2030. return requestAnimationFrameOriginal.call(this,...args);
  2031. };
  2032. scope.SENDFUNCTION = function(args){return args;};
  2033. scope.RECIEVEFUNCTION = function(args){return args;};
  2034. scope.EVENTLOOPFUNCTION = function(){};
  2035. Gwindow.WebSocket.prototype.send = function(args) {
  2036. if(this.url.includes("socket.io/?EIO=3&transport=websocket&sid=")){
  2037. if(typeof(args) == "string" && !bonkwssextra.includes(this)){
  2038. args = SENDFUNCTION(args);
  2039. wsssendlog.push(args);
  2040. wsssendrecievelog.push([0,args]);
  2041. if(!bonkwss){
  2042. bonkwss = this;
  2043. }
  2044. if(args.startsWith('42[26,')){
  2045. var jsonargs = JSON.parse(args.substring(2));
  2046. if(sandboxon){
  2047. if(typeof(sandboxplayerids[jsonargs[1]["targetID"]])!='undefined'){
  2048. var packet = '42[18,'+jsonargs[1]["targetID"]+','+jsonargs[1]["targetTeam"]+']';
  2049. RECIEVE(packet);
  2050. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  2051. }
  2052. }
  2053. }
  2054. if(args.startsWith('42[9,')){
  2055. var jsonargs = JSON.parse(args.substring(2));
  2056. if(sandboxon){
  2057. if(typeof(sandboxplayerids[jsonargs[1]["banshortid"]])!='undefined'){
  2058. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  2059. var packet = '42[24,'+jsonargs[1]["banshortid"].toString()+','+jsonargs[1]["kickonly"]+']';
  2060. var packet2 = '42[5,'+jsonargs[1]["banshortid"].toString()+',0]';
  2061. RECIEVE(packet);
  2062. RECIEVE(packet2);
  2063. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet,packet2],to:[-1]}]));
  2064. }
  2065. else{
  2066. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  2067. }
  2068. }
  2069. }
  2070. }
  2071. if(args.startsWith('42[1,')){
  2072. return;
  2073. }
  2074. if(args.startsWith('42[4,')){
  2075. var jsonargs = JSON.parse(args.substring(2));
  2076. if(sandboxcopyme==myid && typeof(jsonargs[1]["i"])!="undefined"){
  2077. var jsonkeys = Object.keys(sandboxplayerids);
  2078. var jsonargs2 = jsonargs[1];
  2079. for(var i = 0; i<jsonkeys.length;i++){
  2080. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2081. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2082. RECIEVE(packet);
  2083. }
  2084. jsonargs2["c"] = "CVALUE";
  2085. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2086. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2087. }
  2088. if(typeof(jsonargs[1]["i"]) != "undefined"){
  2089. if(playerids[myid].movecount>=jsonargs[1]["c"]){
  2090. jsonargs[1]["c"] = playerids[myid].movecount;
  2091. playerids[myid].movecount+=1;
  2092. }
  2093. else{
  2094. playerids[myid].movecount = jsonargs[1]["c"]+1;
  2095. }
  2096. }
  2097. if(recording && typeof(jsonargs[1]["i"])!="undefined"){
  2098. if(myid.toString() == recordingid){
  2099. if(recordingdata.length == 0){
  2100. recordingdata.push([jsonargs[1]["i"],jsonargs[1]["f"]]);
  2101. }
  2102. else{
  2103. recordingdata.push([jsonargs[1]["i"],jsonargs[1]["f"]-recordingdata[0][1]]);
  2104. }
  2105. }
  2106. }
  2107. playerids[myid].lastmove = Date.now();
  2108. if(ishost && typeof(jsonargs[1]["i"])!="undefined"){
  2109. for(var i = 0;i<disabledkeys.length;i++){
  2110. if(GET_KEYS(jsonargs[1]["i"])[disabledkeys[i]]){
  2111. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(myid)){
  2112. killedids.push(myid);
  2113. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2114. SEND('42[25,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2115. RECIEVE('42[31,{"a":{"playersLeft":['+myid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2116. break;
  2117. }
  2118. }
  2119. }
  2120. }
  2121. args = "42"+JSON.stringify(jsonargs);
  2122. }
  2123. if(args.startsWith('42[29,')){
  2124. var jsonargs = JSON.parse(args.substring(2));
  2125. playerids[jsonargs[1]["sid"]].playerData2.balance = jsonargs[1]["bal"];
  2126. if(sandboxon){
  2127. if(typeof(sandboxplayerids[jsonargs[1]["sid"]])!='undefined'){
  2128. var packet = '42[36,'+jsonargs[1]["sid"]+','+jsonargs[1]["bal"]+']';
  2129. RECIEVE(packet);
  2130. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  2131. }
  2132. }
  2133. }
  2134. if(args.startsWith('42[12,')){
  2135. playerids = {};
  2136. var jsonargs2 = JSON.parse(args.substring(2));
  2137. var jsonargs = jsonargs2[1];
  2138. playerids["0"] = {"peerID":jsonargs["peerID"],"userName":username,"level":Gdocument.getElementById("pretty_top_level").textContent == "Guest" ? 0 : parseInt(Gdocument.getElementById("pretty_top_level").textContent.substring(3)),"guest":typeof(jsonargs.token)=="undefined","team":1,"avatar":jsonargs["avatar"],"movecount":0,"commands":true,"ratelimit":{"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now(),"style":0},"vote":{"poll":-1}};
  2139. allstyles[username] = [0,0,0];
  2140. myid = 0;
  2141. bonkwss = this;
  2142. hostid = 0;
  2143. inroom = true;
  2144. if(savedrooms.length>0){
  2145. Gdocument.getElementById("roomlistrefreshbutton").click();
  2146. }
  2147. }
  2148. if(args.startsWith('42[10')){
  2149. var jsonargs = JSON.parse(args.substring(2));
  2150. if(jsonargs[2]){
  2151. args = "42"+JSON.stringify([10,jsonargs[1]]);
  2152. }
  2153. else if(translating2[0]){
  2154. text = translate(jsonargs[1]["message"],"auto",translating2[1]).then(function(r){SEND("42"+JSON.stringify([10,{"message":r},true]))});
  2155. return;
  2156. }
  2157. }
  2158. if(args.startsWith('42[23,') && recteams){
  2159. var jsonargs = JSON.parse(args.substring(2));
  2160. var map = decodeFromDatabase(jsonargs[1]["m"]);
  2161. var spawns = map["spawns"];
  2162. var teamsneeded = true;
  2163. var excludedindexes = [];
  2164. var ffaspawns = false;
  2165. var ffaforsure = false;
  2166. for(var i = 0; i<spawns.length;i++){
  2167. var currentSpawn = spawns[i];
  2168. if(Math.sqrt(currentSpawn.x**2 + currentSpawn.y**2)>=850 || currentSpawn.y>250){
  2169. excludedindexes.push(i);
  2170. }
  2171. else if(!(currentSpawn.f || currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  2172. excludedindexes.push(i);
  2173. }
  2174. else if(currentSpawn.f){
  2175. ffaspawns = true;
  2176. if(!(currentSpawn.r || currentSpawn.b || currentSpawn.gr || currentSpawn.ye)){
  2177. excludedindexes.push(i);
  2178. ffaforsure = true
  2179. }
  2180. }
  2181. }
  2182. if(!ffaspawns && !ffaforsure){
  2183. teamsneeded = true;
  2184. }
  2185. else{
  2186. teamsneeded = false;
  2187. }
  2188. if(teamsneeded){
  2189. var newspawns = [];
  2190. for(var i = 0; i<spawns.length;i++){
  2191. if(!excludedindexes.includes(i)){
  2192. newspawns.push({"r":spawns[i]["r"],"g":spawns[i]["gr"],"b":spawns[i]["b"],"y":spawns[i]["ye"],"total":spawns[i]["r"]+spawns[i]["ye"]+spawns[i]["gr"]+spawns[i]["b"],"priority":spawns[i]["priority"]});
  2193. }
  2194. }
  2195. if(newspawns.length>0){
  2196. var teamletters = ["r","g","b","y"];
  2197. var ratios = {"r":0,"g":0,"b":0,"y":0};
  2198. for(var i = 0; i < newspawns.length;i++){
  2199. for(var i2 = 0; i2<teamletters.length;i2++){
  2200. var ct = teamletters[i2];
  2201. if(newspawns[i]["priority"]!=0){
  2202. ratios[ct]+=(newspawns[i][ct])/newspawns[i]["total"]*newspawns[i]["priority"];
  2203. }
  2204. }
  2205. }
  2206. var highest = ["",0];
  2207. for(var i = 0; i<teamletters.length;i++){
  2208. var ct = teamletters[i];
  2209. if(ratios[ct]>0 && highest[1]<ratios[ct]){
  2210. highest = [ct,ratios[ct]];
  2211. }
  2212. }
  2213. if(highest[0]!=""){
  2214. for(var i = 0; i<teamletters.length;i++){
  2215. var ct = teamletters[i];
  2216. ratios[ct] = ratios[ct]/highest[1];
  2217. }
  2218. }
  2219. var playerids3 = Object.keys(playerids);
  2220. var playerids2 = [];
  2221. for(var i = 0; i<playerids3.length;i++){
  2222. if(playerids[playerids3[i]].team>0){
  2223. playerids2.push(playerids3[i]);
  2224. }
  2225. }
  2226. var pi2l = playerids2.length;
  2227. var ratios2 = {"r":0,"r1":0,"g":0,"g1":0,"b":0,"b1":0,"y":0,"y1":0};
  2228. var items = Object.entries(ratios);
  2229. items.sort(function(a,b){return a[1]-b[1];});
  2230. var items = items.map(function(e){return e[0];});
  2231. var highest2 = ["",0];
  2232. while(pi2l>0){
  2233. var done = false;
  2234. for(var i2 = 0; i2<items.length;i2++){
  2235. var ci = items[i2];
  2236. var ci2 = items[i2]+"1";
  2237. for(var i = 0; i<teamletters.length;i++){
  2238. var ct = teamletters[i];
  2239. if(ratios2[ct]>0 && highest2[1]<ratios2[ct]){
  2240. highest2 = [ct,ratios2[ct]];
  2241. }
  2242. }
  2243. if(highest2[0]!=""){
  2244. for(var i = 0; i<teamletters.length;i++){
  2245. var ct = teamletters[i];
  2246. ratios2[ct+"1"] = ratios2[ct]/highest2[1];
  2247. }
  2248. }
  2249. if(ratios[ci]>0 && ratios[ci]>=ratios2[ci2] && pi2l>0){
  2250. ratios2[ci]+=1;
  2251. pi2l--;
  2252. done = true;
  2253. }
  2254. }
  2255. if(pi2l>0 && !done){
  2256. ratios2[highest2[0]]+=1;
  2257. pi2l--;
  2258. }
  2259. }
  2260. SEND('42[32,{"t":true}]');
  2261. RECIEVE('42[39,true]');
  2262. for(var i = 0; i<ratios2["r"];i++){
  2263. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2264. SEND('42[26,{"targetID":'+pid+',"targetTeam":2}]');
  2265. if(playerids[pid].peerID!="sandbox"){
  2266. RECIEVE('42[18,'+pid+',2]');
  2267. }
  2268. }
  2269. for(var i = 0; i<ratios2["g"];i++){
  2270. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2271. SEND('42[26,{"targetID":'+pid+',"targetTeam":4}]');
  2272. if(playerids[pid].peerID!="sandbox"){
  2273. RECIEVE('42[18,'+pid+',4]');
  2274. }
  2275. }
  2276. for(var i = 0; i<ratios2["b"];i++){
  2277. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2278. SEND('42[26,{"targetID":'+pid+',"targetTeam":3}]');
  2279. if(playerids[pid].peerID!="sandbox"){
  2280. RECIEVE('42[18,'+pid+',3]');
  2281. }
  2282. }
  2283. for(var i = 0; i<ratios2["y"];i++){
  2284. var pid = playerids2.splice(Math.floor(Math.random()*playerids2.length),1)[0];
  2285. SEND('42[26,{"targetID":'+pid+',"targetTeam":5}]');
  2286. if(playerids[pid].peerID!="sandbox"){
  2287. RECIEVE('42[18,'+pid+',5]');
  2288. }
  2289. }
  2290. }
  2291. }
  2292. else{
  2293. SEND('42[32,{"t":false}]');
  2294. RECIEVE('42[39,false]');
  2295. }
  2296. }
  2297. if(args.startsWith('42[47,') && stopquickplay == 0 && ishost && document.hidden && !qppaused){
  2298. roundsperqp2++;
  2299. if(roundsperqp2>=roundsperqp){
  2300. if(shuffle){
  2301. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2302. var available = [];
  2303. var availableindexes = [];
  2304. var notempty = false;
  2305. for(var i = 0; i<e2.length;i++){
  2306. var a = false;
  2307. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2308. available.push(a);
  2309. if(a){
  2310. availableindexes.push(i);
  2311. notempty = true;
  2312. }
  2313. }
  2314. if(notempty){
  2315. if(availableindexes.length!=1){
  2316. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  2317. }
  2318. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  2319. }
  2320. }
  2321. else{
  2322. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  2323. var available = [];
  2324. var availableindexes = [];
  2325. var notempty = false;
  2326. for(var i = 0; i<e2.length;i++){
  2327. var a = false;
  2328. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  2329. available.push(a);
  2330. if(a){
  2331. availableindexes.push(i);
  2332. notempty = true;
  2333. }
  2334. }
  2335. if(notempty){
  2336. var above = [];
  2337. for(var i = 0;i<availableindexes.length;i++){
  2338. if(availableindexes[i]>quicki && !reverseqp){
  2339. above.push(availableindexes[i]);
  2340. }
  2341. else if(availableindexes[i]<quicki && reverseqp){
  2342. above.push(availableindexes[i])
  2343. }
  2344. }
  2345. if(above.length>0){
  2346. quicki = above[0];
  2347. if(reverseqp){
  2348. quicki = above[above.length-1];
  2349. }
  2350. }
  2351. else{
  2352. quicki = availableindexes[0];
  2353. if(reverseqp){
  2354. quicki = availableindexes[availableindexes.length-1];
  2355. }
  2356. }
  2357. }
  2358. }
  2359. }
  2360. canceled = false;
  2361. startedinqp = true;
  2362. window.map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length),0);
  2363. }
  2364. if(args.startsWith('42[32,')){
  2365. var jsonargs = JSON.parse(args.substring(2));
  2366. var keys = Object.keys(playerids);
  2367. if(!jsonargs[1]["t"]){
  2368. FFA = true;
  2369. for(var i = 0;i<keys.length;i++){
  2370. if(playerids[keys[i]].team!=0){
  2371. playerids[keys[i]].team = 1;
  2372. }
  2373. }
  2374. }
  2375. else{
  2376. FFA = false;
  2377. }
  2378. }
  2379. if(args.startsWith('42[5,')){
  2380. var jsonargs = JSON.parse(args.substring(2));
  2381. if(stopquickplay!=1 && startedinqp){
  2382. startedinqp = false;
  2383. jsonargs[1]["gs"]["wl"] = 999;
  2384. if(!instaqp){
  2385. var jsonargs2 = decodeIS(jsonargs[1]["is"]);
  2386. jsonargs2["ftu"] = 60;
  2387. if(jsonargs2["mm"]["rxa"] != ""){
  2388. jsonargs2["mm"]["a"] = jsonargs2["mm"]["rxa"];
  2389. jsonargs2["mm"]["n"] = jsonargs2["mm"]["rxn"];
  2390. }
  2391. jsonargs2 = encodeIS(jsonargs2);
  2392. jsonargs[1]["is"] = jsonargs2;
  2393. var jsonargs3 = decodeFromDatabase(jsonargs[1]["gs"]["map"]);
  2394. if(jsonargs3["m"]["rxa"] != ""){
  2395. jsonargs3["m"]["a"] = jsonargs3["m"]["rxa"];
  2396. jsonargs3["m"]["n"] = jsonargs3["m"]["rxn"];
  2397. }
  2398. jsonargs3 = encodeToDatabase(jsonargs3);
  2399. jsonargs[1]["gs"]["map"] = jsonargs3;
  2400. }
  2401. }
  2402. args = "42"+JSON.stringify(jsonargs);
  2403. }
  2404. }
  2405. }
  2406. else{
  2407. if(args.includes("rport")){
  2408. return;
  2409. }
  2410. }
  2411. if(this.url.includes("socket.io/?EIO=3&transport=websocket&sid=") && !this.injected){
  2412. this.injected = true;
  2413. var originalRecieve = this.onmessage;
  2414. this.onmessage = function(args){
  2415. if(!bonkwssextra.includes(this)){
  2416. wssrecievelog.push(args.data);
  2417. wsssendrecievelog.push([1,args.data]);
  2418. if(typeof(args.data)=="string"){
  2419. args = {"data":RECIEVEFUNCTION(args.data)};
  2420. if(args.data.startsWith('42[1,')){
  2421. var jsonargs = JSON.parse(args.data.substring(2));
  2422. originalSend.call(this,'42[1,{"id":'+jsonargs[2]+'}]');
  2423. }
  2424. if(args.data.startsWith('42[36,')){
  2425. var jsonargs = JSON.parse(args.data.substring(2));
  2426. playerids[jsonargs[1]].playerData2.balance = jsonargs[2];
  2427. }
  2428. if(args.data.startsWith('42[24,')){
  2429. beenKickedTimeStamp = Date.now();
  2430. onlykicked = JSON.parse(args.data.substring(2))[2];
  2431. }
  2432. if(args.data.startsWith('42[21,')){
  2433. recievedinitdata = true;
  2434. }
  2435. if(args.data.startsWith('42[48,')){
  2436. recievedinitdata = true;
  2437. }
  2438. if(args.data.startsWith('42[23,')){
  2439. var jsonargs = JSON.parse(args.data.substring(2));
  2440. if(causelag){
  2441. jsonargs[1]["result"]-=causelag2;
  2442. }
  2443. args.data = '42'+JSON.stringify(jsonargs);
  2444. }
  2445. if(args.data.startsWith('42[16,')){
  2446. var jsonargs = JSON.parse(args.data.substring(2));
  2447. var now = Date.now();
  2448. if(jsonargs[1]=="chat_rate_limit"){
  2449. if(pollactive[1]+100>now){
  2450. pollactive = [false,0,0,[]];
  2451. displayInChat("Your poll failed due to chat rate limit.","#DA0808","#1EBCC1");
  2452. displayInChat("Please try again.","#DA0808","#1EBCC1");
  2453. }
  2454. }
  2455. else if(jsonargs[1]=="room_full"){
  2456. if(!savedrooms.includes(currentroomaddress)){
  2457. savedroombutton.className = "brownButton brownButton_classic buttonShadow";
  2458. }
  2459. }
  2460. }
  2461. if(args.data.startsWith('42[6,')){
  2462. var jsonargs = JSON.parse(args.data.substring(2));
  2463. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2464. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2465. delete playerids[jsonargs[1]];
  2466. }
  2467. hostid = jsonargs[2];
  2468. }
  2469. if(args.data.startsWith('42[39,')){
  2470. var jsonargs = JSON.parse(args.data.substring(2));
  2471. var keys = Object.keys(playerids);
  2472. if(!jsonargs[1]){
  2473. FFA = true;
  2474. for(var i = 0;i<keys.length;i++){
  2475. if(playerids[keys[i]].team!=0){
  2476. playerids[keys[i]].team = 1;
  2477. }
  2478. }
  2479. }
  2480. else{
  2481. FFA = false;
  2482. }
  2483. }
  2484. if(args.data.startsWith('42[41,')){
  2485. var jsonargs = JSON.parse(args.data.substring(2));
  2486. hostid = jsonargs[1]["newHost"];
  2487. }
  2488. if(args.data.startsWith('42[20,')){
  2489. var jsonargs = JSON.parse(args.data.substring(2));
  2490. if(translating[0]){
  2491. translate(jsonargs[2],"auto",translating[1]).then(function(r){if(r==jsonargs[2]){return;} displayInChat(playerids[jsonargs[1]].userName+": "+r,"#DA0808","#1EBCC1")});
  2492. }
  2493. if(echo_list.includes(playerids[jsonargs[1]].userName)){
  2494. chat(flag_manage(echotext.replaceAll("username",playerids[jsonargs[1]].userName).replaceAll("message",jsonargs[2])));
  2495. }
  2496. if(randomchat){
  2497. var isin = false;
  2498. for(var i = 0;i<randomchatpriority[1].length;i++){
  2499. if(randomchatpriority[1][i][0] == jsonargs[2]){
  2500. isin = true;
  2501. if(myid!=jsonargs[1]){
  2502. randomchatpriority[1][i][1]+=2;
  2503. randomchatpriority[0]+=2;
  2504. }
  2505. break;
  2506. }
  2507. }
  2508. if(!isin){
  2509. randomchatpriority[1].push([jsonargs[2],Math.max(35-Math.abs(35-jsonargs[2].length),1)]);
  2510. randomchatpriority[0]+=Math.max(35-Math.abs(35-jsonargs[2].length),1);
  2511. }
  2512. }
  2513. if(pollactive[0] || pollactive2[0]){
  2514. var chatmessage = jsonargs[2].toUpperCase().trim().replace(")","");
  2515. var lettersindex = letters.indexOf(chatmessage);
  2516. if(ishost){
  2517. if(pollactive[3].length>0 && lettersindex!=-1 && lettersindex<pollactive[3].length){
  2518. playerids[jsonargs[1]].vote.poll = lettersindex;
  2519. }
  2520. }
  2521. else{
  2522. if(pollactive2[2].length>0 && lettersindex!=-1 && lettersindex<pollactive2[2].length){
  2523. playerids[jsonargs[1]].vote.poll = lettersindex;
  2524. }
  2525. }
  2526. }
  2527. }
  2528. if(args.data.startsWith('42[32')){
  2529. SEND('42[4,{"type":"inactive kick counter"}]');
  2530. }
  2531. if(args.data.startsWith('42[18')){
  2532. var jsonargs = JSON.parse(args.data.substring(2));
  2533. playerids[jsonargs[1]].team = jsonargs[2];
  2534. }
  2535. if(args.data.startsWith('42[40,')){
  2536. recordedTimeStamp = Date.now();
  2537. recordedId = JSON.parse(args.data.substring(2))[1];
  2538. }
  2539. if(args.data.startsWith('42[3,')){
  2540. playerids = {};
  2541. var jsonargs = JSON.parse(args.data.substring(2));
  2542. var jsonargs2 = JSON.parse(args.data.substring(2));
  2543. for(var i = 0; i<jsonargs[3].length;i++){
  2544. if(jsonargs[3][i]!=null){
  2545. if(jsonargs[3][i].userName == "Juice1313" && jsonargs[3][i].level > 0){
  2546. jsonargs2[3][i].userName = "Piss1313";
  2547. jsonargs[3][i].userName = "Piss1313";
  2548. }
  2549. if(jsonargs[3][i].userName == "LEGENDBOSS123" && jsonargs[3][i].level > 0){
  2550. jsonargs2[3][i].level = -jsonargs2[3][i].level;
  2551. }
  2552. playerids[i.toString()] = jsonargs[3][i];
  2553. playerids[i.toString()].commands = false;
  2554. playerids[i.toString()].ratelimit = {"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now(),"style":0};
  2555. playerids[i.toString()].vote = {"poll":-1};
  2556. allstyles[playerids[i.toString()].userName] = [0,0,0];
  2557. }
  2558. }
  2559. if(playerids[jsonargs[1]].userName.startsWith(Gdocument.getElementById("pretty_top_name").textContent)){
  2560. myid = jsonargs[1];
  2561. bonkwss = this;
  2562. playerids[myid].commands = true;
  2563. /*setTimeout(function(){var me = playerids[myid];RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));});*/
  2564. }
  2565. else{
  2566. bonkwssextra.push(this);
  2567. }
  2568. inroom = true;
  2569. hostid = jsonargs[2];
  2570. SEND('42[4,{"type":"commands"}]');
  2571. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":mystyle}]));
  2572. allstyles[playerids[myid].userName] = [...mystyle];
  2573. ghostroomwss = bonkwss;
  2574. Gdocument.getElementById("roomlistrefreshbutton").click();
  2575. setTimeout(function(){if(bonkwss == ghostroomwss && !sandboxon && !recievedinitdata && myid!=0){RECIEVE('42[21,{"map":{"v":13,"s":{"re":false,"nc":false,"pq":1,"gd":25,"fl":false},"physics":{"shapes":[],"fixtures":[],"bodies":[],"bro":[],"joints":[],"ppm":12},"spawns":[],"capZones":[],"m":{"a":"","n":"","dbv":0,"dbid":0,"authid":-1,"date":"","rxid":0,"rxn":"","rxa":"","rxdb":0,"cr":[],"pub":false,"mo":"","vu":0,"vd":0}},"gt":2,"wl":3,"q":false,"tl":false,"tea":false,"ga":"b","mo":"b","bal":[]}]');displayInChat("You have joined a ghost room.","#DA0808","#1EBCC1");}},6000);
  2576. args.data = "42"+JSON.stringify(jsonargs2);
  2577. }
  2578. if(args.data.startsWith('42[21,')){
  2579. var jsonargs = JSON.parse(args.data.substring(2));
  2580. mode = jsonargs[1]["mo"];
  2581. FFA = !jsonargs[1]["tea"];
  2582. }
  2583. if(args.data.startsWith('42[48,')){
  2584. var jsonargs = JSON.parse(args.data.substring(2));
  2585. mode = jsonargs[1]["gs"]["mo"];
  2586. FFA = !jsonargs[1]["gs"]["tea"];
  2587. }
  2588. if(args.data.startsWith('42[49,')){
  2589. /*
  2590. var me = playerids[myid];
  2591. RECIEVE('42'+JSON.stringify([4,myid,me.peerID,me.userName,me.guest,me.level,me.team,me.avatar]));
  2592. */
  2593. }
  2594. if(args.data.startsWith('42[15,')){
  2595. var jsonargs = JSON.parse(args.data.substring(2));
  2596. dontswitch = false;
  2597. mode = jsonargs[3]["mo"];
  2598. gameStartTimeStamp = jsonargs[1];
  2599. killedids = [];
  2600. Gdocument.getElementById("newbonklobby").style["z-index"] = "unset";
  2601. Gdocument.getElementById("mapeditorcontainer").style["z-index"] = "unset";
  2602. }
  2603. if(args.data.startsWith('42[33,')){
  2604. var jsonargs = JSON.parse(args.data.substring(2));
  2605. var decodedmap = decodeFromDatabase(jsonargs[1]);
  2606. if(decodedmap!=0){
  2607. requestedmaps = [[decodedmap,jsonargs[1]]].concat(requestedmaps);
  2608. }
  2609. }
  2610. if(args.data.startsWith('42[7,')){
  2611. var jsonargs2 = JSON.parse(args.data.substring(2));
  2612. var idofpacket = jsonargs2[1];
  2613. jsonargs = jsonargs2[2];
  2614. if(typeof(jsonargs["i"]) == "undefined"){
  2615. if(jsonargs["type"]=="private chat" && jsonargs["to"] == username){
  2616. from = jsonargs["from"];
  2617. if(Object.keys(playerids).includes(idofpacket.toString())){
  2618. from = playerids[idofpacket].userName;
  2619. }
  2620. if(!ignorepmlist.includes(from)){
  2621. if(typeof(jsonargs["message"])=="string"){
  2622. var now = Date.now();
  2623. if(playerids[idofpacket].ratelimit.pm+500<now){
  2624. playerids[idofpacket].ratelimit.pm = now;
  2625. DECRYPT_MESSAGE(private_key,jsonargs["message"]).then(function(e){
  2626. var encodedtext = e;
  2627. var code = 'Gwindow.private_chat = "'+from+'"; Gwindow.SEND("42"+JSON.stringify([4,{"type":"request public key","from":Gwindow.username,"to":Gwindow.private_chat}])); Gwindow.request_public_key_time_stamp = Date.now(); setTimeout(function(){if(Gwindow.private_chat_public_key[0]!=Gwindow.private_chat){Gwindow.displayInChat("Failed to connect to "+Gwindow.private_chat+".","#DA0808","#1EBCC1");Gwindow.private_chat = Gwindow.private_chat_public_key[0];}},1600);';
  2628. displayInChat('> '+'<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+sanitize(from)+'</a>'+': ',"#DA0808","#1EBCC1",{sanitize:false},encodedtext);
  2629. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  2630. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  2631. Laster_message = lastmessage();
  2632. }).catch(function(){EXPORT_KEY(public_key).then(function(e){SEND("42"+JSON.stringify([4,{"type":"public key correction","from":username,"to":private_chat_public_key[0],"public key":e}]));});});
  2633. }
  2634. }
  2635. }
  2636. }
  2637. if(jsonargs["type"]=="request public key" && jsonargs["to"] == username){
  2638. EXPORT_KEY(public_key).then(function(e){SEND("42"+JSON.stringify([4,{"type":"public key","from":username,"public key":e}]));});
  2639. }
  2640. if(jsonargs["type"]=="private chat users" && pmuserstimestamp+1500>Date.now()){
  2641. if(typeof(jsonargs["from"])!='undefined'){
  2642. from = jsonargs["from"];
  2643. if(Object.keys(playerids).includes(idofpacket.toString())){
  2644. from = playerids[idofpacket].userName;
  2645. }
  2646. if(!pmusers.includes(from) && username == jsonargs["to"]){
  2647. pmusers.push(from);
  2648. }
  2649. }
  2650. }
  2651. if(jsonargs["type"]=="style" && playerids[idofpacket].ratelimit["style"]+3000<Date.now()){
  2652. playerids[idofpacket].ratelimit["style"] = Date.now();
  2653. if(Array.isArray(jsonargs["style"])){
  2654. if(jsonargs["style"].length == 3){
  2655. var valid = true;
  2656. for(var i = 0;i<jsonargs["style"].length;i++){
  2657. if(Number.isInteger(jsonargs["style"][i])){
  2658. if(jsonargs["style"][i]>255 || jsonargs["style"][i]<0){
  2659. valid = false;
  2660. break;
  2661. }
  2662. }
  2663. else{
  2664. valid = false;
  2665. break;
  2666. }
  2667. }
  2668. if(valid){
  2669. allstyles[playerids[idofpacket].userName] = jsonargs["style"];
  2670. }
  2671. }
  2672. }
  2673. }
  2674. if(jsonargs["type"]=="request private chat users"){
  2675. if(typeof(jsonargs["from"])!='undefined'){
  2676. from = jsonargs["from"];
  2677. if(Object.keys(playerids).includes(idofpacket.toString())){
  2678. from = playerids[idofpacket].userName;
  2679. }
  2680. SEND("42"+JSON.stringify([4,{"type":"private chat users","from":username,"to":from}]));
  2681. }
  2682. }
  2683. if(jsonargs["type"]=="public key" && request_public_key_time_stamp+1500>Date.now()){
  2684. from = jsonargs["from"];
  2685. if(Object.keys(playerids).includes(idofpacket.toString())){
  2686. from = playerids[idofpacket].userName;
  2687. }
  2688. if(from == private_chat){
  2689. IMPORT_KEY(jsonargs["public key"]).then(function(key){private_chat_public_key = [private_chat,key];displayInChat("Private chatting with "+private_chat+".","#DA0808","#1EBCC1");});
  2690. }
  2691. }
  2692. if(jsonargs["type"]=="fakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2693. for(var i = 0;i<jsonargs["packet"].length;i++){
  2694. if(!jsonargs["packet"][i].trim().startsWith("42[20,") && !jsonargs["packet"][i].trim().startsWith("41")){
  2695. RECIEVE(sanitize(jsonargs["packet"][i]));
  2696. }
  2697. }
  2698. }
  2699. if(jsonargs["type"]=="customfakerecieve" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2700. for(var i2 = 0;i2<jsonargs["packet"].length;i2++){
  2701. var keys = Object.keys(sandboxplayerids);
  2702. for(var i = 0;i<keys.length;i++){
  2703. if(jsonargs["packet"][i2].startsWith("42[7,")){
  2704. originalRecieve.call(this,{data:jsonargs["packet"][i2].replace("ID",keys[i].toString()).replace("CVALUE",playerids[keys[i]].movecount.toString())});
  2705. playerids[keys[i]].movecount+=1;
  2706. }
  2707. }
  2708. }
  2709. }
  2710. if(jsonargs["type"]=="commands"){
  2711. playerids[idofpacket].commands = true;
  2712. }
  2713. if(jsonargs["type"]=="sandboxid" && hostid == idofpacket && sandboxon && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2714. sandboxid = jsonargs["lastid"];
  2715. }
  2716. if(jsonargs["type"]=="sandboxon" && idofpacket == hostid){
  2717. if(!sandboxon){
  2718. displayInChat("This is a sandbox lobby.","#DA0808","#1EBCC1");
  2719. sandboxon = true;
  2720. }
  2721. }
  2722. if(jsonargs["type"]=="vote poll"){
  2723. from = jsonargs["from"];
  2724. if(Object.keys(playerids).includes(idofpacket.toString())){
  2725. from = playerids[idofpacket].userName;
  2726. }
  2727. if(typeof(jsonargs["vote"]) == 'number' && idofpacket!=hostid){
  2728. var now = Date.now();
  2729. if(ishost && pollactive[3].length>1 && pollactive[0]){
  2730. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive[3].length){
  2731. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2732. }
  2733. }
  2734. else if(pollactive2[0] && pollactive2[2].length>1){
  2735. if(jsonargs["vote"]>=0 && jsonargs["vote"]<pollactive2[2].length){
  2736. playerids[idofpacket].vote.poll = jsonargs["vote"];
  2737. }
  2738. }
  2739. }
  2740. }
  2741. if(jsonargs["type"]=="poll end"){
  2742. from = jsonargs["from"];
  2743. if(Object.keys(playerids).includes(idofpacket.toString())){
  2744. from = playerids[idofpacket].userName;
  2745. }
  2746. var now = Date.now();
  2747. if(hostid == idofpacket && playerids[idofpacket].ratelimit.poll+5000<now){
  2748. playerids[idofpacket].ratelimit.poll = now;
  2749. var count = [0,0,0,0];
  2750. var keys = Object.keys(playerids);
  2751. for(var i = 0;i<keys.length;i++){
  2752. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  2753. count[playerids[keys[i]].vote.poll]++;
  2754. }
  2755. playerids[keys[i]].vote.poll = -1;
  2756. }
  2757. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  2758. for(var i = 0;i<count.length;i++){
  2759. if(count[i]>1){
  2760. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2761. }
  2762. if(count[i]==1){
  2763. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  2764. }
  2765. }
  2766. pollactive2 = [false,0,[]];
  2767. }
  2768. }
  2769. if(jsonargs["type"] == "video player" && idofpacket == hostid && ((jsonargs["to"].includes(myid) && jsonargs["to"][0]!=-1) || (!jsonargs["to"].includes(myid) && jsonargs["to"][0]==-1))){
  2770. changeJukeboxURL(jsonargs["url"],jsonargs["timestamp"]);
  2771. }
  2772. if(jsonargs["type"]=="poll" && idofpacket == hostid){
  2773. from = jsonargs["from"];
  2774. if(Object.keys(playerids).includes(idofpacket.toString())){
  2775. from = playerids[idofpacket].userName;
  2776. }
  2777. if(Array.isArray(jsonargs["poll"])){
  2778. var propperpoll = true;
  2779. var pollifproper = [];
  2780. if(jsonargs["poll"].length>5){
  2781. propperpoll = false;
  2782. }
  2783. else{
  2784. for(var i = 0;i<jsonargs["poll"].length;i++){
  2785. if(typeof(jsonargs["poll"][i]) == 'string'){
  2786. if(jsonargs["poll"][i].length>50){
  2787. propperpoll = false;
  2788. break;
  2789. }
  2790. else{
  2791. pollifproper.push(jsonargs["poll"][i]);
  2792. }
  2793. }
  2794. else{
  2795. propperpoll = false;
  2796. break;
  2797. }
  2798. }
  2799. }
  2800. if(propperpoll){
  2801. var now = Date.now();
  2802. var keys = Object.keys(playerids);
  2803. for(var i = 0;i<keys.length;i++){
  2804. playerids[keys[i]].vote.poll = -1;
  2805. }
  2806. pollactive2 = [true,now,pollifproper];
  2807. playerids[idofpacket].ratelimit.poll = now;
  2808. displayInChat(from+" started a poll:","#DA0808","#1EBCC1");
  2809. for(var i = 0;i<pollifproper.length;i++){
  2810. var code = 'Gwindow.displayInChat("You voted for option '+letters[i]+'.","#DA0808","#1EBCC1",{sanitize:false},"",true);Gwindow.SEND("42"+JSON.stringify([4,{"type":"vote poll","from":Gwindow.username,"vote":'+i+'}]));Gwindow.playerids[Gwindow.myid].vote.poll='+i+';Gwindow.Gdocument.getElementById("newbonklobby_chat_content").children[Gwindow.Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;Gwindow.Gdocument.getElementById("ingamechatcontent").children[Gwindow.Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;Gwindow.Laster_message = Gwindow.lastmessage();';
  2811. displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+letters[i]+')</a>',"#DA0808","#1EBCC1",{sanitize:false}," "+pollifproper[i]);
  2812. }
  2813. }
  2814. }
  2815. }
  2816. if(jsonargs["type"]=="request mode" && playerids[idofpacket].ratelimit.mode+1000<Date.now()){
  2817. playerids[idofpacket].ratelimit.mode = Date.now();
  2818. from = jsonargs["from"];
  2819. if(Object.keys(playerids).includes(idofpacket.toString())){
  2820. from = playerids[idofpacket].userName;
  2821. }
  2822. var req_mode = jsonargs["mode"];
  2823. var req_mode2 = "";
  2824. if(req_mode){
  2825. if(req_mode == "b"){
  2826. req_mode2 = "Classic";
  2827. }
  2828. else if(req_mode == "sp"){
  2829. req_mode2 = "Grapple";
  2830. }
  2831. else if(req_mode == "ar"){
  2832. req_mode2 = "Arrows";
  2833. }
  2834. else if(req_mode == "ard"){
  2835. req_mode2 = "Death Arrows";
  2836. }
  2837. }
  2838. if(req_mode2){
  2839. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+req_mode+'")}';
  2840. displayInChat('> '+playerids[idofpacket].userName+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+req_mode2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  2841. }
  2842. }
  2843. if(jsonargs["type"]=="public key correction" && private_chat_public_key[0] == private_chat){
  2844. from = jsonargs["from"];
  2845. if(Object.keys(playerids).includes(idofpacket.toString())){
  2846. from = playerids[idofpacket].userName;
  2847. }
  2848. if(from == private_chat){
  2849. IMPORT_KEY(jsonargs["public key"]).then(function(public_key){private_chat_public_key = [private_chat,public_key]; ENCRYPT_MESSAGE(private_chat_public_key[1],pmlastmessage).then(function(e){
  2850. setTimeout(function(){SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"message":e}]))},500);
  2851. });});
  2852. }
  2853. }
  2854. }
  2855. else{
  2856. var now = Date.now();
  2857. if(playerids[idofpacket.toString()]){
  2858. playerids[idofpacket.toString()].lastmove = now;
  2859. }
  2860. if(idofpacket!=myid){
  2861. playerids[idofpacket.toString()].movecount+=1;
  2862. }
  2863. if(Math.abs(gameStartTimeStamp - (now-1000*jsonargs["f"]/30))>1000 && idofpacket!=myid){
  2864. gameStartTimeStamp = now-1000*jsonargs["f"]/30;
  2865. }
  2866. if(recording){
  2867. if(idofpacket.toString() == recordingid){
  2868. if(recordingdata.length == 0){
  2869. recordingdata.push([jsonargs["i"],jsonargs["f"]]);
  2870. }
  2871. recordingdata.push([jsonargs["i"],jsonargs["f"]-recordingdata[0][1]]);
  2872. }
  2873. }
  2874. if(ishost){
  2875. if(sandboxon && idofpacket == sandboxcopyme){
  2876. var jsonkeys = Object.keys(sandboxplayerids);
  2877. if(!jsonkeys.includes(sandboxcopyme.toString())){
  2878. var jsonargs2 = jsonargs;
  2879. for(var i = 0; i<jsonkeys.length;i++){
  2880. jsonargs2["c"] = playerids[jsonkeys[i]].movecount;
  2881. var packet = '42[7,'+jsonkeys[i].toString()+','+JSON.stringify(jsonargs2)+']';
  2882. RECIEVE(packet);
  2883. }
  2884. jsonargs2["c"] = "CVALUE";
  2885. jsonargs2 = JSON.stringify(jsonargs2).replace('"CVALUE"',"CVALUE");
  2886. SEND("42"+JSON.stringify([4,{"type":"customfakerecieve","from":username,"packet":['42[7,ID,'+jsonargs2+']'],to:[-1]}]));
  2887. }
  2888. }
  2889. for(var i = 0;i<disabledkeys.length;i++){
  2890. var get_keys_var = GET_KEYS(jsonargs["i"]);
  2891. if(get_keys_var[disabledkeys[i]]){
  2892. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(idofpacket)){
  2893. killedids.push(idofpacket);
  2894. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  2895. SEND('42[25,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2896. RECIEVE('42[31,{"a":{"playersLeft":['+idofpacket.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  2897. break;
  2898. }
  2899. }
  2900. }
  2901. }
  2902. }
  2903. }
  2904. if(args.data.startsWith('42[4,')){
  2905. var jsonargs = JSON.parse(args.data.substring(2));
  2906. if(jsonargs[3] == "Juice1313" && jsonargs[5] > 0){
  2907. jsonargs[3] = "Piss1313";
  2908. }
  2909. playerids[jsonargs[1]] = {"peerID":jsonargs[2],"userName":jsonargs[3],"guest":jsonargs[4],"level":jsonargs[5],"team":jsonargs[6],"avatar":jsonargs[7],"movecount":0,"ratelimit":{"pm":0,"mode":0,"team":0,"poll":0,"join":Date.now(),"style":0},"vote":{"poll":-1}};
  2910. if(jsonargs[2]!="sandbox"){
  2911. SEND('42[4,{"type":"commands"}]');
  2912. if(!Object.keys(allstyles).includes(jsonargs[3])){
  2913. allstyles[jsonargs[3]] = [0,0,0];
  2914. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":allstyles[playerids[myid].userName]}]));
  2915. }
  2916. }
  2917. if(sandboxon){
  2918. var sandboxkeys = Object.keys(sandboxplayerids);
  2919. if(sandboxkeys.includes(jsonargs[1].toString())){
  2920. delete sandboxplayerids[jsonargs[1]];
  2921. }
  2922. if(jsonargs[2]=="sandbox"){
  2923. sandboxplayerids[jsonargs[1]] = jsonargs[3];
  2924. if(jsonargs[1]>sandboxid){
  2925. sandboxid = parseInt(jsonargs[1])+1;
  2926. }
  2927. }
  2928. else{
  2929. if(ishost){
  2930. SEND('42[4,{"type":"sandboxon"}]');
  2931. var sandboxkeys = Object.keys(sandboxplayerids);
  2932. var packets = [];
  2933. for(var i = 0;i<sandboxkeys.length;i++){
  2934. var p = playerids[sandboxkeys[i]];
  2935. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  2936. packets.push(packet);
  2937. }
  2938. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[jsonargs[1]]}]));
  2939. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[jsonargs[1]]}]));
  2940. }
  2941. }
  2942. }
  2943. if(ishost){
  2944. if(jointext!="" && jsonargs[2]!="sandbox"){
  2945. chat(flag_manage(jointext.replaceAll("username",jsonargs[3])));
  2946. }
  2947. if(jointeam!=-1 && jsonargs[2]!="sandbox"){
  2948. SEND('42[26,{"targetID":'+jsonargs[1].toString()+',"targetTeam":'+jointeam.toString()+'}]');
  2949. setTimeout(function(){RECIEVE('42[18,'+jsonargs[1].toString()+','+jointeam.toString()+']');});
  2950. }
  2951. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  2952. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[jsonargs[1]]}]));
  2953. }
  2954. if(freejoin){
  2955. var count = 0;
  2956. var keys = Object.keys(playerids);
  2957. for(var i = 0; i<keys.length;i++){
  2958. if(playerids[keys[i]].team!=0){
  2959. count++;
  2960. }
  2961. }
  2962. if(count <= 2 && jsonargs[6]!=0){
  2963. setTimeout(function(){
  2964. Gdocument.getElementById("newbonklobby_editorbutton").click();
  2965. Gdocument.getElementById("mapeditor_close").click();
  2966. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  2967. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  2968. if(transitioning == true){
  2969. canceled = true;
  2970. }
  2971. },150);
  2972. }
  2973. }
  2974. }
  2975. if(jsonargs[3] == "LEGENDBOSS123" && jsonargs[5] > 0){
  2976. jsonargs[5] = -jsonargs[5];
  2977. }
  2978. args.data = "42" + JSON.stringify(jsonargs);
  2979. }
  2980. if(args.data.startsWith('42[5,')){
  2981. var jsonargs = JSON.parse(args.data.substring(2));
  2982. if(typeof(playerids[jsonargs[1]])!='undefined'){
  2983. delplayerids[jsonargs[1]] = playerids[jsonargs[1]];
  2984. delete allstyles[playerids[jsonargs[1]].userName];
  2985. delete playerids[jsonargs[1]];
  2986. }
  2987. if(sandboxon && typeof(sandboxplayerids[jsonargs[1]])!='undefined'){
  2988. delete sandboxplayerids[jsonargs[1]];
  2989. }
  2990. }
  2991. }}
  2992. return originalRecieve.call(this,args);
  2993. };
  2994. var originalClose = this.onclose;
  2995. this.onclose = function () {
  2996. if(bonkwssextra.includes(this)){
  2997. bonkwssextra.splice(bonkwssextra.indexOf(this),1)
  2998. }
  2999. else{
  3000. window.bonkwss = 0;
  3001. }
  3002. return originalClose.call(this);
  3003. }
  3004. }
  3005. return originalSend.call(this,args);
  3006. };
  3007. scope.SEND = function(args){
  3008. if(bonkwss!=0){
  3009. bonkwss.send(args);
  3010. }
  3011. };
  3012. scope.RECIEVE = function(args){
  3013. if(bonkwss!=0){
  3014. bonkwss.onmessage({data:args});
  3015. }
  3016. };
  3017. scope.dontswitch = false;
  3018. scope.username = 0;
  3019. scope.timedelay = 1400;
  3020. scope.ishost = false;
  3021. scope.checkboxhidden = true;
  3022. scope.quicki=0;
  3023. scope.defaultmode = "d";
  3024. scope.recmodebool = false;
  3025. scope.shuffle = false;
  3026. scope.startedinqp = false;
  3027. scope.instaqp = false;
  3028. scope.freejoin = false;
  3029. scope.recordedTimeStamp = 0;
  3030. scope.recordedId = 0;
  3031. scope.smartteams = false;
  3032. scope.beenKickedTimeStamp = 0;
  3033. scope.stopquickplay = 1;
  3034. scope.currentFrame = 0;
  3035. scope.text2speech = false;
  3036. scope.canceled = false;
  3037. scope.wintext = "";
  3038. scope.banned = [];
  3039. scope.transitioning = false;
  3040. scope.echo_list = [];
  3041. scope.echoAppend = "";
  3042. scope.message = "";
  3043. scope.private_chat = "";
  3044. scope.private_chat_public_key = ["",[0,0]];
  3045. scope.disabledkeys = [];
  3046. scope.actuallyhost = false;
  3047. scope.pmusers = [];
  3048. scope.pmlastmessage = "";
  3049. scope.pmuserstimestamp = 0;
  3050. scope.ignorepmlist = [];
  3051. scope.scroll = false;
  3052. scope.elem = Gdocument.getElementById("maploadwindowmapscontainer");
  3053. scope.npermissions = 1;
  3054. scope.space_flag = false;
  3055. scope.rcaps_flag = false;
  3056. scope.number_flag = false;
  3057. scope.reverse_flag = false;
  3058. scope.autocorrect = false;
  3059. scope.request_public_key_time_stamp = 0;
  3060. scope.sandboxcopyme = -1;
  3061. scope.recteams = false;
  3062. scope.chatheight = 128;
  3063. scope.onlykicked = false;
  3064. scope.killedids = [];
  3065. scope.jointext = "";
  3066. scope.randomchat = false;
  3067. scope.randomchatpriority = [0,[]];
  3068. scope.randomchatlastmessage = ["",0];
  3069. scope.afkkill = -1;
  3070. scope.tournament_mode = "";
  3071. scope.tournament_scores = [];
  3072. scope.tournament_in_and_out = {"in":[],"out":[]};
  3073. scope.echotext = "message";
  3074. scope.nextafter = 0;
  3075. scope.nextafterbuffer = -1;
  3076. scope.roundsperqp = 1;
  3077. scope.roundsperqp2 = 0;
  3078. scope.autorecord = false;
  3079. scope.poll = [];
  3080. scope.letters = ["A","B","C","D","E"];
  3081. scope.qppaused = false;
  3082. scope.FollowCam = false;
  3083. scope.autocam = false;
  3084. scope.gravity = 20;
  3085. scope.randomchat = false;
  3086. scope.randomchat_randomtimestamp = 0;
  3087. scope.randomchat_timestamp = 0;
  3088. scope.multiplier = 3.65;
  3089. scope.aimbot = false;
  3090. scope.recievedinitdata = false;
  3091. scope.heavybot = false;
  3092. scope.zoom = 1;
  3093. scope.prediction = 350;
  3094. scope.started = 0;
  3095. scope.holdheavy = 0;
  3096. scope.maxfps = false;
  3097. scope.grappleheld = false;
  3098. scope.grappleheld2 = false;
  3099. scope.heavyheld = false;
  3100. scope.reverseqp = false;
  3101. scope.jointeam = -1;
  3102. scope.heavyheld2 = false;
  3103. scope.heavyid = 3;
  3104. scope.specialid = 0;
  3105. scope.keyCodes = {"BACK_SPACE":8,"TAB":9,"SHIFT":16,"ALT":18,"LEFT ARROW":37,"RIGHT ARROW":39,"DOWN ARROW":40,"UP ARROW":38,"CONTROL":17,"SPACE":32};
  3106. scope.leftRight = [37,39];
  3107. scope.upDown = [38,40];
  3108. scope.heavy = 88;
  3109. scope.special = 90;
  3110. scope.newzoom2 = 1;
  3111. scope.staystill = false;
  3112. scope.staystillpos = [0,0];
  3113. scope.zoom2 = 1;
  3114. scope.admins = [["LEGENDBOSS123",[0,0,0,0]],["iNeonz",[0,0,0,0]],["left paren",[0,0,0,0]],["OG_New_Player",[0,0,0,0]],["An Admin",[0,0,0,0]],["L armee d LS",[0,0,0,0]],["Pixelmelt",[0,0,0,0]],["pro9905",[0,0,0,0]],["JustANameForMe",[0,0,0]],["nefarious mouse",[0,0,0,0]],["Annihilate Red",[0,0,0,0]],["Ghost_mit",[0,0,0,0]],["Neptune_1",[0,0,0,0]]];
  3115.  
  3116. scope.letters2 = Array.from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
  3117. scope.superscript_letters = Array.from("ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖᑫʳˢᵗᵘᵛʷˣʸᶻᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾQᴿˢᵀᵁⱽᵂˣʸᶻ");
  3118. scope.hollow_letters = Array.from("𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛𝕜𝕝𝕞𝕟𝕠𝕡𝕢𝕣𝕤𝕥𝕦𝕧𝕨𝕩𝕪𝕫𝔸𝔹ℂ𝔻𝔼𝔽𝔾ℍ𝕀𝕁𝕂𝕃𝕄ℕ𝕆ℙℚℝ𝕊𝕋𝕌𝕍𝕎𝕏𝕐ℤ");
  3119. scope.block_letters = Array.from("🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉");
  3120. scope.bold_letters = Array.from("𝐚𝐛𝐜𝐝𝐞𝐟𝐠𝐡𝐢𝐣𝐤𝐥𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐭𝐮𝐯𝐰𝐱𝐲𝐳𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙");
  3121. scope.italicized_letters = Array.from("𝘢𝘣𝘤𝘥𝘦𝘧𝘨𝘩𝘪𝘫𝘬𝘭𝘮𝘯𝘰𝘱𝘲𝘳𝘴𝘵𝘶𝘷𝘸𝘹𝘺𝘻𝘈𝘉𝘊𝘋𝘌𝘍𝘎𝘏𝘐𝘑𝘒𝘓𝘔𝘕𝘖𝘗𝘘𝘙𝘚𝘛𝘜𝘝𝘞𝘟𝘠𝘡");
  3122. scope.glitched_letters = Array.from("ⱥƀȼđēӻꞡħīɉҟłᵯꞥꝋꝑꝗɍꞩⱦᵾꝟⱳӿɏƶȺɃȻĐɆӺ₲ĦĪɈҞŁᛗꞤꝊꝐꝖꞦꞨȾɄꝞⱲӾɎƵ");
  3123. scope.cursive_letters = Array.from("𝒶𝒷𝒸𝒹𝑒𝒻𝑔𝒽𝒾𝒿𝓀𝓁𝓂𝓃𝑜𝓅𝓆𝓇𝓈𝓉𝓊𝓋𝓌𝓍𝓎𝓏𝒜𝐵𝒞𝒟𝐸𝐹𝒢𝐻𝐼𝒥𝒦𝐿𝑀𝒩𝒪𝒫𝒬𝑅𝒮𝒯𝒰𝒱𝒲𝒳𝒴𝒵");
  3124.  
  3125. scope.letter_dictionary = {};
  3126. for(var i = 0;i<letters2.length;i++){
  3127. letter_dictionary[letters2[i]] = [superscript_letters[i],hollow_letters[i],block_letters[i],bold_letters[i],italicized_letters[i],glitched_letters[i],cursive_letters[i]];
  3128. }
  3129. scope.textmode = -1;
  3130. scope.autokickban = 0;
  3131. scope.ghostroomwss = -1;
  3132. scope.autokickbantimestamp = 0;
  3133. scope.getroomslastcheck = 0;
  3134. scope.causelag = false;
  3135. scope.causelag2 = 0;
  3136. scope.overideDate = [false,0];
  3137. scope.scale = 1;
  3138. scope.translating = [false,""];
  3139. scope.translating2 = [false,""];
  3140. scope.translatingkeys = {"english":"en","chinese":"zh","japanese":"ja","dutch":"nl","hindi":"hi","spanish":"es","portugese":"pt","french":"fr","arabic":"ar","russian":"ru","korean":"ko"};
  3141. scope.translate = function(text,fromL,toL) {
  3142. var fL = fromL || 'en';
  3143. var tL = toL || 'de';
  3144. var url = 'https://translate.googleapis.com/translate_a/single?client=gtx&sl='+ fL + "&tl=" + tL + "&dt=t&q=" + encodeURI(text);
  3145. var parseJSON = txt => JSON.parse(txt.split(',').map( x => x || 'null').join(',')) ;
  3146. var joinSnippets = json => json[0].map( x => x[0] ).join('');
  3147. return fetch(url).then(function(res){
  3148. return res.text();
  3149. }).then(function(text){
  3150. return joinSnippets(parseJSON(text));
  3151. });
  3152. };
  3153. scope.positive = function(angle){
  3154. if(angle<0){
  3155. angle += 2*Math.PI;
  3156. }
  3157. return angle%(Math.PI*2);
  3158. };
  3159. scope.angle_between = function(angle,angle2){
  3160. return Math.min(Math.abs(positive(angle)-positive(angle2)),Math.PI*2-Math.abs(positive(angle)-positive(angle2)));
  3161. };
  3162. scope.angle_between2 = function(angle,angle2){
  3163. if(angle_between(angle,angle2+Math.PI/2)<Math.PI/2){
  3164. return 1;
  3165. }
  3166. return -1;
  3167. };
  3168. scope.stringdistance = function(s1,s2){
  3169. s1 = s1.toLowerCase();
  3170. s2 = s2.toLowerCase();
  3171. var matrix = Array(s1.length+1);
  3172. for(var i = 0;i<matrix.length;i++){
  3173. matrix[i] = Array(s2.length+1);
  3174. matrix[i][0] = i;
  3175. }
  3176. for(var i = 0;i<matrix[0].length;i++){
  3177. matrix[0][i] = i;
  3178. }
  3179. for(var i = 1;i<s1.length+1;i++){
  3180. for(var i2 = 1;i2<s2.length+1;i2++){
  3181. if(s1[i-1]==s2[i2-1]){
  3182. matrix[i][i2] = matrix[i-1][i2-1];
  3183. }
  3184. else{
  3185. matrix[i][i2] = Math.min(matrix[i][i2-1],matrix[i-1][i2],matrix[i-1][i2-1])+1;
  3186. }
  3187. }
  3188. }
  3189. return matrix[s1.length][s2.length];
  3190. };
  3191. scope.closestWord = function(word){
  3192. if(word.length>20 || word.length<2){
  3193. return word;
  3194. }
  3195. var distances = [word.length,""];
  3196. var playernamelist = [];
  3197. var keys = Object.keys(playerids);
  3198. for(var i = 0;i<keys.length;i++){
  3199. playernamelist.push(playerids[keys[i]].userName);
  3200. }
  3201. var wordlist2 = playernamelist.concat(wordlist);
  3202. for(var i = 0;i<wordlist2.length;i++){
  3203. var distance = stringdistance(word,wordlist2[i]);
  3204. if(distance<=distances[0]){
  3205. distances[0] = distance;
  3206. distances[1] = wordlist2[i];
  3207. if(distance == 0){
  3208. return wordlist2[i];
  3209. }
  3210. }
  3211. };
  3212. if(distances[1] == ""){
  3213. return word;
  3214. }
  3215. return distances[1];
  3216. };
  3217. scope.replay = function(){
  3218. var frame = getCurrentFrame();
  3219. /*var replaycounter = 0;
  3220. while(1){
  3221. if(replaycounter != recordingdata.length-1){
  3222. for(var i = 0;i<recordingdata[replaycounter+1][1]-recordingdata[replaycounter][1];i++){
  3223. RECIEVE('42[7,'+myid+',{"i":'+recordingdata[replaycounter][0]+',"f":'+(frame+i+recordingdata[replaycounter][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3224. playerids[myid].movecount+=1;
  3225. }
  3226. replaycounter+=1;
  3227. }
  3228. else{
  3229. break;
  3230. }
  3231. }*/
  3232. for(var i = 0;i<recordingdata.length;i++){
  3233. SEND('42[4,{"i":'+recordingdata[i][0]+',"f":'+(frame+recordingdata[i][1]).toString()+',"c":'+playerids[myid].movecount+'}]');
  3234. }
  3235. };
  3236. scope.presskeys = function(x,y){
  3237. if(!x.left && y.left){
  3238. fire("keydown",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3239. }
  3240. else if(x.left && !y.left){
  3241. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  3242. }
  3243. if(!x.right && y.right){
  3244. fire("keydown",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3245. }
  3246. else if(x.right && !y.right){
  3247. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  3248. }
  3249. if(!x.up && y.up){
  3250. fire("keydown",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3251. }
  3252. else if(x.up && !y.up){
  3253. fire("keyup",{"keyCode":upDown[0]},Gdocument.getElementById("gamerenderer"));
  3254. }
  3255. if(!x.down && y.down){
  3256. fire("keydown",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3257. }
  3258. else if(x.down && !y.down){
  3259. fire("keyup",{"keyCode":upDown[1]},Gdocument.getElementById("gamerenderer"));
  3260. }
  3261. if(!x.heavy && y.heavy){
  3262. fire("keydown",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3263. }
  3264. else if(x.heavy && !y.heavy){
  3265. fire("keyup",{"keyCode":heavy},Gdocument.getElementById("gamerenderer"));
  3266. }
  3267. if(!x.special && y.special){
  3268. fire("keydown",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3269. }
  3270. else if(x.special && !y.special){
  3271. fire("keyup",{"keyCode":special},Gdocument.getElementById("gamerenderer"));
  3272. }
  3273. };
  3274. scope.getplayerkeys = function(){
  3275. var keykeys = Object.keys(keyCodes);
  3276. var keyslist = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[1].children).slice(1);
  3277. var keyslist2 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[2].children).slice(1);
  3278. var keyslist3 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[3].children).slice(1);
  3279. var keyslist4 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[4].children).slice(1);
  3280. var keyslist5 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[5].children).slice(1);
  3281. var keyslist6 = Array.from(Gdocument.getElementById("redefineControls_table").children[0].children[6].children).slice(1);
  3282. for(var i = 0;i<keyslist.length;i++){
  3283. if(keykeys.includes(keyslist[i].textContent)){
  3284. leftRight[0] = keyCodes[keyslist[i].textContent];
  3285. break;
  3286. }
  3287. else{
  3288. leftRight[0] = keyslist[i].textContent.charCodeAt(0);
  3289. break
  3290. }
  3291. }
  3292. for(var i = 0;i<keyslist2.length;i++){
  3293. if(keykeys.includes(keyslist2[i].textContent)){
  3294. leftRight[1] = keyCodes[keyslist2[i].textContent];
  3295. break;
  3296. }
  3297. else{
  3298. leftRight[1] = keyslist2[i].textContent.charCodeAt(0);
  3299. break
  3300. }
  3301. }
  3302. for(var i = 0;i<keyslist3.length;i++){
  3303. if(keykeys.includes(keyslist3[i].textContent)){
  3304. upDown[0] = keyCodes[keyslist3[i].textContent];
  3305. break;
  3306. }
  3307. else{
  3308. upDown[0] = keyslist3[i].textContent.charCodeAt(0);
  3309. break
  3310. }
  3311. }
  3312. for(var i = 0;i<keyslist4.length;i++){
  3313. if(keykeys.includes(keyslist4[i].textContent)){
  3314. upDown[1] = keyCodes[keyslist4[i].textContent];
  3315. break;
  3316. }
  3317. else{
  3318. upDown[1] = keyslist4[i].textContent.charCodeAt(0);
  3319. break
  3320. }
  3321. }
  3322. for(var i = 0;i<keyslist5.length;i++){
  3323. if(keykeys.includes(keyslist5[i].textContent)){
  3324. heavy = keyCodes[keyslist5[i].textContent];
  3325. break;
  3326. }
  3327. else{
  3328. heavy = keyslist5[i].textContent.charCodeAt(0);
  3329. break
  3330. }
  3331. }
  3332. for(var i = 0;i<keyslist6.length;i++){
  3333. if(keykeys.includes(keyslist6[i].textContent)){
  3334. special = keyCodes[keyslist6[i].textContent];
  3335. break;
  3336. }
  3337. else{
  3338. special = keyslist6[i].textContent.charCodeAt(0);
  3339. break
  3340. }
  3341. }
  3342. };
  3343. scope.changeJukeboxURL = function(url,timestamp = 0){
  3344. if(pipedurllist.length == 0){
  3345. displayInChat("The jukebox is still being set up.","#DA0808","#1EBCC1");
  3346. return;
  3347. }
  3348. if(url == ""){
  3349. jukeboxplayer.pause();
  3350. jukeboxplayer.src = '';
  3351. displayInChat("The jukebox has been paused.","#DA0808","#1EBCC1");
  3352. }
  3353. else if(url == jukeboxplayerURL && Date.now()-timestamp >= 2000){
  3354. jukeboxplayer.volume = jukeboxplayervolume/100;
  3355. displayInChat("The jukebox has been unpaused or reset.","#DA0808","#1EBCC1",{sanitize:false});
  3356. jukeboxplayer.play();
  3357. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3358. }
  3359. else{
  3360. var id = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/)[0].split("?v=");
  3361. id = id[id.length-1];
  3362. var loaded = false;
  3363. var loaded2 = 0;
  3364. for(var inst = 0;inst<pipedindexes.length;inst++){
  3365. checkJukeboxStream(pipedindexes[inst],id).then(function(value){
  3366. loaded2+=1;
  3367. if(value!=-1 && !loaded){
  3368. loaded = true;
  3369. jukeboxplayer.src = value[0];
  3370. jukeboxplayer.volume = jukeboxplayervolume/100;
  3371. jukeboxplayerURL = url;
  3372. jukeboxplayer.oncanplaythrough = function(){
  3373. displayInChat("The jukebox has been changed to: ","#DA0808","#1EBCC1",{sanitize:false},url);
  3374. displayInChat("Jukebox is now playing: "+value[1]+" by "+value[2]+".","#DA0808","#1EBCC1");
  3375. jukeboxplayer.play();
  3376. jukeboxplayer.currentTime = (Date.now()-timestamp)/1000;
  3377. jukeboxplayer.oncanplaythrough = null;
  3378. };
  3379. jukeboxplayer.onerror = function(){
  3380. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3381. };
  3382. }
  3383. });
  3384. }
  3385. new Promise(function(r){
  3386. var interv = setInterval(function(){
  3387. if(loaded2>=pipedindexes.length){
  3388. if(!loaded){
  3389. displayInChat("The jukebox failed to load. Please try again.","#DA0808","#1EBCC1");
  3390. }
  3391. clearInterval(interv);
  3392. }
  3393. },60)
  3394. });
  3395. }
  3396. };
  3397. scope.help = ["All the commands are:","/help","/?","/advhelp [command]","/space","/rcaps","/number","/autocorrect","/translateto [language]","/translate [language]","/randomchat","/speech","/savedroom","/clearsavedroom","/pan","/resetpan","/style [R G B]","/maxfps","/textmode [1-7]","/followcam","/autocam","/zoom [in/out/reset]","/xray","/aimbot","/heavybot","/still","/echo [username]","/clearecho","/remove [username]","/echotext [text]","/chatw [username]","/msg [text]","/ignorepm [username]","/record [username]","/replay","/stoprecord","/loadrecording [text]","/saverecording [text]","/delrecording [text]","/volume [0-100]","/pmusers","/pollstat","/lobby","/score","/team [letter]","/mode [mode]","/scroll","/hidechat","/showchat","/notify","/stopnotify","/support","Host commands are:","/startqp","/stopqp","/pauseqp","/revqp","/next","/nextafter [seconds]","/previous","/shuffle","/instaqp","/jukebox [link]","/pausejukebox","/resetjukebox","/playjukebox","/freejoin","/recmode","/recteam","/defaultmode [mode]","/start","/balanceA [number]","/moveA [letter]","/moveT [letter] [letter]","/balanceT [letter] [number]","/killA","/rounds [number]","/roundsperqp [number]","/disablekeys [keys]","/jointext [text]","/jointeam [letter]","/wintext [text]","/autorecord","/afkkill [number]","/ban [username]","/kill [username]","/resetpoll","/addoption [text]","/deloption [letter]","/startpoll [seconds]","/endpoll","/autokick","/autoban","/sandbox","Sandbox commands are:","/addplayer [number]","/addname [text]","/delplayer [number]","/copy [username]","Debugging commands are:","/eval [code]","/debugger","Hotkeys are:","Alt L","Alt B","Alt C","Alt I","Alt <","Alt >","Alt N","Alt V","Alt G","Alt H","Alt J","Alt W","Host hotkeys are:","Alt S","Alt P","Alt T","Alt E","Alt K","Alt M","Alt Q","Alt A","Alt D","Alt F","Alt R","Alt [","Alt ]"];
  3398. scope.adv_help = {"help":"Shows all command names.",
  3399. "?":"Shows all command names.",
  3400. "advhelp":"Shows a command in detail.",
  3401. "space":"Toggles space. When space is on, whatever you type will be spaced apart.",
  3402. "rcaps":"Toggles rcaps. When rcaps is on, each letter will randomly get capitalized.",
  3403. "number":"Toggles number. When number is on, 'a' becomes 4, 'e' becomes 3, 's' becomes 5, 'o' becomes 0, 'l' and 'i' become 1.",
  3404. "speech":"Turns on text to speech for the chat.",
  3405. "savedroom":"Displays all the rooms you have saved, you can remove individual ones from the saved rooms by clicking \"Remove\".",
  3406. "maxfps":"Toggles maxfps. When maxfps is on, your fps will be increased.",
  3407. "clearsavedroom":"Clears all the saved rooms.",
  3408. "echo":"Echoes a username. It copies the username's chat messages.",
  3409. "echotext":"Sets a message when someone who is echoed chats. \"message\" will get replaced by the person's message. \"username\" will get replaced by the person's username.",
  3410. "remove":"Removes username from echo list. You will not echo that username anymore.",
  3411. "clearecho":"Clears echo list. You will not echo anyone anymore.",
  3412. "chatw":"It private chats with username. Type /msg to message that username.",
  3413. "msg":"Messages with what username you are chatting with. Type /chatw to chat with a username.",
  3414. "ignorepm":"Ignores the username's private chat messages. To unignore, type '/ignorepm [username]'.",
  3415. "pmusers":"Dispays who you can private chat with.",
  3416. "pollstat":"Displays the current poll and its votes.",
  3417. "textmode":"Changes the text font.",
  3418. "eval":"Evaluates code. Only use this if you are experienced in javascript.",
  3419. "debugger":"Opens debugger.",
  3420. "style":"Change the color of your username, level, and background. For example, '/style 255 0 0' will make your username red.",
  3421. "translate":"Translates peoples texts to the chosen language.",
  3422. "translateto":"You will now speak the chosen language.",
  3423. "autocorrect":"Fixes spelling mistakes.",
  3424. "randomchat":"Spams random chat messages from the past.",
  3425. "lobby":"Makes lobby visible when you are ingame. Type '/lobby' again to close lobby.",
  3426. "score":"Displays the current score while ingame. Type '/score' again to hide the score.",
  3427. "pan":"Toggles pan mode. Use Shift+Arrow Keys to move the camera around.",
  3428. "resetpan":"Resets pan.",
  3429. "team":"Joins a specific team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3430. "scroll":"Toggles a scrollbar in ingame chat.",
  3431. "followcam":"Enables follow camera. Your character will be centered on the screen.",
  3432. "autocam":"Zooms in/out enough for you to see everyone on the screen.",
  3433. "zoom":"Zooms in, out, or resets zoom.",
  3434. "xray":"Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3435. "aimbot":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3436. "heavybot":"Enables heavy bot. Heavy bot will heavy right before collision. Turn this off when player collision is off, because heavy bot will still function.",
  3437. "still":"Saves your position, and tries to reach it constantly. This is useful in parkour if you want to go afk. Use Alt+W instead, because this feature will fail when you are in chat.",
  3438. "lagbot":"Makes your movements very laggy. Type '/lagbot 0' to turn it off.",
  3439. "hidechat":"Hides ingame chat. Type '/showchat' to show it again.",
  3440. "showchat":"Shows ingame chat. '/hidechat' hides the chat.",
  3441. "notify":"You will be notified if a person types @username",
  3442. "stopnotify":"You will not be notified if a person types @username",
  3443. "support":"Displays all the people who have supported this mod.",
  3444. "startqp":"Starts cycling maps in your map menu.",
  3445. "stopqp":"Stops cycling maps in your map menu.",
  3446. "revqp":"Reverses the order of quickplay. '/next', '/previous' will be inverted.",
  3447. "pauseqp":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3448. "next":"Skips the map. Usable only with '/startqp'.",
  3449. "nextafter":"Skips the map if no one is able to win/draw within a certain amount of time.",
  3450. "previous":"Goes to previous map. Usable only with '/startqp'.",
  3451. "shuffle":"Makes quickplay play random maps instead of in order.",
  3452. "freejoin":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3453. "recmode":"In quickplay, it switches mode to recommended mode, according to editor.",
  3454. "recteam":"In quickplay, it sorts people into teams when teams are necessary.",
  3455. "defaultmode":"Switches mode to defaultmode if there is no recmode.",
  3456. "start":"Starts game instantly.",
  3457. "instaqp":"Rounds will instantly start without a countdown.",
  3458. "balanceA":"Balances everyone with balance number.",
  3459. "moveA":"Sets everyones team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3460. "balanceT":"Sets everyones balance to the number. The team is 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3461. "killA":"Kills everyone.",
  3462. "jointeam":"Sets the team of anyone who joins. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3463. "moveT":"Sets everyone in one team to another team. 'r' = red, 'b' = blue, 'g' = green, 'y' = yellow, and 's' = spectate.",
  3464. "rounds":"Sets rounds to win.",
  3465. "replay":"Replays the movements that were recorded",
  3466. "record":"Records movements of the username",
  3467. "delrecording":"Deletes the recording with the name.",
  3468. "saverecording":"Saves the recording with the name.",
  3469. "loadrecording":"Loads the recording with the name. Type '/replay' to replay it.",
  3470. "stoprecord":"Stops recording the player. Type '/saverecording [text]' to save it.",
  3471. "jukebox":"Sets the jukebox to a link. That link will play for everyone who has this mod.",
  3472. "volume":"Sets the volume of the jukebox.",
  3473. "pausejukebox":"If the jukebox is playing, it pauses it.",
  3474. "resetjukebox":"Resets the jukebox, so it starts from the very beginning.",
  3475. "playjukebox":"If the jukebox is paused, it plays it.",
  3476. "roundsperqp":"After that many rounds, the map will change. Normally, the map will change after 1 round.",
  3477. "autorecord":"After a round ends, automatically records the last 15 seconds.",
  3478. "mode":"If host, switches mode. Otherwise, it requests the host to switch mode, as long as the host has this mod.",
  3479. "disablekeys":"If anyone presses a disabled key, they get killed. Key options: left right up down heavy special.",
  3480. "jointext":"Chats the jointext whenever someone joins. \"username\" will get replaced by the joining person's username.",
  3481. "wintext":"Chats the wintext whenever someone wins. \"username\" will get replaced by the winning person's username.",
  3482. "afkkill":"If a person stays afk for that many seconds, they get automatically killed.",
  3483. "ban":"Bans username from lobby. If they rejoin, it automatically bans.",
  3484. "kill":"Kills the person ingame.",
  3485. "resetpoll":"Clears the poll.",
  3486. "addoption":"Adds the option to the poll. You can only have 4 maximum options. Type '/deloption [letter]' to remove an option.",
  3487. "deloption":"Removes the option with that letter.",
  3488. "startpoll":"Starts a poll that lasts for at least 10 seconds. Type '/endpoll' to end it early.",
  3489. "endpoll":"Ends the poll early if the poll lasted for at least 10 seconds.",
  3490. "addplayer":"In sandbox, it adds bots.",
  3491. "addname":"Adds a bot with a specific name. If that name already exists, it will copy the skin of that player to the bot.",
  3492. "delplayer":"In sandbox, it deletes bots.",
  3493. "copy":"In sandbox, it makes all bots copy the username's movements.",
  3494. "sandbox":"Turns a normal lobby into a sandbox lobby. You cannot turn a sandbox lobby back into a normal lobby.",
  3495. "autokick":"Automatically kicks everyone who is not using this mod.",
  3496. "autoban":"Automatically bans everyone who is not using this mod.",
  3497. "Alt L":"Makes lobby visible when you are ingame. Press Alt L again to close lobby.",
  3498. "Alt C":"Hides ingame chat. Press Alt C again to show ingame chat.",
  3499. "Alt S":"Starts game instantly.",
  3500. "Alt T":"Toggles teams.",
  3501. "Alt N":"Enables follow camera. Your character will be centered on the screen.",
  3502. "Alt G":"Zooms in.",
  3503. "Alt H":"Resets zoom.",
  3504. "Alt J":"Zooms out.",
  3505. "Alt Y":"Enables xray. Removes all shapes that don't have a shadow. This means all non-physics shapes will be hidden.",
  3506. "Alt E":"Toggles editor.",
  3507. "Alt K":"Exits ingame and returns to lobby.",
  3508. "Alt M":"Switches modes.",
  3509. "Alt V":"Toggles autocam. Autocam zooms in/out enough for you to see everyone on the screen.",
  3510. "Alt Q":"Toggles quickplay.",
  3511. "Alt B":"Displays the current score while ingame. Press Alt B again to hide the score.",
  3512. "Alt A":"Skips the map if quickplay is on.",
  3513. "Alt D":"Goes to previous map if quickplay is on.",
  3514. "Alt F":"Toggles freejoin. If freejoin is on, starts the game instantly if there are 1 or less players currently playing.",
  3515. "Alt O":"Enables heavy bot. Heavy bot will heavy right before collision. Turn this off when player collision is off, because heavy bot will still function.",
  3516. "Alt U":"Toggles aimbot. Aimbot will aim for you in arrows or death arrows mode.",
  3517. "Alt P":"Only pauses or unpauses the quickplay cycle due to round end. '/next', '/previous' still work. Type 'pauseqp' to unpause quickplay.",
  3518. "Alt R":"In quickplay, it switches mode to recommended mode, according to editor.",
  3519. "Alt I":"Opens debugger.",
  3520. "Alt W":"Saves your position, and tries to reach it constantly. This is useful in parkour if you want to go afk.",
  3521. "Alt <":"Lowers ingame chat height.",
  3522. "Alt >":"Highers ingame chat height.",
  3523. "Alt [":"Toggles pan mode. Use Shift+Arrow Keys to move the camera around.",
  3524. "Alt ]":"Resets pan."
  3525. };
  3526. scope.displayadvhelp = function(command){
  3527. displayInChat(adv_help[command],"#009398","#DA0808",{sanitize:true},"",true);
  3528. };
  3529. scope.changemode = function(mode){
  3530. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  3531. RECIEVE('42[26,"b","'+mode+'"]');
  3532. };
  3533. Gdocument.getElementById("ingamechatcontent").style["pointer-events"]="all";
  3534. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  3535. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  3536. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  3537. document.getElementById('adboxverticalCurse').style["display"] = "none";
  3538. document.getElementById('adboxverticalleftCurse').style["display"] = "none";
  3539. elem.onclick=function(e){
  3540. if(stopquickplay==0 && ishost == true && e.isTrusted == true){
  3541. quicki = (Array.from(e.target.parentElement.parentNode.children).indexOf(e.target.parentNode)-1)%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3542. if(reverseqp){
  3543. quicki+=2;
  3544. quicki = quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length);
  3545. }
  3546. }
  3547. };
  3548. scope.getCurrentFrame = function(){
  3549. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  3550. return currentFrame;
  3551. };
  3552. scope.urlify = function(text) {
  3553. if(!Gdocument.getElementById('bl_Menu')){
  3554. return text.replace(/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:;%.\-_\+~#=]{2,256}\.[\-a-z]{2,6}\b([\-a-zA-Z0-9@:;%_\+.~#?&//=]*)/ig, function(url) {
  3555. var extratext = "";
  3556. var matches = url.match(/youtu\.?be.com\/watch\?.*v=[a-z|A-Z|0-9|_|-]{11}/);
  3557. if(matches){
  3558. var button = Gdocument.createElement("a");
  3559. button.style["color"] = "green";
  3560. button.textContent = "Play";
  3561. button.href = "javascript:void(0)";
  3562. button.setAttribute("onclick",function(){
  3563. if(Gwindow.ishost){
  3564. Gwindow.SEND("42"+JSON.stringify([4,{"type":"video player","from":Gwindow.username,"url":"URL INSERT HERE","timestamp":Gwindow.Date.now()+2000,"to":[-1]}]));
  3565. Gwindow.displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  3566. Gwindow.changeJukeboxURL("URL INSERT HERE",Gwindow.Date.now()+2000);
  3567. }
  3568. else{
  3569. Gwindow.displayInChat("You need to be host.","#DA0808","#1EBCC1");
  3570. }
  3571. });
  3572. button.attributes["onclick"].nodeValue = button.attributes["onclick"].nodeValue.slice(11,-1).replaceAll("URL INSERT HERE","https://www."+matches[0]);
  3573. var extratext = ' ['+button.outerHTML+']';
  3574. }
  3575. if(url.startsWith('https://') || url.startsWith('http://')){return '<a href="' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3576. else{return '<a href="https://' + url + '" target="_blank" style = "color:orange">' + sanitize(url) + '</a>'+extratext;}
  3577. })}return text;
  3578. };
  3579. scope.fire = function(type,options,d = Gdocument){
  3580. var event= document.createEvent("HTMLEvents");
  3581. event.initEvent(type,true,false);
  3582. for(var p in options){
  3583. event[p]=options[p];
  3584. }
  3585. d.dispatchEvent(event);
  3586. };
  3587. scope.chat = function(message){
  3588. SEND('42[10,{"message":'+JSON.stringify(message)+'}]');
  3589. };
  3590. scope.chat2 = function(message,enteragain=false){
  3591. mess = Gdocument.getElementById("newbonklobby_chat_input").value;
  3592. mess2 = Gdocument.getElementById("ingamechatinputtext").value;
  3593. Gdocument.getElementById("newbonklobby_chat_input").value = message;
  3594. Gdocument.getElementById("ingamechatinputtext").value = message;
  3595. fire("keydown",{keyCode:13});
  3596. if(!enteragain){
  3597. fire("keydown",{keyCode:13});
  3598. }
  3599. Gdocument.getElementById("newbonklobby_chat_input").value = mess;
  3600. Gdocument.getElementById("ingamechatinputtext").value = mess2;
  3601. };
  3602. scope.sanitize = function(message){
  3603. return message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;');
  3604. };
  3605. scope.displayInChat = function(message, LobbyColor, InGameColor, options, message2, BringDown) {
  3606. options = options ?? {};
  3607. BringDown = BringDown ?? false;
  3608. message2 = message2 ?? "";
  3609. LobbyColor = LobbyColor ?? "#8800FF";
  3610. InGameColor = InGameColor ?? "#AA88FF";
  3611. var A = Gdocument.createElement("div");
  3612. var B = Gdocument.createElement("span");
  3613. B.className = "newbonklobby_chat_status";
  3614. B.style.color = LobbyColor;
  3615. A.appendChild(B);
  3616. B.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3617. B.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3618. var C = Gdocument.createElement("div");
  3619. var D = Gdocument.createElement("span");
  3620. D.style.color = InGameColor;
  3621. C.appendChild(D);
  3622. D.innerHTML = (options.sanitize ?? true) ? message.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : message;
  3623. D.innerHTML+=urlify(message2.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'));
  3624. var a = BringDown;
  3625. if(Gdocument.getElementById("newbonklobby_chat_content").clientHeight + Gdocument.getElementById("newbonklobby_chat_content").scrollTop >= Gdocument.getElementById("newbonklobby_chat_content").scrollHeight-1) {
  3626. a = true;
  3627. }
  3628. var b = BringDown;
  3629. if(Gdocument.getElementById("ingamechatcontent").clientHeight + Gdocument.getElementById("ingamechatcontent").scrollTop >= Gdocument.getElementById("ingamechatcontent").scrollHeight-1) {
  3630. b = true;
  3631. }
  3632. A.style["parsed"] = true;
  3633. C.style["parsed"] = true;
  3634. Gdocument.getElementById("newbonklobby_chat_content").appendChild(A);
  3635. Gdocument.getElementById("ingamechatcontent").appendChild(C);
  3636. if (a) { Gdocument.getElementById("newbonklobby_chat_content").scrollTop = Gdocument.getElementById("newbonklobby_chat_content").scrollHeight;};
  3637. if (b) { Gdocument.getElementById("ingamechatcontent").scrollTop = Gdocument.getElementById("ingamechatcontent").scrollHeight;};
  3638. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"]!="auto" && !Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  3639. chat2("");
  3640. }
  3641. };
  3642. scope.lobby = function(){
  3643. if (Gdocument.getElementById("newbonklobby").style["display"]=="none"){
  3644. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3645. Gdocument.getElementById("mapeditor_close").click();
  3646. if(Gdocument.getElementById("newbonklobby_playerbox_elementcontainer").children.length+Gdocument.getElementById("newbonklobby_specbox_elementcontainer").children.length-3>0){
  3647. Gdocument.getElementById("newbonklobby").style["z-index"]=1;
  3648. Gdocument.getElementById("maploadwindowcontainer").style["z-index"]=1;
  3649. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=1;
  3650. Gdocument.getElementById("pretty_top").style["z-index"]=3;
  3651. Gdocument.getElementById("settingsContainer").style["z-index"]=3;
  3652. Gdocument.getElementById("leaveconfirmwindow").style["z-index"]=3;
  3653. Gdocument.getElementById("hostleaveconfirmwindow").style["z-index"]=3;
  3654. debuggermenu.style["z-index"] = 2;
  3655. }
  3656. else{
  3657. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3658. Gdocument.getElementById("newbonklobby").style["display"]="none";
  3659. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3660. }
  3661. }
  3662. else if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  3663. Gdocument.getElementById("newbonklobby").style["opacity"]=0;
  3664. Gdocument.getElementById("newbonklobby").style["display"]="none";
  3665. Gdocument.getElementById("mapeditorcontainer").style["z-index"]=0;
  3666. }
  3667. };
  3668. scope.lastmessage = function(){
  3669. if(Gdocument.getElementById("newbonklobby_chat_content").children.length!=0){
  3670. var lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  3671. var lm2 = "";
  3672. for(var i = 0; i<lm.length;i++){
  3673. lm2+=" "+lm[i].textContent.trim();
  3674. }
  3675. lm2 = lm2.trim();
  3676. if(lm2.startsWith("*")){
  3677. return lm2;
  3678. }
  3679. }
  3680. if(Gdocument.getElementById("ingamechatcontent").children.length!=0){
  3681. var lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  3682. var lm2 = "";
  3683. for(var i = 0; i<lm.length;i++){
  3684. lm2+=" "+lm[i].textContent.trim();
  3685. }
  3686. return lm2.trim();
  3687. }
  3688. return "";
  3689. };
  3690. scope.map = function(e,t=timedelay){
  3691. if(e<0){
  3692. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3693. quicki = 0;
  3694. return;
  3695. }
  3696. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3697. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3698. return;
  3699. }
  3700. setTimeout(function(){if(!canceled){
  3701. startedinqp = true;
  3702. if(roundsperqp2>=roundsperqp){
  3703. roundsperqp2 = 0;
  3704. }
  3705. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3706. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3707. if(recmodebool && ishost){
  3708. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3709. if(mode == "" && defaultmode!="d"){
  3710. mode = defaultmode;
  3711. }
  3712. if(mode != ""){
  3713. RECIEVE('42[26,"b","'+mode+'"]');
  3714. }
  3715. }
  3716. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3717. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3718. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3719. if(displayblock){
  3720. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3721. }
  3722. Gdocument.getElementById("mapeditor_midbox_testbutton").click();}
  3723. canceled = false;
  3724. transitioning = false;
  3725. },t);
  3726. };
  3727. scope.gotonextmap = function(e){
  3728. if(e<0){
  3729. displayInChat("There is no previous map.","#DA0808","#1EBCC1");
  3730. quicki = 0;
  3731. return;
  3732. }
  3733. if(Gdocument.getElementById("maploadwindowmapscontainer").children[e] == undefined){
  3734. displayInChat("Click the maps button.","#DA0808","#1EBCC1");
  3735. return;
  3736. }
  3737. Gdocument.getElementById("maploadwindowmapscontainer").children[e].click();
  3738. Gdocument.getElementById("newbonklobby_editorbutton").click();
  3739. if(recmodebool && ishost){
  3740. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  3741. if(mode == "" && defaultmode!="d"){
  3742. mode = defaultmode;
  3743. }
  3744. if(mode != ""){
  3745. RECIEVE('42[26,"b","'+mode+'"]');
  3746. }
  3747. }
  3748. startedinqp = true;
  3749. if(roundsperqp2>=roundsperqp){
  3750. roundsperqp2 = 0;
  3751. }
  3752. var displayblock = Gdocument.getElementById("newbonklobby").style["display"] == "block";
  3753. Gdocument.getElementById("mapeditorcontainer").style["display"] = "none";
  3754. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  3755. if(displayblock){
  3756. Gdocument.getElementById("newbonklobby").style["display"] = "block";
  3757. }
  3758. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  3759. Gdocument.getElementById("newbonklobby").style["visibility"] = "visible";
  3760. };
  3761. scope.commandhandle = function(chat_val){
  3762. if (chat_val.substring(1,6)=="echo " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3763. if (chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")==username){
  3764. displayInChat("You cannot echo yourself.","#DA0808","#1EBCC1");
  3765. return "";
  3766. }
  3767. else if (echo_list.indexOf(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))===-1) {
  3768. echo_list.push(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  3769. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is being echoed.","#DA0808","#1EBCC1");
  3770. return "";
  3771. }
  3772. else{
  3773. displayInChat(chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + " is already being echoed.","#DA0808","#1EBCC1");
  3774. return "";
  3775. }
  3776. }
  3777. else if (chat_val.substring(1,8)=="remove " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3778. if (echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""))!==-1){
  3779. echo_list.splice(echo_list.indexOf(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")),1);
  3780. displayInChat(chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+" is not being echoed.","#DA0808","#1EBCC1");
  3781. return "";
  3782. }
  3783. else{
  3784. displayInChat("You cannot remove someone that you didn't echo.","#DA0808","#1EBCC1");
  3785. return "";
  3786. }
  3787. }
  3788. else if (chat_val.substring(1,10)=="echotext " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  3789. echotext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  3790. displayInChat("Set echotext as: "+echotext,"#DA0808","#1EBCC1");
  3791. displayInChat("Type '/echotext' to reset echotext.","#DA0808","#1EBCC1");
  3792. return "";
  3793. }
  3794. else if (chat_val.substring(1,9)=="echotext"){
  3795. echotext = "message";
  3796. displayInChat("Reset echotext.","#DA0808","#1EBCC1");
  3797. return "";
  3798. }
  3799. else if (chat_val.substring(1,10)=="clearecho"){
  3800. echo_list = [];
  3801. displayInChat("Cleared the echo list.","#DA0808","#1EBCC1");
  3802. return "";
  3803. }
  3804. else if (chat_val.substring(1,11)=="randomchat"){
  3805. if(randomchat == true){
  3806. displayInChat("Random chat is now off.","#DA0808","#1EBCC1");
  3807. randomchat = false;
  3808. }
  3809. else{
  3810. displayInChat("Random chat is now on.","#DA0808","#1EBCC1");
  3811. randomchat = true;
  3812. }
  3813. return "";
  3814. }
  3815. else if (chat_val.substring(1,12)=="autocorrect"){
  3816. if(autocorrect == true){
  3817. displayInChat("Autocorrect is now off.","#DA0808","#1EBCC1");
  3818. autocorrect = false;
  3819. }
  3820. else{
  3821. displayInChat("Autocorrect is now on.","#DA0808","#1EBCC1");
  3822. autocorrect = true;
  3823. }
  3824. return "";
  3825. }
  3826. else if (chat_val.substring(1,13)=="translateto " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  3827. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '').toLowerCase();
  3828. var keys = Object.keys(translatingkeys);
  3829. if(keys.includes(text)){
  3830. translating2 = [true,translatingkeys[text]];
  3831. displayInChat("You will now speak the "+text+" language.","#DA0808","#1EBCC1");
  3832. }
  3833. else{
  3834. displayInChat("Invalid language. Here are the current language options:","#DA0808","#1EBCC1");
  3835. for(var i = 0;i<keys.length;i++){
  3836. displayInChat(keys[i],"#DA0808","#1EBCC1");
  3837. }
  3838. }
  3839. return "";
  3840. }
  3841. else if (chat_val.substring(1,12)=="translateto"){
  3842. translating2 = [false,""];
  3843. displayInChat("You will not speak another language anymore.","#DA0808","#1EBCC1");
  3844. return "";
  3845. }
  3846. else if (chat_val.substring(1,11)=="translate " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  3847. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '').toLowerCase();
  3848. var keys = Object.keys(translatingkeys);
  3849. if(keys.includes(text)){
  3850. translating = [true,translatingkeys[text]];
  3851. displayInChat("Translator has been set to the "+text+" language.","#DA0808","#1EBCC1");
  3852. }
  3853. else{
  3854. displayInChat("Invalid language. Here are the current language options:","#DA0808","#1EBCC1");
  3855. for(var i = 0;i<keys.length;i++){
  3856. displayInChat(keys[i],"#DA0808","#1EBCC1");
  3857. }
  3858. }
  3859. return "";
  3860. }
  3861. else if (chat_val.substring(1,10)=="translate"){
  3862. translating = [false,""];
  3863. displayInChat("Translator has been turned off.","#DA0808","#1EBCC1");
  3864. return "";
  3865. }
  3866. else if (chat_val.substring(1,6)=="space"){
  3867. if(space_flag == true){
  3868. displayInChat("Space is now off.","#DA0808","#1EBCC1");
  3869. space_flag = false;
  3870. }
  3871. else{
  3872. displayInChat("Space is now on.","#DA0808","#1EBCC1");
  3873. space_flag = true;
  3874. }
  3875. return "";
  3876. }
  3877. else if (chat_val.substring(1,6)=="rcaps"){
  3878. if(rcaps_flag == true){
  3879. displayInChat("Rcaps is now off.","#DA0808","#1EBCC1");
  3880. rcaps_flag = false;
  3881. }
  3882. else{
  3883. displayInChat("Rcaps is now on.","#DA0808","#1EBCC1");
  3884. rcaps_flag = true;
  3885. }
  3886. return "";
  3887. }
  3888. else if (chat_val.substring(1,7)=="number"){
  3889. if(number_flag == true){
  3890. displayInChat("Number is now off.","#DA0808","#1EBCC1");
  3891. number_flag = false;
  3892. }
  3893. else{
  3894. displayInChat("Number is now on.","#DA0808","#1EBCC1");
  3895. number_flag = true;
  3896. }
  3897. return "";
  3898. }
  3899. else if (chat_val.substring(1,8)=="reverse"){
  3900. if(reverse_flag == true){
  3901. displayInChat("Reverse is now off.","#DA0808","#1EBCC1");
  3902. reverse_flag = false;
  3903. }
  3904. else{
  3905. displayInChat("Reverse is now on.","#DA0808","#1EBCC1");
  3906. reverse_flag = true;
  3907. }
  3908. return "";
  3909. }
  3910. else if (chat_val.substring(1,7)=="speech"){
  3911. if(text2speech == true){
  3912. displayInChat("Text to speech is now off.","#DA0808","#1EBCC1");
  3913. text2speech = false;
  3914. }
  3915. else{
  3916. displayInChat("Text to speech is now on.","#DA0808","#1EBCC1");
  3917. text2speech = true;
  3918. }
  3919. return "";
  3920. }
  3921. else if (chat_val.substring(1,7)=="maxfps"){
  3922. if(maxfps){
  3923. displayInChat("Max FPS is now off.","#DA0808","#1EBCC1");
  3924. maxfps = false;
  3925. }
  3926. else{
  3927. displayInChat("Max FPS is now on.","#DA0808","#1EBCC1");
  3928. maxfps = true;
  3929. }
  3930. return "";
  3931. }
  3932. else if (chat_val.substring(1,6)=="eval " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  3933. var ev = "";
  3934. try{
  3935. ev = eval(chat_val.substring(6).replace(/^\s+|\s+$/g, ''));
  3936. }
  3937. catch(e){
  3938. displayInChat(e.message,"#DA0808","#1EBCC1");
  3939. }
  3940. try{
  3941. displayInChat(ev.toString(),"#DA0808","#1EBCC1");
  3942. }
  3943. catch{
  3944. }
  3945. return "";
  3946. }
  3947. else if (chat_val.substring(1,10)=="textmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  3948. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  3949. var parsed = parseInt(text);
  3950. if(!isNaN(parsed)){
  3951. if(parsed<=7 && parsed>=1){
  3952. textmode = parsed-1;
  3953. displayInChat("Type '/textmode' to reset textmode.","#DA0808","#1EBCC1");
  3954. }
  3955. else{
  3956. displayInChat("Please enter a integer from 1-7 inclusive.","#DA0808","#1EBCC1");
  3957. }
  3958. }
  3959. else{
  3960. displayInChat("Please enter a integer from 1-7 inclusive.","#DA0808","#1EBCC1");
  3961. }
  3962. return "";
  3963.  
  3964. }
  3965. else if (chat_val.substring(1,9)=="textmode"){
  3966. textmode = -1;
  3967. displayInChat("Reset textmode.","#DA0808","#1EBCC1");
  3968. return "";
  3969. }
  3970. else if (chat_val.substring(1,10)=="savedroom"){
  3971. if(savedrooms.length == 0){
  3972. displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  3973. return "";
  3974. }
  3975. else{
  3976. var keys = Object.keys(savedroomsdata);
  3977. for(var i = 0;i<keys.length;i++){
  3978. var code = 'this.parentElement.remove();delete Gwindow.savedroomsdata["'+keys[i]+'"];Gwindow.savedrooms.splice(Gwindow.savedrooms.indexOf('+keys[i]+'),1);';
  3979. displayInChat('<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">Remove</a>'+' - ',"#DA0808","#1EBCC1",{sanitize:false},JSON.stringify(savedroomsdata[keys[i]].roomname)+" - "+savedroomsdata[keys[i]].players+"/"+savedroomsdata[keys[i]].maxplayers+" players.");
  3980. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  3981. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  3982. Laster_message = lastmessage();
  3983. }
  3984. }
  3985. return "";
  3986. }
  3987. else if (chat_val.substring(1,15)=="clearsavedroom"){
  3988. if(savedrooms.length == 0){
  3989. displayInChat("You do not have any saved rooms.","#DA0808","#1EBCC1");
  3990. return "";
  3991. }
  3992. else{
  3993. var keys = Object.keys(savedroomsdata);
  3994. for(var i = 0;i<keys.length;i++){
  3995. savedrooms.splice(savedrooms.indexOf(parseInt(keys[i])),1);
  3996. delete savedroomsdata[keys[i]];
  3997. }
  3998. }
  3999. return "";
  4000. }
  4001. else if (chat_val.substring(1,10)=="followcam"){
  4002. if(FollowCam == true){
  4003. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  4004. FollowCam = false;
  4005. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4006. var addto = {"children":[]};
  4007. for(var i = 0;i<parentDraw.children.length;i++){
  4008. if(parentDraw.children[i].constructor.name == "e"){
  4009. addto = parentDraw.children[i];
  4010. break;
  4011. }
  4012. }
  4013. var canv = 0;
  4014. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4015. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4016. canv = Gdocument.getElementById("gamerenderer").children[i];
  4017. break;
  4018. }
  4019. }
  4020. var width = parseInt(canv.style["width"]);
  4021. var height = parseInt(canv.style["height"]);
  4022. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4023. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4024. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4025. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4026. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  4027. pixiCircle.visible = false;
  4028. }
  4029. else{
  4030. pixiCircle.visible = true;
  4031. }
  4032. }
  4033. }
  4034. else{
  4035. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  4036. FollowCam = true;
  4037. }
  4038. return "";
  4039. }
  4040. else if (chat_val.substring(1,8)=="autocam"){
  4041. if(autocam == true){
  4042. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  4043. autocam = false
  4044. }
  4045. else{
  4046. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  4047. autocam = true;
  4048. }
  4049. return "";
  4050. }
  4051. else if (chat_val.substring(1,4)=="pan"){
  4052. if(pan_enabled == true){
  4053. displayInChat("Pan is now off.","#DA0808","#1EBCC1");
  4054. pan_enabled = false;
  4055. pan = {"x":0,"y":0};
  4056. }
  4057. else{
  4058. displayInChat("Pan is now on. Shift + Arrow Keys to pan.","#DA0808","#1EBCC1");
  4059. pan_enabled = true;
  4060. }
  4061. return "";
  4062. }
  4063. else if (chat_val.substring(1,9)=="resetpan"){
  4064. pan = {"x":0,"y":0};
  4065. displayInChat("Reset pan.","#DA0808","#1EBCC1");
  4066. return "";
  4067. }
  4068. else if (chat_val.substring(1,7)=="aimbot"){
  4069. if(aimbot == true){
  4070. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  4071. aimbot = false;
  4072. }
  4073. else{
  4074. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  4075. aimbot = true;
  4076. getplayerkeys();
  4077. }
  4078. return "";
  4079. }
  4080. else if (chat_val.substring(1,8)=="volume " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4081. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4082. if(!isNaN(parseInt(text))){
  4083. int_text = parseInt(text);
  4084. if(int_text>=0 && int_text<=100){
  4085. jukeboxplayer.volume = int_text/100;
  4086. jukeboxplayervolume = int_text;
  4087. displayInChat("Jukebox volume set to: "+int_text.toString()+" percent.","#DA0808","#1EBCC1");
  4088. }
  4089. else{
  4090. displayInChat("Volume must be between 0 and 100 percent.","#DA0808","#1EBCC1");
  4091. }
  4092. }
  4093. return "";
  4094. }
  4095. else if (chat_val.substring(1,6)=="still"){
  4096. if(staystill == true){
  4097. displayInChat("Still is now off.","#DA0808","#1EBCC1");
  4098. staystill = false;
  4099. staystillpos = [0,0];
  4100. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  4101. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  4102. }
  4103. else{
  4104. if(playerids[myid].playerData?.transform){
  4105. displayInChat("Still is now on.","#DA0808","#1EBCC1");
  4106. staystill = true;
  4107. staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  4108. getplayerkeys();
  4109. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  4110. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  4111. }
  4112. else{
  4113. displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  4114. }
  4115. }
  4116. return "";
  4117. }
  4118. else if (chat_val.substring(1,9)=="heavybot"){
  4119. if(heavybot == true){
  4120. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  4121. heavybot = false;
  4122. }
  4123. else{
  4124. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  4125. heavybot = true;
  4126. getplayerkeys();
  4127. }
  4128. return "";
  4129. }
  4130. else if (chat_val.substring(1,5)=="xray"){
  4131. Gdocument.getElementById("pretty_top_settings").click();
  4132. Gdocument.getElementById("settings_close").click();
  4133. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  4134. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  4135. return "";
  4136. }
  4137. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4138. var addto = {"children":[]};
  4139. for(var i = 0;i<parentDraw.children.length;i++){
  4140. if(parentDraw.children[i].constructor.name == "e"){
  4141. addto = parentDraw.children[i];
  4142. break;
  4143. }
  4144. }
  4145. var addto2 = {"children":[]};
  4146. for(var i = 0;i<addto.children.length;i++){
  4147. if(addto.children[i].constructor.name == "e"){
  4148. addto2 = addto.children[i];
  4149. break;
  4150. }
  4151. }
  4152. var checkxray = addto2.children[0];
  4153. var addto3 = addto2.children[0].children;
  4154. if(addto3.length==1){
  4155. checkxray = checkxray.children[0];
  4156. addto3 = addto3[0].children;
  4157. }
  4158. var xrayon = false;
  4159. if(checkxray.xrayon){
  4160. checkxray.xrayon = false;
  4161. xrayon = false;
  4162. }
  4163. else{
  4164. checkxray.xrayon = true;
  4165. xrayon = true;
  4166. }
  4167. if(xrayon){
  4168. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  4169. for(var i = 0;i<addto3.length;i++){
  4170. if(addto3[i].children.length>0){
  4171. var ids = [];
  4172. var ids2 = [];
  4173. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4174. addto3[i].children[i3].visible = false;
  4175. if(addto3[i].children[i3].children.length>0){
  4176. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  4177. if(addto3[i].children[i3].children[i4].geometry?.id){
  4178. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  4179. }
  4180. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  4181. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  4182. }
  4183. }
  4184. }
  4185. }
  4186. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  4187. if(addto3[i].children[i3].children.length==0){
  4188. if(addto3[i].children[i3].geometry?.id){
  4189. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  4190. addto3[i].children[i3].visible = true;
  4191. addto3[i].children[i3].alpha = 0.5;
  4192. }
  4193. }
  4194. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  4195. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  4196. addto3[i].children[i3].visible = true;
  4197. addto3[i].children[i3].alpha = 0.5;
  4198. }
  4199. }
  4200. if(addto3[i].children[i3].batchDirty){
  4201. addto3[i].children[i3].visible = true;
  4202. addto3[i].children[i3].alpha = 0.5;
  4203. addto3[i].children[i3+1].visible = true;
  4204. addto3[i].children[i3+1].alpha = 0.5;
  4205. }
  4206.  
  4207. }
  4208. }
  4209. }
  4210. }
  4211. }
  4212. else{
  4213. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  4214. for(var i = 0;i<addto3.length;i++){
  4215. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  4216. addto3[i].children[i2].visible = true;
  4217. addto3[i].children[i2].alpha = 1;
  4218. }
  4219. }
  4220. }
  4221. }
  4222. return "";
  4223. }
  4224. else if (chat_val.substring(1,6)=="zoom "){
  4225. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4226. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4227. var addto = 0;
  4228. for(var i = 0;i<parentDraw.children.length;i++){
  4229. if(parentDraw.children[i].constructor.name == "e"){
  4230. addto = parentDraw.children[i];
  4231. break;
  4232. }
  4233. }
  4234. var canv = 0;
  4235. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  4236. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  4237. canv = Gdocument.getElementById("gamerenderer").children[i];
  4238. break;
  4239. }
  4240. }
  4241. var width = parseInt(canv.style["width"]);
  4242. var height = parseInt(canv.style["height"]);
  4243. if(addto){
  4244. if(text == "in"){
  4245. zoom *= 1.1;
  4246. }
  4247. else if(text == "out"){
  4248. zoom /= 1.1;
  4249. }
  4250. else if(text == "reset"){
  4251. zoom = 1;
  4252. }
  4253. else{
  4254. displayInChat("Options for zooming:","#DA0808","#1EBCC1");
  4255. displayInChat("in","#DA0808","#1EBCC1");
  4256. displayInChat("out","#DA0808","#1EBCC1");
  4257. displayInChat("reset","#DA0808","#1EBCC1");
  4258. return "";
  4259. }
  4260. addto.scale.x=zoom;
  4261. addto.scale.y=zoom;
  4262. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  4263. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  4264. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  4265. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  4266. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  4267. pixiCircle.visible = false;
  4268. }
  4269. else{
  4270. pixiCircle.visible = true;
  4271. }
  4272. }
  4273. }
  4274. return "";
  4275. }
  4276. else if (chat_val.substring(1,9)=="hidechat"){
  4277. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  4278. return "";
  4279. }
  4280. else if (chat_val.substring(1,9)=="showchat"){
  4281. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  4282. return "";
  4283. }
  4284. else if (chat_val.substring(1,6)=="score"){
  4285. var element = Gdocument.getElementById("ingamewinner_scores");
  4286. if(element.style["opacity"]<1){
  4287. element.style["opacity"] = 1;
  4288. element.style["visibility"] = "visible";
  4289. }
  4290. else{
  4291. element.style["opacity"] = 0;
  4292. element.style["visibility"] = "unset";
  4293. }
  4294. return "";
  4295. }
  4296. else if (chat_val.substring(1,7)=="scroll"){
  4297. if(scroll==false){
  4298. scroll = true;
  4299. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="scroll";
  4300. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  4301. }
  4302. else if(scroll==true){
  4303. scroll = false;
  4304. Gdocument.getElementById("ingamechatcontent").style["overflow-y"]="hidden";
  4305. Gdocument.getElementById("ingamechatcontent").style["overflow-x"]="hidden";
  4306. }
  4307. return "";
  4308. }
  4309. else if (chat_val.substring(1,7)=="chatw "){
  4310. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4311. if(username == text){
  4312. displayInChat("You cannot private chat with yourself.","#DA0808","#1EBCC1");
  4313. return "";
  4314. }
  4315. private_chat = text;
  4316. SEND("42"+JSON.stringify([4,{"type":"request public key","from":username,"to":private_chat}]));
  4317. request_public_key_time_stamp = Date.now();
  4318. setTimeout(function(){if(private_chat_public_key[0]!=private_chat){displayInChat("Failed to connect to "+private_chat+".","#DA0808","#1EBCC1");private_chat = private_chat_public_key[0];}},1600);
  4319. return "";
  4320. }
  4321. else if (chat_val.substring(1,8)=="lagbot " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4322. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  4323. if(!isNaN(parseInt(text))){
  4324. int_text = parseInt(text);
  4325. if(int_text == 0){
  4326. causelag = false;
  4327. causelag2 = 0;
  4328. displayInChat("Lagbot is now off.","#DA0808","#1EBCC1");
  4329. displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4330. }
  4331. else if(int_text>0 && int_text<=10){
  4332. causelag = true;
  4333. causelag2 = 45*int_text;
  4334. displayInChat("Lagbot is now on with a lag setting of "+int_text.toString()+" (~"+(45*int_text).toString()+"MS).","#DA0808","#1EBCC1");
  4335. displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4336. }
  4337. else{
  4338. displayInChat("To enable lagbot, type '/lagbot [number]' with a number between 1 and 10.","#DA0808","#1EBCC1");
  4339. displayInChat("Type '/lagbot 0' to turn off lagbot.","#DA0808","#1EBCC1");
  4340. }
  4341. return "";
  4342. }
  4343. }
  4344. else if (chat_val.substring(1,8)=="record " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  4345. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4346. var keys = Object.keys(playerids);
  4347. var recordingid2 = -1;
  4348. for(var i = 0;i<keys.length;i++){
  4349. if(playerids[keys[i]].userName == text){
  4350. recordingid2 = keys[i];
  4351. }
  4352. }
  4353. if(recordingid2 == -1){
  4354. displayInChat("Player not found. Please type a valid username.","#DA0808","#1EBCC1");
  4355. return "";
  4356. }
  4357. else{
  4358. recording = true;
  4359. recordingid = recordingid2;
  4360. displayInChat(playerids[recordingid].userName+" is now being recorded.","#DA0808","#1EBCC1");
  4361. if(recordingdata.length>0){
  4362. displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4363. }
  4364. recordingdata = [];
  4365. }
  4366. return "";
  4367. }
  4368. else if (chat_val.substring(1,11)=="stoprecord"){
  4369. if(recording){
  4370. displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4371. displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4372. recording = false;
  4373. recordingid = -1;
  4374. recordingdata[0][1] = 0;
  4375. }
  4376. else{
  4377. displayInChat("No one is being recorded.","#DA0808","#1EBCC1");
  4378. }
  4379. return "";
  4380. }
  4381. else if (chat_val.substring(1,15)=="saverecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4382. var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4383. if(Object.keys(recorddata).includes(text)){
  4384. displayInChat("This recording already exists. Please use a different name or type '/delrecording "+text+"'.","#DA0808","#1EBCC1");
  4385. }
  4386. else if(recordingdata.length>0){
  4387. recorddata[text] = JSON.parse(JSON.stringify(recordingdata));
  4388. displayInChat("Recording saved as: "+text,"#DA0808","#1EBCC1");
  4389. }
  4390. else{
  4391. displayInChat("There is no recording data to save. Please record data using '/record [username]'","#DA0808","#1EBCC1");
  4392. }
  4393. return "";
  4394. }
  4395. else if (chat_val.substring(1,14)=="delrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=15){
  4396. var text = chat_val.substring(14).replace(/^\s+|\s+$/g, '');
  4397. if(Object.keys(recorddata).includes(text)){
  4398. displayInChat("Recording deleted.","#DA0808","#1EBCC1");
  4399. delete recorddata[text];
  4400. }
  4401. else{
  4402. displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4403. }
  4404. return "";
  4405. }
  4406. else if (chat_val.substring(1,15)=="loadrecording " && chat_val.replace(/^\s+|\s+$/g, '').length>=16){
  4407. var text = chat_val.substring(15).replace(/^\s+|\s+$/g, '');
  4408. if(!Object.keys(recorddata).includes(text)){
  4409. displayInChat("This recording does not exist.","#DA0808","#1EBCC1");
  4410. }
  4411. else{
  4412. if(recordingdata.length>0){
  4413. displayInChat("Any unsaved recording data is now cleared.","#DA0808","#1EBCC1");
  4414. }
  4415. recordingdata = JSON.parse(JSON.stringify(recorddata[text]));
  4416. displayInChat("Recording data is now loaded.","#DA0808","#1EBCC1");
  4417. }
  4418. return "";
  4419. }
  4420. else if (chat_val.substring(1,7)=="replay"){
  4421. if(recording){
  4422. displayInChat(playerids[recordingid].userName+" is not being recorded anymore.","#DA0808","#1EBCC1");
  4423. displayInChat("Type '/saverecording [text]' to save this recording.","#DA0808","#1EBCC1");
  4424. recordingid = -1;
  4425. recording = false;
  4426. recordingdata[0][1] = 0;
  4427. }
  4428. replay();
  4429. return "";
  4430. }
  4431. else if (chat_val.substring(1,5)=="msg " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4432. if(private_chat_public_key[1][0] != 0 && private_chat_public_key[1][1] != 0 && private_chat_public_key[0] == private_chat){
  4433. var text = chat_val.substring(5).replace(/^\s+|\s+$/g, '');
  4434. pmlastmessage = text.slice(0,400);
  4435. ENCRYPT_MESSAGE(private_chat_public_key[1],text).then(function(e){
  4436. SEND("42"+JSON.stringify([4,{"type":"private chat","from":username,"to":private_chat,"message":e}]));
  4437. });
  4438. displayInChat("> "+username+": ","#DA0808","#1EBCC1",{sanitize:false},text,false);
  4439. Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true;
  4440. Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true;
  4441. Laster_message = lastmessage();
  4442. }
  4443. return "";
  4444. }
  4445. else if (chat_val.substring(1,10)=="ignorepm " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4446. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4447. if(ignorepmlist.includes(text)){
  4448. var index = ignorepmlist.indexOf(text);
  4449. ignorepmlist.splice(index,1);
  4450. displayInChat("You are not ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4451. }
  4452. else{
  4453. ignorepmlist.push(text);
  4454. displayInChat("You are now ignoring private messages from "+text+".","#DA0808","#1EBCC1");
  4455. }
  4456. return "";
  4457. }
  4458. else if (chat_val.substring(1,8)=="pmusers"){
  4459. pmusers = [];
  4460. SEND("42"+JSON.stringify([4,{"type":"request private chat users","from":username}]));
  4461. pmuserstimestamp = Date.now();
  4462. setTimeout(function(){if(pmusers.length == 0){displayInChat("You cannot private chat with anyone.","#DA0808","#1EBCC1");
  4463. }else{displayInChat("You can private chat with:","#DA0808","#1EBCC1");for(var i = 0;i<pmusers.length;i++){var code = 'Gwindow.private_chat = "'+pmusers[i]+'"; Gwindow.SEND("42"+JSON.stringify([4,{"type":"request public key","from":Gwindow.username,"to":Gwindow.private_chat}])); Gwindow.request_public_key_time_stamp = Date.now(); setTimeout(function(){if(Gwindow.private_chat_public_key[0]!=Gwindow.private_chat){Gwindow.displayInChat("Failed to connect to "+Gwindow.private_chat+".","#DA0808","#1EBCC1");Gwindow.private_chat = Gwindow.private_chat_public_key[0];}},1600);';displayInChat('<a onclick = \''+code+'\' href = "javascript:void(0);" style = "color:green">'+sanitize(pmusers[i])+'</a>',"#DA0808","#1EBCC1",{sanitize:false}); Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children[0].parentElement.style["parsed"] = true; Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children[0].parentElement.style["parsed"] = true; Laster_message = lastmessage(); }}},1600);
  4464. return "";
  4465. }
  4466. else if (chat_val.substring(1,6)=="lobby"){
  4467. lobby();
  4468. return "";
  4469. }
  4470. else if (chat_val.substring(1,7)=="style " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4471. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  4472. var text2 = text.split(" ");
  4473. var array = [];
  4474. for(var i = 0;i<text2.length;i++){
  4475. var parsed = parseInt(text2[i]);
  4476. if(!isNaN(parsed)){
  4477. array.push(parsed);
  4478. }
  4479. }
  4480. if(array[0]+array[1]+array[2] == 0){
  4481. array = [1,1,1];
  4482. }
  4483. if(array.length == 3){
  4484. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":array}]));
  4485. allstyles[username] = array;
  4486. mystyle = [...array];
  4487. displayInChat("Set style to ("+array.toString()+"). Type '/style' to reset style.","#DA0808","#1EBCC1");
  4488. }
  4489. else{
  4490. displayInChat("Please enter a valid RGB color code seperated by space. For example, white = '/style 255 255 255'. Type '/style' to reset style.","#DA0808","#1EBCC1");
  4491. }
  4492. return "";
  4493. }
  4494. else if (chat_val.substring(1,6)=="style"){
  4495. SEND("42"+JSON.stringify([4,{"type":"style","from":username,"style":[0,0,0]}]));
  4496. allstyles[username] = [0,0,0];
  4497. mystyle = [0,0,0];
  4498. displayInChat("Reset style.","#DA0808","#1EBCC1");
  4499. return "";
  4500. }
  4501. else if (chat_val.substring(1,6)=="lobby"){
  4502. lobby();
  4503. return "";
  4504. }
  4505. else if (chat_val.substring(1,9)=="debugger"){
  4506. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  4507. debuggeropen = true;
  4508. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  4509. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  4510. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  4511. }
  4512. else{
  4513. debuggeropen = false;
  4514. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  4515. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  4516. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  4517. }
  4518. return "";
  4519. }
  4520. else if (chat_val.substring(1,6)=="team " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4521. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4522. if(text == "r"){Gdocument.getElementById("newbonklobby_redbutton").click();}
  4523. else if(text == "g"){Gdocument.getElementById("newbonklobby_greenbutton").click();}
  4524. else if(text == "y"){Gdocument.getElementById("newbonklobby_yellowbutton").click();}
  4525. else if(text == "b"){Gdocument.getElementById("newbonklobby_bluebutton").click();}
  4526. else if(text == "s"){Gdocument.getElementById("newbonklobby_specbutton").click();}
  4527. else if(text == "f"){Gdocument.getElementById("newbonklobby_ffabutton").click();}
  4528. return "";
  4529. }
  4530. else if (chat_val.substring(1,7)=="notify"){
  4531. npermissions = 1;
  4532. return "";
  4533. }
  4534. else if (chat_val.substring(1,11)=="stopnotify"){
  4535. npermissions = 0;
  4536. return "";
  4537. }
  4538. else if (chat_val.substring(1,8)=="support"){
  4539. displayInChat("Thanks everyone for helping me make this mod - LEGENDBOSS123","#0000FF","#FFFFFF");
  4540. displayInChat("mastery3","#0000FF","#FFFFFF");
  4541. displayInChat("UnmatchedBracket aka Left Paren","#0000FF","#FFFFFF");
  4542. displayInChat("iNeonz","#0000FF","#FFFFFF");
  4543. return "";
  4544. }
  4545. else if (chat_val.substring(1,9)=="pollstat"){
  4546. if(pollactive[0] || pollactive2[0]){
  4547. var count = [0,0,0,0];
  4548. var keys = Object.keys(playerids);
  4549. for(var i = 0;i<keys.length;i++){
  4550. if(ishost){
  4551. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  4552. count[playerids[keys[i]].vote.poll]++;
  4553. }
  4554. }
  4555. else{
  4556. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive2[2].length-1){
  4557. count[playerids[keys[i]].vote.poll]++;
  4558. }
  4559. }
  4560. }
  4561. for(var i = 0;i<count.length;i++){
  4562. if(count[i]>1){
  4563. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4564. }
  4565. if(count[i]==1){
  4566. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  4567. }
  4568. }
  4569. if(ishost){
  4570. displayInChat("The poll will end in: "+((pollactive[2]-Date.now())/1000).toString()+" seconds.","#DA0808","#1EBCC1");
  4571. }
  4572. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4573. if(ishost){
  4574. for(var i = 0;i<pollactive[3].length;i++){
  4575. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  4576. }
  4577. }
  4578. else{
  4579. for(var i = 0;i<pollactive2[2].length;i++){
  4580. displayInChat(letters[i]+") "+pollactive2[2][i],"#DA0808","#1EBCC1");
  4581. }
  4582. }
  4583. }
  4584. else{
  4585. displayInChat("No poll has been started.","#DA0808","#1EBCC1");
  4586. if(ishost){
  4587. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  4588. if(poll.length>0){
  4589. displayInChat("The poll is:","#DA0808","#1EBCC1");
  4590. for(var i = 0;i<poll.length;i++){
  4591. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  4592. }
  4593. }
  4594. }
  4595. }
  4596. return "";
  4597. }
  4598. else if (chat_val.substring(1,5)=="help" || chat_val.substring(1,2)=="?"){
  4599. for(var i = 0;i<help.length;i++){
  4600. if(help[i].startsWith("/")){
  4601. var splitted = help[i].substring(1).split(" ");
  4602. var command = splitted[0];
  4603. var rest = "";
  4604. if(splitted.length>1){
  4605. rest = " "+splitted.slice(1).join(" ");
  4606. }
  4607. displayInChat("/"+'<a onclick = \'Gwindow.displayadvhelp("'+command+'");\' style = "color:green;" href = "javascript:void(0);">'+command+'</a>'+rest,"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4608. }
  4609. else if(help[i].startsWith("Alt ")){
  4610. displayInChat('<a onclick = \'Gwindow.displayadvhelp("'+help[i]+'");\' style = "color:green;" href = "javascript:void(0);">'+help[i]+'</a>',"#DA0808","#1EBCC1",{sanitize:false},"",false);
  4611. }
  4612. else{
  4613. displayInChat(help[i],"#DA0808","#1EBCC1");
  4614. }
  4615. }
  4616. return "";
  4617. }
  4618. else if (chat_val.substring(1,9)=="advhelp " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4619. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4620. if(typeof(adv_help[text])!='undefined'){
  4621. displayInChat(adv_help[text],"#DA0808","#1EBCC1");
  4622. }
  4623. return "";
  4624. }
  4625. else if (chat_val.substring(1,6)=="mode " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4626. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '');
  4627. var mode = "";
  4628. var text2 = text;
  4629. if(text == "arrows"){
  4630. text2 = "Arrows";
  4631. mode = "ar";
  4632. }
  4633. else if(text == "death arrows"){
  4634. mode = "ard";
  4635. text2 = "Death Arrows";
  4636. }
  4637. else if(text == "grapple"){
  4638. mode = "sp";
  4639. text2 = "Grapple";
  4640. }
  4641. else if(text == "classic"){
  4642. mode = "b";
  4643. text2 = "Classic";
  4644. }
  4645. else{
  4646. displayInChat("Mode options:","#DA0808","#1EBCC1");
  4647. displayInChat("classic","#DA0808","#1EBCC1");
  4648. displayInChat("arrows","#DA0808","#1EBCC1");
  4649. displayInChat("death arrows","#DA0808","#1EBCC1");
  4650. displayInChat("grapple","#DA0808","#1EBCC1");
  4651. }
  4652. if(mode != ""){
  4653. if(ishost){
  4654. SEND('42[20,{"ga":"b","mo":"'+mode+'"}]');
  4655. RECIEVE('42[26,"b","'+mode+'"]');
  4656. displayInChat("Changed mode to "+text+".","#DA0808","#1EBCC1");
  4657. }
  4658. else{
  4659. if(playerids[myid].ratelimit.mode+1000<Date.now()){
  4660. playerids[myid].ratelimit.mode=Date.now();
  4661. SEND("42"+JSON.stringify([4,{"type":"request mode","from":username,"mode":mode}]));
  4662. var code = 'if(!Gwindow.ishost){Gwindow.displayInChat("You must be host to change the mode.","#DA0808","#1EBCC1",{sanitize:false},"",true)}else{Gwindow.changemode("'+mode+'")}';
  4663. displayInChat('> '+username+' requests [<a onclick = \''+code+'\' style = "color:green;" href = "javascript:void(0);">'+text2+'</a>]',"#DA0808","#1EBCC1",{sanitize:false}," mode.");
  4664. }
  4665. else{
  4666. displayInChat("You are requesting modes too quickly.","#DA0808","#1EBCC1");
  4667. }
  4668. }
  4669. }
  4670. return "";
  4671. }
  4672. else if(ishost){
  4673. if (chat_val.substring(1,11)=="nextafter " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  4674. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  4675. if(isNaN(text)){
  4676. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4677. return "";
  4678. }
  4679. else if(text<=0){
  4680. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  4681. return "";
  4682. }
  4683. nextafter = text;
  4684. displayInChat("Set next after to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  4685. displayInChat("Type '/nextafter' to reset next after.","#DA0808","#1EBCC1");
  4686. return "";
  4687. }
  4688. else if (chat_val.substring(1,10)=="nextafter"){
  4689. nextafter = 0;
  4690. displayInChat("Reset next after.","#DA0808","#1EBCC1");
  4691. return "";
  4692. }
  4693. else if (chat_val.substring(1,5)=="next" && stopquickplay == 0){
  4694. roundsperqp2 = 0;
  4695. if(shuffle){
  4696. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4697. var available = [];
  4698. var availableindexes = [];
  4699. var notempty = false;
  4700. for(var i = 0; i<e.length;i++){
  4701. var a = false;
  4702. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4703. available.push(a);
  4704. if(a){
  4705. availableindexes.push(i);
  4706. notempty = true;
  4707. }
  4708. }
  4709. if(notempty){
  4710. if(availableindexes.length!=1){
  4711. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4712. }
  4713. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4714. }
  4715. }
  4716. else{
  4717. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4718. var available = [];
  4719. var availableindexes = [];
  4720. var notempty = false;
  4721. for(var i = 0; i<e.length;i++){
  4722. var a = false;
  4723. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4724. available.push(a);
  4725. if(a){
  4726. availableindexes.push(i);
  4727. notempty = true;
  4728. }
  4729. }
  4730. if(notempty){
  4731. var above = [];
  4732. for(var i = 0;i<availableindexes.length;i++){
  4733. if(availableindexes[i]>quicki && !reverseqp){
  4734. above.push(availableindexes[i]);
  4735. }
  4736. else if(availableindexes[i]<quicki && reverseqp){
  4737. above.push(availableindexes[i])
  4738. }
  4739. }
  4740. if(above.length>0){
  4741. quicki = above[0];
  4742. if(reverseqp){
  4743. quicki = above[above.length-1];
  4744. }
  4745. }
  4746. else{
  4747. quicki = availableindexes[0];
  4748. if(reverseqp){
  4749. quicki = availableindexes[availableindexes.length-1];
  4750. }
  4751. }
  4752. }
  4753. }
  4754. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4755. displayInChat("Switched to next map.","#DA0808","#1EBCC1");
  4756. return "";
  4757. }
  4758. else if (chat_val.substring(1,9)=="freejoin"){
  4759. if(freejoin == false){
  4760. freejoin = true;
  4761. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  4762. }
  4763. else{
  4764. freejoin = false;
  4765. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  4766. }
  4767. return "";
  4768. }
  4769. else if (chat_val.substring(1,8)=="instaqp"){
  4770. if(instaqp == false){
  4771. instaqp = true;
  4772. displayInChat("Instaqp is now on.","#DA0808","#1EBCC1");
  4773. }
  4774. else{
  4775. instaqp = false;
  4776. displayInChat("Instaqp is now off.","#DA0808","#1EBCC1");
  4777. }
  4778. return "";
  4779. }
  4780. else if (chat_val.substring(1,9)=="previous" && stopquickplay == 0){
  4781. roundsperqp2 = 0;
  4782. if(shuffle){
  4783. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4784. var available = [];
  4785. var availableindexes = [];
  4786. var notempty = false;
  4787. for(var i = 0; i<e.length;i++){
  4788. var a = false;
  4789. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4790. available.push(a);
  4791. if(a){
  4792. availableindexes.push(i);
  4793. notempty = true;
  4794. }
  4795. }
  4796. if(notempty){
  4797. if(availableindexes.length!=1){
  4798. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  4799. }
  4800. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  4801. }
  4802. }
  4803. else{
  4804. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  4805. var available = [];
  4806. var availableindexes = [];
  4807. var notempty = false;
  4808. for(var i = 0; i<e.length;i++){
  4809. var a = false;
  4810. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  4811. available.push(a);
  4812. if(a){
  4813. availableindexes.push(i);
  4814. notempty = true;
  4815. }
  4816. }
  4817. if(notempty){
  4818. var above = [];
  4819. for(var i = 0;i<availableindexes.length;i++){
  4820. if(availableindexes[i]<quicki && !reverseqp){
  4821. above.push(availableindexes[i]);
  4822. }
  4823. else if(availableindexes[i]>quicki && reverseqp){
  4824. above.push(availableindexes[i])
  4825. }
  4826. }
  4827. if(above.length>0){
  4828. quicki = above[above.length-1];
  4829. if(reverseqp){
  4830. quicki = above[0];
  4831. }
  4832. }
  4833. else{
  4834. quicki = availableindexes[availableindexes.length-1];
  4835. if(reverseqp){
  4836. quicki = availableindexes[0];
  4837. }
  4838. }
  4839. }
  4840. }
  4841. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  4842. displayInChat("Switched to previous map.","#DA0808","#1EBCC1");
  4843. return "";
  4844. }
  4845. else if (chat_val.substring(1,6)=="start" && chat_val.length == 6){
  4846. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  4847. Gdocument.getElementById("newbonklobby_editorbutton").click();
  4848. }
  4849. if(recmodebool && ishost){
  4850. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  4851. if(mode == "" && defaultmode!="d"){
  4852. mode = defaultmode;
  4853. }
  4854. if(mode != ""){
  4855. RECIEVE('42[26,"b","'+mode+'"]');
  4856. }
  4857. }
  4858. Gdocument.getElementById("mapeditor_close").click();
  4859. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  4860. roundsperqp2 = 0;
  4861. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  4862. return "";
  4863. }
  4864. else if (chat_val.substring(1,8)=="startqp" && stopquickplay == 1){
  4865. stopquickplay = 0;
  4866. quicki = 0;
  4867. qppaused = false;
  4868. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  4869. return "";
  4870. }
  4871. else if (chat_val.substring(1,7)=="stopqp" && stopquickplay == 0){
  4872. stopquickplay = 1;
  4873. quicki = 0;
  4874. qppaused = false;
  4875. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  4876. return "";
  4877. }
  4878. else if (chat_val.substring(1,8)=="pauseqp" && stopquickplay == 0){
  4879. if(qppaused == false){
  4880. qppaused = true;
  4881. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  4882. }
  4883. else{
  4884. qppaused = false;
  4885. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  4886. }
  4887. return "";
  4888. }
  4889. else if (chat_val.substring(1,6)=="revqp" && stopquickplay == 0){
  4890. if(reverseqp == false){
  4891. reverseqp = true;
  4892. displayInChat("Reverseqp is now on..","#DA0808","#1EBCC1");
  4893. }
  4894. else{
  4895. reverseqp = false;
  4896. displayInChat("Reverseqp is now off.","#DA0808","#1EBCC1");
  4897. }
  4898. return "";
  4899. }
  4900. else if (chat_val.substring(1,9)=="jukebox " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  4901. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  4902. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":text,"timestamp":Date.now()+2000,"to":[-1]}]));
  4903. displayInChat("Jukebox is loading... Please wait a few seconds.","#DA0808","#1EBCC1");
  4904. changeJukeboxURL(text,Date.now()+2000);
  4905. return "";
  4906. }
  4907. else if (chat_val.substring(1,13)=="pausejukebox"){
  4908. if(jukeboxplayer.src!="" && !jukeboxplayer.paused){
  4909. displayInChat("Jukebox is now paused.","#DA0808","#1EBCC1");
  4910. jukeboxplayer.pause();
  4911. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":"","timestamp":Date.now(),"to":[-1]}]));
  4912. }
  4913. return "";
  4914. }
  4915. else if (chat_val.substring(1,13)=="resetjukebox"){
  4916. if(jukeboxplayer.src!=""){
  4917. jukeboxplayer.currentTime = 0;
  4918. displayInChat("Jukebox has reset.","#DA0808","#1EBCC1");
  4919. changeJukeboxURL(jukeboxplayerURL,Date.now()+2000);
  4920. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()+2000,"to":[-1]}]));
  4921. }
  4922. return "";
  4923. }
  4924. else if (chat_val.substring(1,12)=="playjukebox"){
  4925. if(jukeboxplayer.src!="" && jukeboxplayer.paused){
  4926. changeJukeboxURL(jukeboxplayerURL,Date.now()-jukeboxplayer.currentTime*1000);
  4927. SEND("42"+JSON.stringify([4,{"type":"video player","from":username,"url":jukeboxplayerURL,"timestamp":Date.now()-jukeboxplayer.currentTime*1000,"to":[-1]}]));
  4928. }
  4929. return "";
  4930. }
  4931. else if (chat_val.substring(1,5)=="ban " && chat_val.replace(/^\s+|\s+$/g, '').length>=6){
  4932. banned.push(chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',""));
  4933. displayInChat("Banned "+chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"")+".","#DA0808","#1EBCC1");
  4934. return "/kick '" + chat_val.substring(5).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"") + "'";
  4935. }
  4936. else if (chat_val.substring(1,6)=="kill " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  4937. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  4938. var keys = Object.keys(playerids);
  4939. var killid = undefined;
  4940. for(var i = 0; i<keys.length; i++){
  4941. if(playerids[keys[i]].userName == text){
  4942. killid = keys[i];
  4943. }
  4944. }
  4945. if(typeof(killid)!="undefined" && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden" && !killedids.includes(killid)){
  4946. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  4947. killedids.push(killid);
  4948. SEND('42[25,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4949. RECIEVE('42[31,{"a":{"playersLeft":['+killid.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4950. }
  4951. return "";
  4952. }
  4953. else if (chat_val.substring(1,6)=="killA"){
  4954. var keys = Object.keys(playerids);
  4955. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  4956. currentFrame = Math.floor((Date.now() - gameStartTimeStamp)/1000*30);
  4957. SEND('42[25,{"a":{"playersLeft":['+keys.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4958. RECIEVE('42[31,{"a":{"playersLeft":['+keys.toString()+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  4959. }
  4960. return "";
  4961. }
  4962. else if (chat_val.substring(1,10)=="balanceA " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4963. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  4964. if(!isNaN(parseInt(text))){
  4965. if(parseInt(text)>=-100 && parseInt(text)<=100){
  4966. var keys = Object.keys(playerids);
  4967. for(var i = 0; i<keys.length;i++){
  4968. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text+'}]');
  4969. RECIEVE('42[36,'+keys[i]+','+text+']');
  4970. }
  4971. }
  4972. }
  4973. return "";
  4974. }
  4975. else if (chat_val.substring(1,10)=="balanceT " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  4976. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  4977. var text2 = text.split(" ").filter(function(e){if(e!=""){return true;}return false;});
  4978. if(text2.length!=2 || isNaN(parseInt(text2[1])) || !["s","r","b","y","g","f"].includes(text2[0])){
  4979. displayInChat("Please enter a team letter and a number to balance.","#DA0808","#1EBCC1");
  4980. return "";
  4981. }
  4982. var teamdict = {"s":0,"f":1,"r":2,"b":3,"g":4,"y":5};
  4983. if(parseInt(text2[1])>=-100 && parseInt(text2[1])<=100){
  4984. var keys = Object.keys(playerids);
  4985. for(var i = 0; i<keys.length;i++){
  4986. if(playerids[keys[i]].team == teamdict[text2[0]]){
  4987. SEND('42[29,{"sid":'+keys[i]+',"bal":'+text2[1]+'}]');
  4988. RECIEVE('42[36,'+keys[i]+','+text2[1]+']');
  4989. }
  4990. }
  4991. }
  4992. return "";
  4993. }
  4994. else if (chat_val.substring(1,10)=="resetpoll"){
  4995. poll = [];
  4996. displayInChat("The poll has been reset.","#DA0808","#1EBCC1");
  4997. return "";
  4998. }
  4999. else if (chat_val.substring(1,11)=="addoption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5000. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5001. if(text.length>50){
  5002. displayInChat("Your option is greater than 50 characters.","#DA0808","#1EBCC1");
  5003. return "";
  5004. }
  5005. if(poll.includes(text)){
  5006. displayInChat("This option already exists.","#DA0808","#1EBCC1");
  5007. }
  5008. else if(poll.length>=4){
  5009. displayInChat("Your poll already has the max 4 amounts of options.","#DA0808","#1EBCC1");
  5010. displayInChat("Type '/deloption [letter]' to remove a option.","#DA0808","#1EBCC1");
  5011. displayInChat("The poll is:","#DA0808","#1EBCC1");
  5012. for(var i = 0;i<poll.length;i++){
  5013. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5014. }
  5015. }
  5016. else{
  5017. poll.push(text);
  5018. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  5019. for(var i = 0;i<poll.length;i++){
  5020. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5021. }
  5022. }
  5023. return "";
  5024. }
  5025. else if (chat_val.substring(1,11)=="deloption " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5026. var text = letters.indexOf(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  5027. if(text==-1 || text>=poll.length){
  5028. if(poll.length>0){
  5029. displayInChat("Available options are:","#DA0808","#1EBCC1");
  5030. for(var i = 0;i<poll.length;i++){
  5031. displayInChat(letters[i],"#DA0808","#1EBCC1");
  5032. }
  5033. }
  5034. else{
  5035. displayInChat("Your poll is empty.","#DA0808","#1EBCC1");
  5036. displayInChat("Type '/addoption [text]' to add an option.","#DA0808","#1EBCC1");
  5037. }
  5038. }
  5039. else{
  5040. poll.splice(text,1);
  5041. displayInChat("The poll is now:","#DA0808","#1EBCC1");
  5042. for(var i = 0;i<poll.length;i++){
  5043. displayInChat(letters[i]+") "+poll[i],"#DA0808","#1EBCC1");
  5044. }
  5045. }
  5046. return "";
  5047. }
  5048. else if (chat_val.substring(1,11)=="startpoll " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5049. var text = parseFloat(chat_val.substring(11).replace(/^\s+|\s+$/g, ''));
  5050. if(isNaN(text)){
  5051. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5052. return "";
  5053. }
  5054. else if(text<=0){
  5055. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5056. return "";
  5057. }
  5058. else if(text<10){
  5059. displayInChat("Your poll has to last for at least 10 seconds.","#DA0808","#1EBCC1");
  5060. return "";
  5061. }
  5062. if(pollactive[0]){
  5063. displayInChat("There is already an ongoing poll.","#DA0808","#1EBCC1");
  5064. displayInChat("Type '/endpoll' to end the poll.","#DA0808","#1EBCC1");
  5065. return "";
  5066. }
  5067. if(poll.length<2){
  5068. displayInChat("Your poll needs at least 2 options.","#DA0808","#1EBCC1");
  5069. displayInChat("Type '/addoption' to add to the poll.","#DA0808","#1EBCC1");
  5070. return "";
  5071. }
  5072. var now = Date.now();
  5073. pollactive = [true,now,now+text*1000,[...poll]];
  5074. playerids[myid].ratelimit.poll = now;
  5075. var chatpoll = [...poll];
  5076. chatpoll.push("Cancel vote.");
  5077. pollactive[3].push("Cancel vote.");
  5078. for(var i = 0;i<chatpoll.length;i++){
  5079. chatpoll[i] = letters[i]+") "+chatpoll[i];
  5080. }
  5081. chat(chatpoll.join("     "));
  5082. setTimeout(function(){
  5083. if(pollactive[0]){
  5084. SEND("42"+JSON.stringify([4,{"type":"poll","from":username,"poll":pollactive[3]}]));
  5085. var keys = Object.keys(playerids);
  5086. for(var i = 0;i<keys.length;i++){
  5087. playerids[keys[i]].vote.poll = -1;
  5088. }
  5089. displayInChat("The poll will end in: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5090. displayInChat("Type '/endpoll' to end the poll early.","#DA0808","#1EBCC1");
  5091. }
  5092. },200);
  5093. return "";
  5094. }
  5095. else if (chat_val.substring(1,8)=="endpoll"){
  5096. if(pollactive[0]){
  5097. if(playerids[myid].ratelimit.poll+10000>Date.now()){
  5098. displayInChat("Your poll has to be at least 10 seconds.","#DA0808","#1EBCC1");
  5099. displayInChat("There are "+((playerids[myid].ratelimit.poll+10000-Date.now())/1000).toString()+" seconds left until you can end the poll early.","#DA0808","#1EBCC1");
  5100. return "";
  5101. }
  5102. playerids[myid].ratelimit.poll = Date.now();
  5103. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  5104. displayInChat("The poll ended.","#DA0808","#1EBCC1");
  5105. var count = [0,0,0,0];
  5106. var keys = Object.keys(playerids);
  5107. for(var i = 0;i<keys.length;i++){
  5108. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  5109. count[playerids[keys[i]].vote.poll]++;
  5110. }
  5111. playerids[keys[i]].vote.poll = -1;
  5112. }
  5113. for(var i = 0;i<count.length;i++){
  5114. if(count[i]>1){
  5115. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5116. }
  5117. if(count[i]==1){
  5118. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  5119. }
  5120. }
  5121. displayInChat("The poll was:","#DA0808","#1EBCC1");
  5122. for(var i = 0;i<pollactive[3].length;i++){
  5123. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  5124. }
  5125. pollactive = [false,0,0,[]];
  5126. }
  5127. else{
  5128. displayInChat("No poll has been started","#DA0808","#1EBCC1");
  5129. displayInChat("Type '/startpoll [seconds]' to start a poll.","#DA0808","#1EBCC1");
  5130. }
  5131. return "";
  5132. }
  5133. else if (chat_val.substring(1,7)=="moveA " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5134. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '');
  5135. var keys = Object.keys(playerids);
  5136. var t = -1;
  5137. if(text == "f"){
  5138. t = 1;
  5139. }
  5140. else if(text == "b"){
  5141. t = 3;
  5142. }
  5143. else if(text == "g"){
  5144. t = 4;
  5145. }
  5146. else if(text == "r"){
  5147. t = 2;
  5148. }
  5149. else if(text == "y"){
  5150. t = 5;
  5151. }
  5152. else if(text == "s"){
  5153. t = 0;
  5154. }
  5155. if(t == -1){
  5156. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5157. displayInChat("/moveA [letter]","#DA0808","#1EBCC1");
  5158. displayInChat("For example: '/moveA r' would move everyone to red team.","#DA0808","#1EBCC1");
  5159. return "";
  5160. }
  5161. for(var i = 0;i<keys.length;i++){
  5162. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+t.toString()+'}]');
  5163. if(playerids[keys[i]].peerID!="sandbox"){
  5164. RECIEVE('42[18,'+keys[i].toString()+','+t.toString()+']');
  5165. }
  5166. }
  5167. return "";
  5168. }
  5169. else if (chat_val.substring(1,7)=="moveT " && chat_val.replace(/^\s+|\s+$/g, '').length>=8){
  5170. var text = chat_val.substring(7).replace(/^\s+|\s+$/g, '').split(" ").filter(function(i){if(i==""){return false}else{return true}});
  5171. if(text.length == 2){
  5172. var firstteam = -1;
  5173. var secondteam = -1;
  5174. for(var i = 0;i<2;i++){
  5175. var t = -1;
  5176. if(text[i] == "f"){
  5177. t = 1;
  5178. }
  5179. else if(text[i] == "b"){
  5180. t = 3;
  5181. }
  5182. else if(text[i] == "g"){
  5183. t = 4;
  5184. }
  5185. else if(text[i] == "r"){
  5186. t = 2;
  5187. }
  5188. else if(text[i] == "y"){
  5189. t = 5;
  5190. }
  5191. else if(text[i] == "s"){
  5192. t = 0;
  5193. }
  5194. if(t==-1){
  5195. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5196. displayInChat("/moveT [letter] [letter]","#DA0808","#1EBCC1");
  5197. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5198. return "";
  5199. }
  5200. else{
  5201. if(i == 0){
  5202. firstteam = t;
  5203. }
  5204. else{
  5205. secondteam = t;
  5206. }
  5207. }
  5208. }
  5209. var keys = Object.keys(playerids);
  5210. for(var i = 0;i<keys.length;i++){
  5211. if(playerids[keys[i]].team == firstteam){
  5212. SEND('42[26,{"targetID":'+keys[i].toString()+',"targetTeam":'+secondteam.toString()+'}]');
  5213. if(playerids[keys[i]].peerID!="sandbox"){
  5214. RECIEVE('42[18,'+keys[i].toString()+','+secondteam.toString()+']');
  5215. }
  5216. }
  5217. }
  5218. }
  5219. else{
  5220. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5221. displayInChat("/moveT [team] [team]","#DA0808","#1EBCC1");
  5222. displayInChat("For example: '/moveT s r' would move everyone in spectate to red team.","#DA0808","#1EBCC1");
  5223. return "";
  5224. }
  5225. return "";
  5226. }
  5227. if (chat_val.substring(1,13)=="roundsperqp " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5228. var text = parseInt(chat_val.substring(13).replace(/^\s+|\s+$/g, ''));
  5229. if(isNaN(text)){
  5230. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5231. return "";
  5232. }
  5233. else if(text<=0){
  5234. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5235. return "";
  5236. }
  5237. roundsperqp = text;
  5238. roundsperqp2 = 0;
  5239. displayInChat("Set rounds per quickplay to: " + text.toString(),"#DA0808","#1EBCC1");
  5240. displayInChat("Type '/roundsperqp' to reset rounds per quickplay.","#DA0808","#1EBCC1");
  5241. return "";
  5242. }
  5243. else if (chat_val.substring(1,12)=="roundsperqp"){
  5244. roundsperqp = 1;
  5245. roundsperqp2 = 0;
  5246. displayInChat("Reset rounds per quickplay.","#DA0808","#1EBCC1");
  5247. return "";
  5248. }
  5249. else if (chat_val.substring(1,8)=="rounds " && chat_val.replace(/^\s+|\s+$/g, '').length>=9){
  5250. var text = chat_val.substring(8).replace(/^\s+|\s+$/g, '');
  5251. if(!isNaN(parseInt(text))){
  5252. text = parseInt(text).toString();
  5253. SEND('42[21,{"w":'+text+'}]');
  5254. RECIEVE('42[27,'+text+']');
  5255. }
  5256. return "";
  5257. }
  5258. else if (chat_val.substring(1,13)=="disablekeys " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5259. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5260. var keys = text.split(" ");
  5261. var disabledkeys2 = [];
  5262. var possiblekeys = ["left","right","up","down","heavy","special"];
  5263. for(var i = 0; i<keys.length; i++){
  5264. if(keys[i]!="" && !disabledkeys2.includes(keys[i])){
  5265. if(possiblekeys.includes(keys[i])){
  5266. disabledkeys2.push(keys[i]);
  5267. }
  5268. else{
  5269. displayInChat("Key options: " + possiblekeys.join(" ") + ".","#DA0808","#1EBCC1");
  5270. return "";
  5271. }
  5272. }
  5273. }
  5274. disabledkeys = disabledkeys2;
  5275. displayInChat("Set disabled keys to: " + disabledkeys.join(" ") + ".","#DA0808","#1EBCC1");
  5276. displayInChat("Type '/disablekeys' to reset disabled keys.","#DA0808","#1EBCC1");
  5277. return "";
  5278. }
  5279. else if (chat_val.substring(1,12)=="disablekeys"){
  5280. displayInChat("Reset disabled keys.","#DA0808","#1EBCC1");
  5281. disabledkeys = [];
  5282. return "";
  5283. }
  5284. else if (chat_val.substring(1,10)=="jointext " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5285. jointext = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5286. displayInChat("Set jointext to: " + jointext,"#DA0808","#1EBCC1");
  5287. displayInChat("Type '/jointext' to reset jointext.","#DA0808","#1EBCC1");
  5288. return "";
  5289. }
  5290. else if (chat_val.substring(1,9)=="jointext"){
  5291. jointext = "";
  5292. displayInChat("Reset jointext.","#DA0808","#1EBCC1");
  5293. return "";
  5294. }
  5295. else if (chat_val.substring(1,10)=="jointeam " && chat_val.replace(/^\s+|\s+$/g, '').length>=11){
  5296. var text = chat_val.substring(10).replace(/^\s+|\s+$/g, '');
  5297. var keys = Object.keys(playerids);
  5298. var t = -1;
  5299. if(text == "f"){
  5300. t = 1;
  5301. displayInChat("Set jointeam to FFA.","#DA0808","#1EBCC1");
  5302. }
  5303. else if(text == "b"){
  5304. t = 3;
  5305. displayInChat("Set jointeam to blue team.","#DA0808","#1EBCC1");
  5306. }
  5307. else if(text == "g"){
  5308. t = 4;
  5309. displayInChat("Set jointeam to green team.","#DA0808","#1EBCC1");
  5310. }
  5311. else if(text == "r"){
  5312. t = 2;
  5313. displayInChat("Set jointeam to red team.","#DA0808","#1EBCC1");
  5314. }
  5315. else if(text == "y"){
  5316. t = 5;
  5317. displayInChat("Set jointeam to yellow team.","#DA0808","#1EBCC1");
  5318. }
  5319. else if(text == "s"){
  5320. t = 0;
  5321. displayInChat("Set jointeam to spectate.","#DA0808","#1EBCC1");
  5322. }
  5323. if(t == -1){
  5324. displayInChat("The format for this command is:","#DA0808","#1EBCC1");
  5325. displayInChat("/jointeam [letter]","#DA0808","#1EBCC1");
  5326. displayInChat("For example: '/jointeam r' would move every joined person to red team.","#DA0808","#1EBCC1");
  5327. return "";
  5328. }
  5329. displayInChat("Type '/jointeam' to reset jointeam.","#DA0808","#1EBCC1");
  5330. jointeam = t;
  5331. return "";
  5332. }
  5333. else if (chat_val.substring(1,9)=="jointeam"){
  5334. jointeam = -1;
  5335. displayInChat("Reset jointeam.","#DA0808","#1EBCC1");
  5336. return "";
  5337. }
  5338. else if (chat_val.substring(1,9)=="wintext " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5339. wintext = chat_val.substring(9).replace(/^\s+|\s+$/g, '');
  5340. displayInChat("Set wintext to: " + wintext,"#DA0808","#1EBCC1");
  5341. displayInChat("Type '/wintext' to reset wintext.","#DA0808","#1EBCC1");
  5342. return "";
  5343. }
  5344. else if (chat_val.substring(1,8)=="wintext"){
  5345. wintext = "";
  5346. displayInChat("Reset wintext.","#DA0808","#1EBCC1");
  5347. return "";
  5348. }
  5349. else if (chat_val.substring(1,11)=="autorecord"){
  5350. if(autorecord){
  5351. autorecord = false;
  5352. displayInChat("Autorecord is now off.","#DA0808","#1EBCC1");
  5353. }
  5354. else{
  5355. autorecord = true;
  5356. displayInChat("Autorecord is now on.","#DA0808","#1EBCC1");
  5357. }
  5358. return "";
  5359. }
  5360. else if (chat_val.substring(1,9)=="afkkill " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5361. var text = parseFloat(chat_val.substring(9).replace(/^\s+|\s+$/g, ''));
  5362. if(!isNaN(text)){
  5363. if(text>0){
  5364. displayInChat("Set afk kill to: " + text.toString()+" seconds.","#DA0808","#1EBCC1");
  5365. displayInChat("Type '/afkkill' to reset afk kill.","#DA0808","#1EBCC1");
  5366. var keys = Object.keys(playerids);
  5367. var now = Date.now();
  5368. for(var i = 0;i<keys.length;i++){
  5369. playerids[keys[i]].lastmove = now;
  5370. }
  5371. afkkill = text;
  5372. }
  5373. else{
  5374. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5375. }
  5376. }
  5377. else{
  5378. displayInChat("Type a positive number.","#DA0808","#1EBCC1");
  5379. }
  5380. return "";
  5381. }
  5382. else if (chat_val.substring(1,9)=="afkkill"){
  5383. afkkill = -1;
  5384. displayInChat("Reset afk kill.","#DA0808","#1EBCC1");
  5385. return "";
  5386. }
  5387. else if (chat_val.substring(1,13)=="defaultmode " && chat_val.replace(/^\s+|\s+$/g, '').length>=14){
  5388. var text = chat_val.substring(13).replace(/^\s+|\s+$/g, '');
  5389. if(text == "default"){
  5390. defaultmode = "";
  5391. displayInChat("Changed default mode to default.","#DA0808","#1EBCC1");
  5392. }
  5393. else if(text == "arrows"){
  5394. defaultmode = "ar";
  5395. displayInChat("Changed default mode to arrows.","#DA0808","#1EBCC1");
  5396. }
  5397. else if(text == "death arrows"){
  5398. defaultmode = "ard";
  5399. displayInChat("Changed default mode to death arrows.","#DA0808","#1EBCC1");
  5400. }
  5401. else if(text == "grapple"){
  5402. defaultmode = "sp";
  5403. displayInChat("Changed default mode to grapple.","#DA0808","#1EBCC1");
  5404. }
  5405. else if(text == "classic"){
  5406. defaultmode = "b";
  5407. displayInChat("Changed default mode to classic.","#DA0808","#1EBCC1");
  5408. }
  5409. else{
  5410. displayInChat("Default mode options:","#DA0808","#1EBCC1");
  5411. displayInChat("default","#DA0808","#1EBCC1");
  5412. displayInChat("classic","#DA0808","#1EBCC1");
  5413. displayInChat("arrows","#DA0808","#1EBCC1");
  5414. displayInChat("death arrows","#DA0808","#1EBCC1");
  5415. displayInChat("grapple","#DA0808","#1EBCC1");
  5416. }
  5417. return "";
  5418. }
  5419. else if (chat_val.substring(1,8)=="recmode"){
  5420. if(recmodebool == true){
  5421. recmodebool = false;
  5422. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  5423. }
  5424. else{
  5425. recmodebool = true;
  5426. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  5427. }
  5428. return "";
  5429. }
  5430. else if (chat_val.substring(1,8)=="recteam"){
  5431. if(recteams == true){
  5432. recteams = false;
  5433. displayInChat("Recteam is now off.","#DA0808","#1EBCC1");
  5434. }
  5435. else{
  5436. recteams = true;
  5437. displayInChat("Recteam is now on.","#DA0808","#1EBCC1");
  5438. }
  5439. return "";
  5440. }
  5441. else if (chat_val.substring(1,8)=="shuffle"){
  5442. if(shuffle == true){
  5443. shuffle = false;
  5444. displayInChat("Shuffle is now off.","#DA0808","#1EBCC1");
  5445. }
  5446. else{
  5447. shuffle = true;
  5448. displayInChat("Shuffle is now on.","#DA0808","#1EBCC1");
  5449. }
  5450. return "";
  5451. }
  5452. else if (chat_val.substring(1,9)=="autokick"){
  5453. if(autokickban == 0){
  5454. displayInChat("Autokick is now on.","#DA0808","#1EBCC1");
  5455. autokickban = 1;
  5456. }
  5457. else if(autokickban == 1){
  5458. autokickban = 0;
  5459. displayInChat("Autokick is now off.","#DA0808","#1EBCC1");
  5460. }
  5461. else{
  5462. autokickban = 1;
  5463. displayInChat("Autokick is now on, and Autoban is now off.","#DA0808","#1EBCC1");
  5464. }
  5465. return "";
  5466. }
  5467. else if (chat_val.substring(1,8)=="autoban"){
  5468. if(autokickban == 0){
  5469. displayInChat("Autoban is now on.","#DA0808","#1EBCC1");
  5470. autokickban = 2;
  5471. }
  5472. else if(autokickban == 2){
  5473. autokickban = 0;
  5474. displayInChat("Autoban is now off.","#DA0808","#1EBCC1");
  5475. }
  5476. else{
  5477. autokickban = 2;
  5478. displayInChat("Autoban is now on, and Autokick is now off.","#DA0808","#1EBCC1");
  5479. }
  5480. return "";
  5481. }
  5482. else if (chat_val.substring(1,8)=="sandbox"){
  5483. if(sandboxon == false){
  5484. displayInChat("This room is now a sandbox room.","#DA0808","#1EBCC1");
  5485. sandboxon = true;
  5486. SEND('42[4,{"type":"sandboxon"}]');
  5487. var sandboxkeys = Object.keys(sandboxplayerids);
  5488. var packets = [];
  5489. for(var i = 0;i<sandboxkeys.length;i++){
  5490. var p = playerids[sandboxkeys[i]];
  5491. var packet = '42'+JSON.stringify([4,sandboxkeys[i],p.peerID,p.userName,p.guest,p.level,p.team,p.avatar]);
  5492. packets.push(packet);
  5493. }
  5494. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5495. SEND("42"+JSON.stringify([4,{"type":"sandboxid","from":username,"lastid":sandboxid,to:[-1]}]));
  5496. }
  5497. else{
  5498. displayInChat("You cannot turn a sandbox room back into a normal room.","#DA0808","#1EBCC1");
  5499. }
  5500. return "";
  5501. }
  5502. else if(sandboxon){
  5503. if (chat_val.substring(1,11)=="addplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5504. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5505. if(!isNaN(parseInt(text))){
  5506. var text2 = parseInt(text);
  5507. if(text2>0){
  5508. for(var i = 0;i<text2;i++){
  5509. while(playerids[sandboxid]){
  5510. sandboxid+=1;
  5511. }
  5512. var color = Math.floor(Math.random() * 16777215).toString();
  5513. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",sandboxid.toString(),true,0,0,{"layers":[],"bc":color}]);
  5514. RECIEVE(packet);
  5515. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5516. sandboxplayerids[sandboxid] = sandboxid.toString();
  5517. sandboxid+=1;
  5518. }
  5519. }
  5520. }
  5521. return "";
  5522. }
  5523. if (chat_val.substring(1,9)=="addname " && chat_val.replace(/^\s+|\s+$/g, '').length>=10){
  5524. var text = chat_val.substring(9).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5525. while(playerids[sandboxid]){
  5526. sandboxid+=1;
  5527. }
  5528. var keys = Object.keys(playerids);
  5529. var addon = "";
  5530. var escape = false;
  5531. var keysi = -1;
  5532. while(!escape){
  5533. escape = true;
  5534. for(var i = 0;i<keys.length;i++){
  5535. if(playerids[keys[i]].userName == text+addon){
  5536. addon+="‎";
  5537. var escape = false;
  5538. }
  5539. if(playerids[keys[i]].userName == text){
  5540. keysi = keys[i];
  5541. }
  5542. }
  5543. }
  5544. if(keysi!=-1){
  5545. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,playerids[keysi].guest,playerids[keysi].level,0,playerids[keysi].avatar]);
  5546. RECIEVE(packet);
  5547. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5548. }
  5549. else{
  5550. var color = Math.floor(Math.random() * 16777215).toString();
  5551. var packet = '42'+JSON.stringify([4,sandboxid,"sandbox",text+addon,true,0,0,{"layers":[],"bc":color}]);
  5552. RECIEVE(packet);
  5553. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":[packet],to:[-1]}]));
  5554. }
  5555. sandboxplayerids[sandboxid] = sandboxid.toString();
  5556. sandboxid+=1;
  5557. return "";
  5558. }
  5559. else if (chat_val.substring(1,11)=="delplayer " && chat_val.replace(/^\s+|\s+$/g, '').length>=12){
  5560. var text = chat_val.substring(11).replace(/^\s+|\s+$/g, '');
  5561. if(!isNaN(parseInt(text))){
  5562. var text2 = parseInt(text);
  5563. if(text2>0){
  5564. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden"){
  5565. var jsonkeys = Object.keys(sandboxplayerids).reverse();
  5566. var packets = [];
  5567. for(var i = 0;i<text2 && i<jsonkeys.length;i++){
  5568. var packet = '42[5,'+jsonkeys[i]+',0]';
  5569. RECIEVE(packet);
  5570. packets.push(packet);
  5571. delete sandboxplayerids[jsonkeys[i]];
  5572. }
  5573. SEND("42"+JSON.stringify([4,{"type":"fakerecieve","from":username,"packet":packets,to:[-1]}]));
  5574. }
  5575. else{
  5576. displayInChat("Cannot delete players while ingame.","#DA0808","#1EBCC1");
  5577. }
  5578. }
  5579. }
  5580. return "";
  5581. }
  5582. else if (chat_val.substring(1,6)=="copy " && chat_val.replace(/^\s+|\s+$/g, '').length>=7){
  5583. var text = chat_val.substring(6).replace(/^\s+|\s+$/g, '').replaceAll("'","").replaceAll('"',"");
  5584. var keys = Object.keys(playerids);
  5585. var keys2 = Object.keys(sandboxplayerids);
  5586. var copiedperson = -1;
  5587. for(var i = 0;i<keys.length;i++){
  5588. if(playerids[keys[i]].userName==text){
  5589. copiedperson = keys[i];
  5590. }
  5591. }
  5592. if(copiedperson==-1){
  5593. displayInChat(playerids[copiedperson].userName + " was not found in this room.","#DA0808","#1EBCC1");
  5594. return "";
  5595. }
  5596. if(keys2.includes(copiedperson.toString())){
  5597. displayInChat("Bots cannot copy a bot.","#DA0808","#1EBCC1");
  5598. return "";
  5599. }
  5600. displayInChat("All bots will now copy "+playerids[copiedperson].userName+".","#DA0808","#1EBCC1");
  5601. displayInChat("To reset copy, type '/copy'.","#DA0808","#1EBCC1");
  5602. sandboxcopyme = copiedperson;
  5603. return "";
  5604. }
  5605. else if (chat_val.substring(1,5)=="copy"){
  5606. sandboxcopyme = -1;
  5607. displayInChat("Copy is now off.","#DA0808","#1EBCC1");
  5608. return "";
  5609. }
  5610. }
  5611. }
  5612. return chat_val;
  5613. };
  5614. scope.flag_manage = function(t){
  5615. var text = t;
  5616. if(autocorrect == true){
  5617. var text2 = text.split(" ");
  5618. for(var i = 0;i<text2.length;i++){
  5619. text2[i] = closestWord(text2[i]);
  5620. }
  5621. text = text2.join(" ");
  5622. }
  5623. if(reverse_flag == true){
  5624. text = text.split("").reverse().join("")
  5625. }
  5626. if(rcaps_flag == true){
  5627. text = text.split('');
  5628. for(var i = 0; i<text.length;i++){
  5629. if(Math.floor(Math.random()*2)){
  5630. text[i] = text[i].toUpperCase();
  5631. }
  5632. else{
  5633. text[i] = text[i].toLowerCase();
  5634. }
  5635. }
  5636. text = text.join('');
  5637. }
  5638. if(space_flag == true){
  5639. text = text.split('').join(' ')
  5640. }
  5641. if(textmode!=-1){
  5642. newtext = "";
  5643. for(var i = 0;i<text.length;i++){
  5644. if(letter_dictionary[text[i]]){
  5645. newtext+=letter_dictionary[text[i]][textmode];
  5646. }
  5647. else{
  5648. newtext+=text[i];
  5649. }
  5650. }
  5651. text = newtext;
  5652. }
  5653. if(number_flag == true){
  5654. text = text.replace(/[t|T][Oo]+/g,"2");
  5655. text = text.replace(/[f|F][o|O][r|R]/g,"4");
  5656. text = text.replace(/[a|A][t|T][e|E]/g,"8");
  5657. text = text.replace(/[e|E]/g,"3");
  5658. text = text.replace(/[a|A]/g,"4");
  5659. text = text.replace(/[o|O]/g,"0");
  5660. text = text.replace(/[s|S]/g,"5");
  5661. text = text.replace(/[i|I|l|L]/g,"1");
  5662. }
  5663. return text;
  5664. };
  5665. Gdocument.getElementById("newbonklobby_chat_input").onkeydown = function(e){
  5666. if(e.keyCode==13){
  5667. var chat_val = Gdocument.getElementById("newbonklobby_chat_input").value;
  5668. if (chat_val!="" && chat_val[0]=="/"){
  5669. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5670. chat2(commandhandle(chat_val));
  5671. }
  5672. else{
  5673. Gdocument.getElementById("newbonklobby_chat_input").value = "";
  5674. chat2(flag_manage(chat_val));
  5675. }
  5676. }
  5677. };
  5678. Gdocument.getElementById("ingamechatinputtext").onkeydown = function(e){
  5679. if(e.keyCode==13){
  5680. var chat_val = Gdocument.getElementById("ingamechatinputtext").value;
  5681. if (chat_val!="" && chat_val[0]=="/"){
  5682. Gdocument.getElementById("ingamechatinputtext").value = "";
  5683. chat2(commandhandle(chat_val));
  5684. }
  5685. else{
  5686. Gdocument.getElementById("ingamechatinputtext").value = "";
  5687. chat2(flag_manage(chat_val));
  5688. }
  5689. }
  5690. };
  5691. scope.Last_message = "";
  5692. scope.Laster_message = "";
  5693. scope.new_message = false;
  5694. scope.changed_chat = false;
  5695. scope.injectedBonkCommandsScript = setInterval(timeout123,60);
  5696.  
  5697. scope.pan_enabled = false;
  5698. scope.pan = {"x":0,"y":0};
  5699. scope.pan_speed = 5;
  5700. scope.keys_being_held = {};
  5701. scope.hotkeys_keyup = function(e){
  5702. if(keys_being_held[e.code]){
  5703. keys_being_held[e.code] = false;
  5704. }
  5705. };
  5706. Gdocument.onkeyup = hotkeys_keyup;
  5707. scope.hotkeys = function(e){
  5708. var keycode = e.code;
  5709. if(!keys_being_held[keycode]){
  5710. keys_being_held[keycode] = true;
  5711. }
  5712. if(!e.altKey && e.shiftKey && !e.ctrlKey && !e.metaKey){
  5713. if(pan_enabled && Gdocument.getElementById("gamerenderer")?.childElementCount>0){
  5714. if(keycode == "ArrowUp"){
  5715. e.stopPropagation();
  5716. e.preventDefault();
  5717. }
  5718. else if(keycode == "ArrowDown"){
  5719. e.stopPropagation();
  5720. e.preventDefault();
  5721. }
  5722. else if(keycode == "ArrowLeft"){
  5723. e.stopPropagation();
  5724. e.preventDefault();
  5725. }
  5726. else if(keycode == "ArrowRight"){
  5727. e.stopPropagation();
  5728. e.preventDefault();
  5729. }
  5730. }
  5731. }
  5732.  
  5733. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5734. if(keycode == "Period"){
  5735. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5736. chatheight+=5;
  5737. if(chatheight>600){chatheight = 600;}
  5738. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5739. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5740. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5741. }
  5742. e.preventDefault();
  5743. }
  5744. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5745. if(keycode == "KeyG"){
  5746. var addto = 0;
  5747. for(var i = 0;i<parentDraw.children.length;i++){
  5748. if(parentDraw.children[i].constructor.name == "e"){
  5749. addto = parentDraw.children[i];
  5750. break;
  5751. }
  5752. }
  5753. var canv = 0;
  5754. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5755. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5756. canv = Gdocument.getElementById("gamerenderer").children[i];
  5757. break;
  5758. }
  5759. }
  5760. var width = parseInt(canv.style["width"]);
  5761. var height = parseInt(canv.style["height"]);
  5762. if(addto){
  5763. zoom *= 1.1;
  5764. }
  5765. addto.scale.x = zoom;
  5766. addto.scale.y = zoom;
  5767. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5768. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5769. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5770. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5771. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5772. pixiCircle.visible = false;
  5773. }
  5774. else{
  5775. pixiCircle.visible = true;
  5776. }
  5777. e.preventDefault();
  5778. }
  5779. if(keycode == "KeyH"){
  5780. var addto = 0;
  5781. for(var i = 0;i<parentDraw.children.length;i++){
  5782. if(parentDraw.children[i].constructor.name == "e"){
  5783. addto = parentDraw.children[i];
  5784. break;
  5785. }
  5786. }
  5787. var canv = 0;
  5788. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5789. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5790. canv = Gdocument.getElementById("gamerenderer").children[i];
  5791. break;
  5792. }
  5793. }
  5794. var width = parseInt(canv.style["width"]);
  5795. var height = parseInt(canv.style["height"]);
  5796. if(addto){
  5797. zoom = 1;
  5798. }
  5799. addto.scale.x = zoom;
  5800. addto.scale.y = zoom;
  5801. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5802. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5803. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5804. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5805. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5806. pixiCircle.visible = false;
  5807. }
  5808. else{
  5809. pixiCircle.visible = true;
  5810. }
  5811. e.preventDefault();
  5812. }
  5813. if(keycode == "KeyJ"){
  5814. var addto = 0;
  5815. for(var i = 0;i<parentDraw.children.length;i++){
  5816. if(parentDraw.children[i].constructor.name == "e"){
  5817. addto = parentDraw.children[i];
  5818. break;
  5819. }
  5820. }
  5821. var canv = 0;
  5822. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  5823. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  5824. canv = Gdocument.getElementById("gamerenderer").children[i];
  5825. break;
  5826. }
  5827. }
  5828. var width = parseInt(canv.style["width"]);
  5829. var height = parseInt(canv.style["height"]);
  5830. if(addto){
  5831. zoom /= 1.1;
  5832. }
  5833. addto.scale.x = zoom;
  5834. addto.scale.y = zoom;
  5835. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  5836. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  5837. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  5838. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  5839. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999 && !FollowCam){
  5840. pixiCircle.visible = false;
  5841. }
  5842. else{
  5843. pixiCircle.visible = true;
  5844. }
  5845. e.preventDefault();
  5846. }
  5847. }
  5848. if(keycode == "Comma"){
  5849. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]!="0px"){
  5850. chatheight-=5;
  5851. if(chatheight<100){chatheight = 100;}
  5852. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  5853. Gdocument.getElementById("ingamechatcontent").style["height"]=chatheight.toString()+"px";
  5854. Gdocument.getElementById("ingamechatbox").style["height"]="100%";
  5855. }
  5856. e.preventDefault();
  5857. }
  5858. }
  5859. if(e.repeat){return;}
  5860. if(e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  5861. if(ishost){
  5862. if(keycode == "KeyE"){
  5863. if(Gdocument.getElementById("newbonklobby").style["display"] == "block"){
  5864. Gdocument.getElementById("newbonklobby_editorbutton").click();
  5865. }
  5866. else if(Gdocument.getElementById("mapeditorcontainer").style["display"] == "block"){
  5867. Gdocument.getElementById("mapeditor_close").click();
  5868. }
  5869. e.preventDefault();
  5870. }
  5871. else if(keycode == "KeyT"){
  5872. Gdocument.getElementById("newbonklobby_teamsbutton").click();
  5873. e.preventDefault();
  5874. }
  5875. else if(keycode == "KeyM"){
  5876. Gdocument.getElementById("newbonklobby_modebutton").click();
  5877. e.preventDefault();
  5878. }
  5879. else if(keycode == "KeyK"){
  5880. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  5881. Gdocument.getElementById("pretty_top_exit").click();
  5882. }
  5883. e.preventDefault();
  5884. }
  5885. else if(keycode == "KeyS"){
  5886. if(Gdocument.getElementById("mapeditorcontainer").style["display"]!="block"){
  5887. Gdocument.getElementById("newbonklobby_editorbutton").click();
  5888. }
  5889. if(recmodebool && ishost){
  5890. var mode = Gdocument.getElementById("mapeditor_modeselect").value;
  5891. if(mode == "" && defaultmode!="d"){
  5892. mode = defaultmode;
  5893. }
  5894. if(mode != ""){
  5895. RECIEVE('42[26,"b","'+mode+'"]');
  5896. }
  5897. }
  5898. Gdocument.getElementById("mapeditor_close").click();
  5899. Gdocument.getElementById("newbonklobby").style["display"] = "none";
  5900. roundsperqp2 = 0;
  5901. Gdocument.getElementById("mapeditor_midbox_testbutton").click();
  5902. e.preventDefault();
  5903. }
  5904. else if(keycode == "KeyD"){
  5905. roundsperqp2 = 0;
  5906. if(stopquickplay == 0){
  5907. if(shuffle){
  5908. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5909. var available = [];
  5910. var availableindexes = [];
  5911. var notempty = false;
  5912. for(var i = 0; i<e2.length;i++){
  5913. var a = false;
  5914. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5915. available.push(a);
  5916. if(a){
  5917. availableindexes.push(i);
  5918. notempty = true;
  5919. }
  5920. }
  5921. if(notempty){
  5922. if(availableindexes.length!=1){
  5923. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5924. }
  5925. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5926. }
  5927. }
  5928. else{
  5929. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5930. var available = [];
  5931. var availableindexes = [];
  5932. var notempty = false;
  5933. for(var i = 0; i<e2.length;i++){
  5934. var a = false;
  5935. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5936. available.push(a);
  5937. if(a){
  5938. availableindexes.push(i);
  5939. notempty = true;
  5940. }
  5941. }
  5942. if(notempty){
  5943. var above = [];
  5944. for(var i = 0;i<availableindexes.length;i++){
  5945. if(availableindexes[i]>quicki && !reverseqp){
  5946. above.push(availableindexes[i]);
  5947. }
  5948. else if(availableindexes[i]<quicki && reverseqp){
  5949. above.push(availableindexes[i])
  5950. }
  5951. }
  5952. if(above.length>0){
  5953. quicki = above[0];
  5954. if(reverseqp){
  5955. quicki = above[above.length-1];
  5956. }
  5957. }
  5958. else{
  5959. quicki = availableindexes[0];
  5960. if(reverseqp){
  5961. quicki = availableindexes[availableindexes.length-1];
  5962. }
  5963. }
  5964. }
  5965. }
  5966. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  5967. }
  5968. e.preventDefault();
  5969. }
  5970. else if(keycode == "KeyA"){
  5971. if(stopquickplay == 0){
  5972. roundsperqp2 = 0;
  5973. if(shuffle){
  5974. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5975. var available = [];
  5976. var availableindexes = [];
  5977. var notempty = false;
  5978. for(var i = 0; i<e2.length;i++){
  5979. var a = false;
  5980. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  5981. available.push(a);
  5982. if(a){
  5983. availableindexes.push(i);
  5984. notempty = true;
  5985. }
  5986. }
  5987. if(notempty){
  5988. if(availableindexes.length!=1){
  5989. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  5990. }
  5991. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  5992. }
  5993. }
  5994. else{
  5995. var e2 = Gdocument.getElementById("maploadwindowmapscontainer").children;
  5996. var available = [];
  5997. var availableindexes = [];
  5998. var notempty = false;
  5999. for(var i = 0; i<e2.length;i++){
  6000. var a = false;
  6001. [...e2[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6002. available.push(a);
  6003. if(a){
  6004. availableindexes.push(i);
  6005. notempty = true;
  6006. }
  6007. }
  6008. if(notempty){
  6009. var above = [];
  6010. for(var i = 0;i<availableindexes.length;i++){
  6011. if(availableindexes[i]<quicki && !reverseqp){
  6012. above.push(availableindexes[i]);
  6013. }
  6014. else if(availableindexes[i]>quicki && reverseqp){
  6015. above.push(availableindexes[i])
  6016. }
  6017. }
  6018. if(above.length>0){
  6019. quicki = above[above.length-1];
  6020. if(reverseqp){
  6021. quicki = above[0];
  6022. }
  6023. }
  6024. else{
  6025. quicki = availableindexes[availableindexes.length-1];
  6026. if(reverseqp){
  6027. quicki = availableindexes[0];
  6028. }
  6029. }
  6030. }
  6031. }
  6032. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6033. }
  6034. e.preventDefault();
  6035. }
  6036. else if(keycode == "KeyQ"){
  6037. if(stopquickplay == 1){
  6038. stopquickplay = 0;
  6039. quicki = 0;
  6040. qppaused = false;
  6041. displayInChat("Enabled quickplay.","#DA0808","#1EBCC1");
  6042. }
  6043. else{
  6044. stopquickplay = 1;
  6045. quicki = 0;
  6046. qppaused = false;
  6047. displayInChat("Disabled quickplay.","#DA0808","#1EBCC1");
  6048. }
  6049. e.preventDefault();
  6050. }
  6051. else if(keycode == "KeyP" && stopquickplay==0){
  6052. if(qppaused == true){
  6053. qppaused = false;
  6054. displayInChat("Unpaused quickplay.","#DA0808","#1EBCC1");
  6055. }
  6056. else{
  6057. qppaused = true;
  6058. displayInChat("Paused quickplay.","#DA0808","#1EBCC1");
  6059. }
  6060. e.preventDefault();
  6061. }
  6062. else if(keycode == "KeyR"){
  6063. if(recmodebool == true){
  6064. recmodebool = false;
  6065. displayInChat("Recmode is now off.","#DA0808","#1EBCC1");
  6066. }
  6067. else{
  6068. recmodebool = true;
  6069. displayInChat("Recmode is now on.","#DA0808","#1EBCC1");
  6070. }
  6071. }
  6072. else if(keycode == "KeyF"){
  6073. if(freejoin == false){
  6074. freejoin = true;
  6075. displayInChat("Freejoin is now on.","#DA0808","#1EBCC1");
  6076. }
  6077. else{
  6078. freejoin = false;
  6079. displayInChat("Freejoin is now off.","#DA0808","#1EBCC1");
  6080. }
  6081. e.preventDefault();
  6082. }
  6083. }
  6084. else{
  6085. if(keycode == "KeyE"){
  6086. e.preventDefault();
  6087. }
  6088. else if(keycode == "KeyT"){
  6089. e.preventDefault();
  6090. }
  6091. else if(keycode == "KeyM"){
  6092. e.preventDefault();
  6093. }
  6094. else if(keycode == "KeyK"){
  6095. e.preventDefault();
  6096. }
  6097. else if(keycode == "KeyS"){
  6098. e.preventDefault();
  6099. }
  6100. else if(keycode == "KeyD"){
  6101. e.preventDefault();
  6102. }
  6103. else if(keycode == "KeyA"){
  6104. e.preventDefault();
  6105. }
  6106. else if(keycode == "KeyQ"){
  6107. e.preventDefault();
  6108. }
  6109. else if(keycode == "KeyP"){
  6110. e.preventDefault();
  6111. }
  6112. else if(keycode == "KeyF"){
  6113. e.preventDefault();
  6114. }
  6115. else if(keycode == "KeyR"){
  6116. e.preventDefault();
  6117. }
  6118. }
  6119. if(keycode == "KeyL"){
  6120. lobby();
  6121. e.preventDefault();
  6122. }
  6123. if(keycode == "KeyC"){
  6124. if(Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6125. if(Gdocument.getElementById("ingamechatcontent").style["max-height"]=="0px"){
  6126. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6127. }
  6128. else{
  6129. Gdocument.getElementById("ingamechatcontent").style["max-height"]="0px";
  6130. }
  6131. }
  6132. e.preventDefault();
  6133. }
  6134. if(keycode == "KeyI"){
  6135. if(Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"] == "none"){
  6136. debuggeropen = true;
  6137. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="block";
  6138. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="none";
  6139. Gdocument.getElementById("ingamechatinputtext").style["display"] = "none";
  6140. }
  6141. else{
  6142. debuggeropen = false;
  6143. Gdocument.getElementById("BonkCommandsDebuggerContainer").style["display"]="none";
  6144. Gdocument.getElementById("newbonklobby_chat_input").style["display"]="";
  6145. Gdocument.getElementById("ingamechatinputtext").style["display"] = "";
  6146. }
  6147. e.preventDefault();
  6148. }
  6149. if(keycode == "KeyB"){
  6150. var element = Gdocument.getElementById("ingamewinner_scores");
  6151. if(element.style["opacity"]<1){
  6152. element.style["opacity"] = 1;
  6153. element.style["visibility"] = "visible";
  6154. }
  6155. else{
  6156. element.style["opacity"] = 0;
  6157. element.style["visibility"] = "unset";
  6158. }
  6159. e.preventDefault();
  6160. }
  6161. if(keycode == "KeyY"){
  6162. Gdocument.getElementById("pretty_top_settings").click();
  6163. Gdocument.getElementById("settings_close").click();
  6164. if(Gdocument.getElementById("settings_graphicsquality").value==1){
  6165. displayInChat("You must have medium or high quality enabled to use this feature.","#DA0808","#1EBCC1");
  6166. return "";
  6167. }
  6168. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6169. var addto = {"children":[]};
  6170. for(var i = 0;i<parentDraw.children.length;i++){
  6171. if(parentDraw.children[i].constructor.name == "e"){
  6172. addto = parentDraw.children[i];
  6173. break;
  6174. }
  6175. }
  6176. var addto2 = {"children":[]};
  6177. for(var i = 0;i<addto.children.length;i++){
  6178. if(addto.children[i].constructor.name == "e"){
  6179. addto2 = addto.children[i];
  6180. break;
  6181. }
  6182. }
  6183. var checkxray = addto2.children[0];
  6184. var addto3 = addto2.children[0].children;
  6185. if(addto3.length==1){
  6186. checkxray = checkxray.children[0];
  6187. addto3 = addto3[0].children;
  6188. }
  6189. var xrayon = false;
  6190. if(checkxray.xrayon){
  6191. checkxray.xrayon = false;
  6192. xrayon = false;
  6193. }
  6194. else{
  6195. checkxray.xrayon = true;
  6196. xrayon = true;
  6197. }
  6198. if(xrayon){
  6199. displayInChat("Xray is now on.","#DA0808","#1EBCC1");
  6200. for(var i = 0;i<addto3.length;i++){
  6201. if(addto3[i].children.length>0){
  6202. var ids = [];
  6203. var ids2 = [];
  6204. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6205. addto3[i].children[i3].visible = false;
  6206. if(addto3[i].children[i3].children.length>0){
  6207. for(var i4 = 0;i4<addto3[i].children[i3].children.length;i4++){
  6208. if(addto3[i].children[i3].children[i4].geometry?.id){
  6209. ids.push(addto3[i].children[i3].children[i4].geometry.id);
  6210. }
  6211. else if(addto3[i].children[i3].children[i4].texture?.baseTexture?.uid){
  6212. ids2.push(addto3[i].children[i3].children[i4].texture.baseTexture.uid);
  6213. }
  6214. }
  6215. }
  6216. }
  6217. for(var i3 = 0;i3<addto3[i].children.length;i3++){
  6218. if(addto3[i].children[i3].children.length==0){
  6219. if(addto3[i].children[i3].geometry?.id){
  6220. if(ids.includes(addto3[i].children[i3].geometry.id+1)){
  6221. addto3[i].children[i3].visible = true;
  6222. addto3[i].children[i3].alpha = 0.5;
  6223. }
  6224. }
  6225. else if(addto3[i].children[i3].texture?.baseTexture?.uid){
  6226. if(ids2.includes(addto3[i].children[i3].texture.baseTexture.uid+1)){
  6227. addto3[i].children[i3].visible = true;
  6228. addto3[i].children[i3].alpha = 0.5;
  6229. }
  6230. }
  6231. if(addto3[i].children[i3].batchDirty){
  6232. addto3[i].children[i3].visible = true;
  6233. addto3[i].children[i3].alpha = 0.5;
  6234. addto3[i].children[i3+1].visible = true;
  6235. addto3[i].children[i3+1].alpha = 0.5;
  6236. }
  6237. }
  6238. }
  6239. }
  6240. }
  6241. }
  6242. else{
  6243. displayInChat("Xray is now off.","#DA0808","#1EBCC1");
  6244. for(var i = 0;i<addto3.length;i++){
  6245. for(var i2 = 0;i2<addto3[i].children.length;i2++){
  6246. addto3[i].children[i2].visible = true;
  6247. addto3[i].children[i2].alpha = 1;
  6248. }
  6249. }
  6250. }
  6251. }
  6252. e.preventDefault();
  6253. }
  6254. if(keycode == "KeyN"){
  6255. if(FollowCam == true){
  6256. displayInChat("Follow Camera is now off.","#DA0808","#1EBCC1");
  6257. FollowCam = false;
  6258. if(parentDraw && Gdocument.getElementById("gamerenderer").style["visibility"]!="hidden"){
  6259. var addto = {"children":[]};
  6260. for(var i = 0;i<parentDraw.children.length;i++){
  6261. if(parentDraw.children[i].constructor.name == "e"){
  6262. addto = parentDraw.children[i];
  6263. break;
  6264. }
  6265. }
  6266. var canv = 0;
  6267. for(var i = 0;i<Gdocument.getElementById("gamerenderer").children.length;i++){
  6268. if(Gdocument.getElementById("gamerenderer").children[i].constructor.name == "HTMLCanvasElement"){
  6269. canv = Gdocument.getElementById("gamerenderer").children[i];
  6270. break;
  6271. }
  6272. }
  6273. var width = parseInt(canv.style["width"]);
  6274. var height = parseInt(canv.style["height"]);
  6275. parentDraw.x = -addto.scale.x * parseInt(width)/2 + parseInt(width)/2;
  6276. parentDraw.y = -addto.scale.y * parseInt(height)/2 + parseInt(height)/2;
  6277. parentDraw.children[0].x = parseInt(width)/2*addto.scale.x-parseInt(width)/2;
  6278. parentDraw.children[0].y = parseInt(height)/2*addto.scale.y-parseInt(height)/2;
  6279. if(addto.scale.x>=0.99999 && addto.scale.y>=0.99999){
  6280. pixiCircle.visible = false;
  6281. }
  6282. else{
  6283. pixiCircle.visible = true;
  6284. }
  6285. }
  6286. }
  6287. else{
  6288. displayInChat("Follow Camera is now on.","#DA0808","#1EBCC1");
  6289. FollowCam = true;
  6290. }
  6291. e.preventDefault();
  6292. }
  6293. if(keycode == "KeyV"){
  6294. if(autocam == true){
  6295. displayInChat("Auto Cam is now off.","#DA0808","#1EBCC1");
  6296. autocam = false
  6297. }
  6298. else{
  6299. displayInChat("Auto Cam is now on.","#DA0808","#1EBCC1");
  6300. autocam = true;
  6301. }
  6302. e.preventDefault();
  6303. }
  6304. if (keycode == "BracketLeft"){
  6305. if(pan_enabled == true){
  6306. displayInChat("Pan is now off.","#DA0808","#1EBCC1");
  6307. pan = {"x":0,"y":0};
  6308. pan_enabled = false;
  6309. }
  6310. else{
  6311. displayInChat("Pan is now on. Shift + Arrow Keys to pan.","#DA0808","#1EBCC1");
  6312. pan_enabled = true;
  6313. }
  6314. return "";
  6315. }
  6316. if (keycode == "BracketRight"){
  6317. pan = {"x":0,"y":0};
  6318. displayInChat("Reset pan.","#DA0808","#1EBCC1");
  6319. return "";
  6320. }
  6321. if(keycode == "KeyO"){
  6322. if(heavybot == true){
  6323. displayInChat("Heavy bot is now off.","#DA0808","#1EBCC1");
  6324. heavybot = false;
  6325. }
  6326. else{
  6327. displayInChat("Heavy bot is now on.","#DA0808","#1EBCC1");
  6328. heavybot = true;
  6329. getplayerkeys();
  6330. }
  6331. e.preventDefault();
  6332. }
  6333. if(keycode == "KeyU"){
  6334. if(aimbot == true){
  6335. displayInChat("Aimbot is now off.","#DA0808","#1EBCC1");
  6336. aimbot = false;
  6337. }
  6338. else{
  6339. displayInChat("Aimbot is now on.","#DA0808","#1EBCC1");
  6340. aimbot = true;
  6341. getplayerkeys();
  6342. }
  6343. e.preventDefault();
  6344. }
  6345. if(keycode == "KeyW"){
  6346. if(staystill == true){
  6347. displayInChat("Still is now off.","#DA0808","#1EBCC1");
  6348. staystill = false;
  6349. staystillpos = [0,0];
  6350. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6351. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6352. }
  6353. else{
  6354. if(playerids[myid].playerData?.transform){
  6355. displayInChat("Still is now on.","#DA0808","#1EBCC1");
  6356. staystill = true;
  6357. staystillpos = [playerids[myid].playerData.transform.position.x/scale,playerids[myid].playerData.transform.position.y/scale];
  6358. getplayerkeys();
  6359. fire("keyup",{"keyCode":leftRight[0]},Gdocument.getElementById("gamerenderer"));
  6360. fire("keyup",{"keyCode":leftRight[1]},Gdocument.getElementById("gamerenderer"));
  6361. }
  6362. else{
  6363. displayInChat("You have to be alive to use this command.","#DA0808","#1EBCC1");
  6364. }
  6365. }
  6366. e.preventDefault();
  6367. }
  6368. }
  6369. if(!e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey){
  6370. if(keycode == "Slash" && !(Gdocument.getElementById("gmeditor")?.style["transform"] == "scale(1)")){
  6371. 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"]==""){
  6372. Gdocument.getElementById("newbonklobby_chat_input").value = "/";
  6373. if(Gdocument.getElementById("newbonklobby_chat_input").style["pointer-events"] == "none"){
  6374. fire("keydown",{keyCode:13});
  6375. }
  6376. else{
  6377. Gdocument.getElementById("newbonklobby_chat_input").focus();
  6378. }
  6379. e.preventDefault();
  6380. }
  6381. else if(Gdocument.getElementById("ingamechatinputtext").style["visibility"]=="visible" && Gdocument.getElementById("ingamechatinputtext").style["display"]=="" && Gdocument.getElementById("mapeditorcontainer").style["display"]!="block" && Gdocument.getElementById("ingamechatinputtext").value == ""){
  6382. Gdocument.getElementById("ingamechatinputtext").value = "/";
  6383. if(!Gdocument.getElementById("ingamechatinputtext").classList.value.includes("ingamechatinputtextbg")){
  6384. fire("keydown",{keyCode:13});
  6385. }
  6386. else{
  6387. Gdocument.getElementById("ingamechatinputtext").focus();
  6388. }
  6389. e.preventDefault();
  6390. }
  6391. }
  6392. }
  6393. };
  6394. Gdocument.onkeydown = hotkeys;
  6395. Gwindow.addEventListener('resize',function(e){
  6396. debuggermenu.style["width"] = Gdocument.getElementById("bonkiocontainer").style["width"];
  6397. debuggermenu.style["height"] = Gdocument.getElementById("bonkiocontainer").style["height"];
  6398. scope.width = parseInt(Gdocument.getElementById("bonkiocontainer").style["width"])-20;
  6399. scope.height = parseInt(Gdocument.getElementById("bonkiocontainer").style["height"])-210;
  6400. logmenu.style["width"] = width.toString()+"px";
  6401. logmenu.style["height"] = height.toString()+"px";
  6402. logmenutopleft.style["width"] = (width/2).toString()+"px";
  6403. logmenutopright.style["width"] = (width/2).toString()+"px";
  6404. logmenutopright.style["left"] = (width/2).toString()+"px";
  6405. debuggerinput.style["width"] = width.toString()+"px";
  6406. debuggerinput.style["top"] = (height+90).toString()+"px";
  6407. debuggersendrecieve.style["top"] = (height+120).toString()+"px";
  6408. debuggerpausebutton.style["top"] = (height+150).toString()+"px";
  6409. debuggereval.style["width"] = (width-150).toString()+"px";
  6410. debuggereval.style["top"] = (height+120).toString()+"px";},true);
  6411. function timeout123() {
  6412. updateWssLog();
  6413. EVENTLOOPFUNCTION();
  6414. var now = Date.now();
  6415. var keys = Object.keys(playerids);
  6416. if(getroomslastcheck+3000<now){
  6417. getroomslastcheck = now;
  6418. if(inroom && savedrooms.length>0){
  6419. Gdocument.getElementById("roomlistrefreshbutton").click();
  6420. }
  6421. }
  6422. var namelist = Gdocument.getElementsByClassName("newbonklobby_playerentry_name");
  6423. for(var i = 0;i<namelist.length;i++){
  6424. var level = 0;
  6425. var levelelement = 0;
  6426. var pingelement = 0;
  6427. var avatarelement = 0;
  6428. var children = namelist[i].parentElement.children;
  6429. for(var i2 = 0;i2<children.length;i2++){
  6430. if(children[i2].className == "newbonklobby_playerentry_level"){
  6431. levelelement = children[i2];
  6432. level = parseInt(children[i2].textContent.slice(6));
  6433. }
  6434. else if(children[i2].className == "newbonklobby_playerentry_pingtext"){
  6435. pingelement = children[i2];
  6436. }
  6437. else if(children[i2].className == "newbonklobby_playerentry_avatar"){
  6438. avatarelement = children[i2];
  6439. }
  6440. }
  6441. var isadmin = [false,0];
  6442. for(var i3 = 0;i3<admins.length;i3++){
  6443. if(admins[i3][0] == namelist[i].textContent){
  6444. isadmin = [true,i3];
  6445. break;
  6446. }
  6447. }
  6448. if(level){
  6449. if(isadmin[0]){
  6450. namelist[i].style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6451. if(isadmin[1]<=3){
  6452. var rotatevalue = 0;
  6453. if(admins[isadmin[1]][1][3]<90){
  6454. rotatevalue = admins[isadmin[1]][1][3]/2;
  6455. }
  6456. else if(admins[isadmin[1]][1][3]<270){
  6457. rotatevalue =(180-admins[isadmin[1]][1][3])/2;
  6458. }
  6459. else if(admins[isadmin[1]][1][3]<360){
  6460. rotatevalue = (-360+admins[isadmin[1]][1][3])/2;
  6461. }
  6462. namelist[i].parentElement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6463. namelist[i].parentElement.style["font-size"] = "17px";
  6464. 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()+")";
  6465. if(levelelement){
  6466. levelelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6467. }
  6468. if(pingelement){
  6469. pingelement.style["color"] = "rgb("+admins[isadmin[1]][1].slice(0,-1).toString()+")";
  6470. }
  6471. if(avatarelement){
  6472. avatarelement.style["filter"] = "hue-rotate("+rotatevalue.toString()+"deg)";
  6473. }
  6474. }
  6475. }
  6476. }
  6477. var stylekeys = Object.keys(allstyles);
  6478. for(var i3 = 0;i3<stylekeys.length;i3++){
  6479. if(stylekeys[i3] == namelist[i].textContent){
  6480. 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])){
  6481. var rgbvalue = [allstyles[stylekeys[i3]][0],allstyles[stylekeys[i3]][1],allstyles[stylekeys[i3]][2]];
  6482. namelist[i].style["color"] = "rgb("+rgbvalue.toString()+")";
  6483. if(!isadmin[0]){
  6484. var n = 255;
  6485. namelist[i].parentElement.style["background"] = "rgb("+[(203+rgbvalue[0])%n,(212+rgbvalue[1])%n,(215+rgbvalue[2])%n].toString()+")";
  6486. }
  6487. if(levelelement){
  6488. levelelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6489. }
  6490. if(pingelement){
  6491. pingelement.style["color"] = "rgb("+rgbvalue.toString()+")";
  6492. }
  6493. }
  6494. }
  6495. }
  6496. }
  6497. for(var i3 = 0;i3<admins.length;i3++){
  6498. if(admins[i3][1][0]==0 && admins[i3][1][1]==0 && admins[i3][1][2]==0){
  6499. admins[i3][1][2] = 180;
  6500. admins[i3][1][1] = 0;
  6501. admins[i3][1][0] = 0;
  6502. }
  6503. var rate = 5;
  6504. var lowest = 0;
  6505. var number = 360;
  6506. admins[i3][1][3] = (admins[i3][1][3]%number+4+number)%number;
  6507. if(admins[i3][1][0]>lowest && admins[i3][1][1] == lowest){
  6508. admins[i3][1][0]-=rate;
  6509. admins[i3][1][2]+=rate;
  6510. }
  6511. if(admins[i3][1][2]>lowest && admins[i3][1][0] == lowest){
  6512. admins[i3][1][2]-=rate;
  6513. admins[i3][1][1]+=rate;
  6514. }
  6515. if(admins[i3][1][1]>lowest && admins[i3][1][2] == lowest){
  6516. admins[i3][1][0]+=rate;
  6517. admins[i3][1][1]-=rate;
  6518. }
  6519. for(var i4 = 0;i4<3;i4++){
  6520. if(admins[i3][1][i4]<lowest){
  6521. admins[i3][1][i4]=lowest;
  6522. }
  6523. else if(admins[i3][1][i4]>255){
  6524. admins[i3][1][i4]=255;
  6525. }
  6526. }
  6527. }
  6528. if(randomchat){
  6529. if(randomchat_timestamp+randomchat_randomtimestamp<now){
  6530. randomchat_timestamp = now;
  6531. randomchat_randomtimestamp = 2000+Math.random()*2000;
  6532. var randnumber = Math.floor(Math.random()*randomchatpriority[0])-randomchatlastmessage[1];
  6533. for(var i = 0;i<randomchatpriority[1].length;i++){
  6534. if(randomchatpriority[1][i][0]!=randomchatlastmessage[0]){
  6535. randnumber-=randomchatpriority[1][i][1];
  6536. if(randnumber<=0){
  6537. chat(flag_manage(randomchatpriority[1][i][0]));
  6538. randomchatpriority[1][i][1]+=2;
  6539. randomchatpriority[0]+=2;
  6540. randomchatlastmessage = randomchatpriority[1][i];
  6541. break;
  6542. }
  6543. }
  6544. }
  6545. }
  6546. }
  6547. for(var i = 0;i<keys.length;i++){
  6548. 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){
  6549. SEND('42[9,{"banshortid":'+keys[i].toString()+',"kickonly":'+(autokickban == 1).toString()+'}]');
  6550. autokickbantimestamp = now;
  6551. }
  6552. if(playerids[keys[i]].playerData){
  6553. if(playerids[keys[i]].playerData2){
  6554. if(playerids[keys[i]].playerData.transform){
  6555. playerids[keys[i]].playerData2.alive = true;
  6556. if(playerids[keys[i]].playerData2.timeStamp == 0){
  6557. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6558. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6559. playerids[keys[i]].playerData2.timeStamp = performance.now();
  6560. }
  6561. else{
  6562. playerids[keys[i]].playerData2.xvel = (playerids[keys[i]].playerData2.px - playerids[keys[i]].playerData.transform.position.x)/(playerids[keys[i]].playerData2.timeStamp-performance.now());
  6563. playerids[keys[i]].playerData2.yvel = (playerids[keys[i]].playerData2.py - playerids[keys[i]].playerData.transform.position.y)/(playerids[keys[i]].playerData2.timeStamp-performance.now());
  6564. playerids[keys[i]].playerData2.px = playerids[keys[i]].playerData.transform.position.x;
  6565. playerids[keys[i]].playerData2.py = playerids[keys[i]].playerData.transform.position.y;
  6566. playerids[keys[i]].playerData2.timeStamp = performance.now();
  6567. }
  6568. if(playerids[keys[i]].playerData2.timeStamp2 == 0){
  6569. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6570. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6571. playerids[keys[i]].playerData2.timeStamp2 = performance.now();
  6572. }
  6573. else{
  6574. playerids[keys[i]].playerData2.xacc = (playerids[keys[i]].playerData2.pvx - playerids[keys[i]].playerData2.xvel)/((playerids[keys[i]].playerData2.timeStamp2-performance.now()));
  6575. playerids[keys[i]].playerData2.yacc = (playerids[keys[i]].playerData2.pvy - playerids[keys[i]].playerData2.yvel)/((playerids[keys[i]].playerData2.timeStamp2-performance.now()));
  6576. playerids[keys[i]].playerData2.pvx = playerids[keys[i]].playerData2.xvel;
  6577. playerids[keys[i]].playerData2.pvy = playerids[keys[i]].playerData2.yvel;
  6578. playerids[keys[i]].playerData2.timeStamp2 = performance.now();
  6579. }
  6580. }
  6581. else{
  6582. if(playerids[keys[i]].playerData2.alive){
  6583. }
  6584. playerids[keys[i]].playerData2.alive = false;
  6585. }
  6586. }
  6587. else{
  6588. playerids[keys[i]].playerData2 = {alive:true,radius:12,timeStamp:0,timeStamp2:0,px:0,py:0,pvx:0,pvy:0,xacc:0,yacc:0,xvel:0,yvel:0,balance:0};
  6589. }
  6590. }
  6591. }
  6592. for(var i = 0;i<keys.length;i++){
  6593. if(!playerids[keys[i]].playerData2){
  6594. 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};
  6595. }
  6596. }
  6597. if(Gdocument.getElementById("redefineControls_table").children[0].children.length<=1 && keys.length>0){
  6598. Gdocument.getElementById("pretty_top_settings").click();
  6599. Gdocument.getElementById("settings_close").click();
  6600. }
  6601. if(pollactive[0] && pollactive[2]<now && ishost){
  6602. playerids[myid].ratelimit.poll = Date.now();
  6603. SEND("42"+JSON.stringify([4,{"type":"poll end","from":username}]));
  6604. var count = [0,0,0,0];
  6605. var keys = Object.keys(playerids);
  6606. for(var i = 0;i<keys.length;i++){
  6607. if(playerids[keys[i]].vote.poll!=-1 && playerids[keys[i]].vote.poll<pollactive[3].length-1){
  6608. count[playerids[keys[i]].vote.poll]++;
  6609. }
  6610. playerids[keys[i]].vote.poll = -1;
  6611. }
  6612. displayInChat("The poll ended due to time.","#DA0808","#1EBCC1");
  6613. for(var i = 0;i<count.length;i++){
  6614. if(count[i]>1){
  6615. displayInChat(count[i].toString()+" people voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6616. }
  6617. if(count[i]==1){
  6618. displayInChat(count[i].toString()+" person voted for option "+letters[i]+".","#DA0808","#1EBCC1");
  6619. }
  6620. }
  6621. displayInChat("The poll was:","#DA0808","#1EBCC1");
  6622. for(var i = 0;i<pollactive[3].length;i++){
  6623. displayInChat(letters[i]+") "+pollactive[3][i],"#DA0808","#1EBCC1");
  6624. }
  6625. pollactive = [false,0,0,[]];
  6626. }
  6627. if(!ishost && sandboxcopyme!=-1){
  6628. sandboxcopyme = -1;
  6629. }
  6630. if(afkkill>0 && ishost){
  6631. var keys = Object.keys(playerids);
  6632. currentFrame = Math.floor((now - gameStartTimeStamp)/1000*30);
  6633. for(var i = 0; i<keys.length;i++){
  6634. if(typeof(playerids[keys[i]].lastmove)=="undefined"){
  6635. playerids[keys[i]].lastmove = now;
  6636. }
  6637. else{
  6638. if(playerids[keys[i]].playerData2?.alive && now-playerids[keys[i]].lastmove>=afkkill*1000 && now-gameStartTimeStamp>=afkkill*1000 && !killedids.includes(keys[i])){
  6639. killedids.push(keys[i]);
  6640. SEND('42[25,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6641. RECIEVE('42[31,{"a":{"playersLeft":['+keys[i]+'],"playersJoined":[]},"f":'+currentFrame.toString()+'}]');
  6642. break;
  6643. }
  6644. }
  6645. }
  6646. }
  6647. if(ishost && Gdocument.getElementById("maploadtypedropdowntitle").textContent == "MAP REQUESTS"){
  6648. clearmaprequests.style["display"] = "block";
  6649. refreshmaprequests.style["display"] = "block";
  6650. }
  6651. else{
  6652. clearmaprequests.style["display"] = "none";
  6653. refreshmaprequests.style["display"] = "none";
  6654. }
  6655. if(Gdocument.getElementById("gamerenderer").style["visibility"]=="hidden"){
  6656. Gdocument.getElementById("ingamewinner_scores").style["visibility"] = "unset";
  6657. Gdocument.getElementById("ingamechatcontent").style["max-height"]=chatheight.toString()+"px";
  6658. pan = {"x":0,"y":0};
  6659. }
  6660. if(Gdocument.getElementById("maploadwindowmapscontainer").children.length>0 && maponclick == 0){
  6661. maponclick = Gdocument.getElementById("maploadwindowmapscontainer").children[0].onclick;
  6662. }
  6663. 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"] == "")){
  6664. var chatbox = Gdocument.getElementById("newbonklobby_chat_content");
  6665. while (chatbox.firstChild) {
  6666. chatbox.removeChild(chatbox.firstChild);
  6667. }
  6668. chatbox = Gdocument.getElementById("ingamechatcontent");
  6669. while (chatbox.firstChild) {
  6670. chatbox.removeChild(chatbox.firstChild);
  6671. }
  6672. rcaps_flag = false;
  6673. space_flag = false;
  6674. number_flag = false;
  6675. reverse_flag = false;
  6676. autocorrect = false;
  6677. translating2 = [false,""];
  6678. translating = [false,""];
  6679. echo_list = [];
  6680. scroll = false;
  6681. FollowCam = false;
  6682. autocam = false;
  6683. aimbot = false;
  6684. recievedinitdata = false;
  6685. zoom = 1;
  6686. zoom2 = 1;
  6687. newzoom = 1;
  6688. newzoom2 = 1;
  6689. FFA = true;
  6690. mode = "b";
  6691. ghostroomwss = -1;
  6692. heavybot = false;
  6693. stopquickplay = 1;
  6694. roundsperqp = 1;
  6695. roundsperqp2 = 0;
  6696. staystill = false;
  6697. staystillpos = [0,0];
  6698. recording = false;
  6699. recordingid = -1;
  6700. reverseqp = false;
  6701. jointeam = -1;
  6702. currentroomaddress = -1;
  6703. checkboxhidden = false;
  6704. freejoin = false;
  6705. shuffle = false;
  6706. textmode = -1;
  6707. defaultmode = "";
  6708. recmodebool = false;
  6709. recteams = false;
  6710. autorecord = false;
  6711. pollactive = [false,0,0,[]];
  6712. pollactive2 = [false,0,[]];
  6713. afkkill = -1;
  6714. nextafter = 0;
  6715. jointext = "";
  6716. ishost = false;
  6717. parentDraw = 0;
  6718. sandboxplayerids = {};
  6719. sandboxcopyme = -1;
  6720. wintext = "";
  6721. sandboxon = false;
  6722. sandboxid = 200;
  6723. disabledkeys = [];
  6724. myid = -1;
  6725. randomchat = false;
  6726. savedroombutton.className = "brownButton brownButton_classic buttonShadow brownButtonDisabled";
  6727. randomchatpriority = [0,[]];
  6728. randomchatlastmessage = ["",0];
  6729. autokickbantimestamp = 0;
  6730. autokickban = 0;
  6731. inroom = false;
  6732. causelag = false;
  6733. causelag2 = 0;
  6734. jukeboxplayerURL = "";
  6735. jukeboxplayer.src = "";
  6736. jukeboxplayervolume = 20;
  6737. allstyles = {};
  6738. pan = {"x":0, "y":0};
  6739. if(!bonkwss){
  6740. playerids = {};
  6741. }
  6742. qppaused = false;
  6743. nextafterbuffer = -1;
  6744. hostid = -1;
  6745. if(chatlog[chatlog.length-1]!="ROOM END"){
  6746. chatlog.push("ROOM END");
  6747. }
  6748. }
  6749. else{
  6750. if(chatlog[chatlog.length-1]=="ROOM END"){
  6751. chatlog.push("ROOM START");
  6752. }
  6753. }
  6754. if(Gdocument.getElementById("newbonklobby").style["display"]=="block"){
  6755. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="hidden";
  6756. }
  6757. else{
  6758. Gdocument.getElementById("ingamechatinputtext").style["visibility"]="visible";
  6759. }
  6760. if((myid == hostid && myid!=-1) || Gdocument.getElementsByClassName('newbonklobby_settings_button brownButton brownButton_classic buttonShadow brownButtonDisabled').length == 0){
  6761. ishost = true;
  6762. }
  6763. else{
  6764. ishost = actuallyhost;
  6765. }
  6766. if(Gdocument.getElementById("pretty_top_name")!=null){
  6767. username = Gdocument.getElementById("pretty_top_name").textContent;
  6768. if(myid!=-1){
  6769. username = playerids[myid].userName;
  6770. }
  6771. }
  6772. try{
  6773. Last_message = lastmessage()
  6774. } catch{
  6775. Last_message = "";
  6776. }
  6777. if (Laster_message != Last_message){
  6778. Laster_message = Last_message;
  6779. if(changed_chat==false){
  6780. new_message = true;
  6781. }
  6782. else{
  6783. changed_chat = false;
  6784. }
  6785. }
  6786. if(new_message){
  6787. chatlog.push(Last_message);
  6788. var lm = "";
  6789. try{
  6790. lm = Gdocument.getElementById("newbonklobby_chat_content").children[Gdocument.getElementById("newbonklobby_chat_content").children.length-1].children;
  6791. if(typeof(lm[0].parentElement.style["parsed"]) == 'undefined'){
  6792. if (lm[0].className == "newbonklobby_chat_msg_colorbox"){
  6793. lm[2].innerHTML = urlify(lm[2].innerHTML);
  6794. Laster_message = lastmessage();
  6795. lm[0].parentElement.style["parsed"] = true;
  6796. }
  6797. if (lm[0].className == "newbonklobby_chat_status"){
  6798. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6799. Laster_message = lastmessage();
  6800. lm[0].parentElement.style["parsed"] = true;
  6801. }
  6802. }
  6803. }
  6804. catch{
  6805. lm = "";
  6806. }
  6807. if(Last_message.indexOf("@"+username)!=-1 && npermissions == 1){
  6808. if(Notification.requestPermission()){
  6809. var n = new Notification(Last_message);
  6810. }
  6811. }
  6812. try{
  6813. lm = Gdocument.getElementById("ingamechatcontent").children[Gdocument.getElementById("ingamechatcontent").children.length-1].children;
  6814. if(typeof(lm[0].parentElement.style["parsed"])=='undefined'){
  6815. if(lm[0].className == "ingamechatname"){
  6816. lm[1].innerHTML = urlify(lm[1].innerHTML);
  6817. Laster_message = lastmessage();
  6818. lm[0].parentElement.style["parsed"] = true;
  6819. }
  6820. if(lm[0].className == ""){
  6821. lm[0].innerHTML = urlify(lm[0].innerHTML);
  6822. Laster_message = lastmessage();
  6823. lm[0].parentElement.style["parsed"] = true;
  6824. }
  6825. }
  6826. }
  6827. catch{
  6828. lm = "";
  6829. }
  6830. if(text2speech){
  6831. if(!sayer.speaking){
  6832. if(Last_message.includes(": ")){
  6833. speech.text = Last_message.substring(0,Last_message.indexOf(":")).toLowerCase();
  6834. speech.rate = 2.25;
  6835. sayer.speak(speech);
  6836. speech.text = Last_message.substring(Last_message.indexOf(": ")+3).toLowerCase();
  6837. speech.rate = 1.25;
  6838. sayer.speak(speech);
  6839. }
  6840. else{
  6841. speech.text = Last_message.toLowerCase();
  6842. sayer.speak(speech);
  6843. }
  6844. }
  6845. }
  6846. }
  6847. if (ishost==true && new_message){
  6848. for(i=0;i<banned.length;i++){
  6849. if(Last_message.startsWith("* "+banned[i]+" has joined the game")){
  6850. chat2("/kick '"+banned[i]+"'");
  6851. }
  6852. }
  6853. }
  6854. if(Gdocument.getElementById("gamerenderer").style["visibility"] == "hidden" && ishost){
  6855. roundsperqp2 = 0;
  6856. }
  6857. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && ishost){
  6858. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true){
  6859. if(stopquickplay!=1){
  6860. roundsperqp2++;
  6861. }
  6862. if(autorecord){
  6863. Gdocument.getElementById("pretty_top_replay").click();
  6864. }
  6865. }
  6866. if(Gdocument.getElementById("ingamewinner").style["parsed"] != true && wintext!="" && Gdocument.getElementById("ingamewinner_bottom").textContent!="DRAW"){
  6867. chat(flag_manage(wintext.replaceAll("username",Gdocument.getElementById("ingamewinner_top").textContent)));
  6868. }
  6869. Gdocument.getElementById("ingamewinner").style["parsed"] = true;
  6870. }
  6871. else{
  6872. Gdocument.getElementById("ingamewinner").style["parsed"] = false;
  6873. }
  6874. if(ishost && stopquickplay == 0){
  6875. if(checkboxhidden){
  6876. checkboxhidden = false;
  6877. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  6878. for(var i = 0; i<classes.length;i++){
  6879. classes[i].style["display"] = "block";
  6880. classes[i].className = "quickplaycheckbox quickplaychecked";
  6881. }
  6882. Gdocument.getElementById('clearallcheckboxes').style["display"] = "block";
  6883. }
  6884. if(nextafter>0 && gameStartTimeStamp+nextafter*1000<=now && Gdocument.getElementById("gamerenderer").style["visibility"] != "hidden" && dontswitch == false && Gdocument.getElementById("ingamewinner").style["visibility"]!="inherit" && !qppaused){
  6885. roundsperqp2 = 0;
  6886. if(shuffle){
  6887. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6888. var available = [];
  6889. var availableindexes = [];
  6890. var notempty = false;
  6891. for(var i = 0; i<e.length;i++){
  6892. var a = false;
  6893. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6894. available.push(a);
  6895. if(a){
  6896. availableindexes.push(i);
  6897. notempty = true;
  6898. }
  6899. }
  6900. if(notempty){
  6901. if(availableindexes.length!=1){
  6902. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6903. }
  6904. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6905. }
  6906. }
  6907. else{
  6908. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6909. var available = [];
  6910. var availableindexes = [];
  6911. var notempty = false;
  6912. for(var i = 0; i<e.length;i++){
  6913. var a = false;
  6914. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6915. available.push(a);
  6916. if(a){
  6917. availableindexes.push(i);
  6918. notempty = true;
  6919. }
  6920. }
  6921. if(notempty){
  6922. var above = [];
  6923. for(var i = 0;i<availableindexes.length;i++){
  6924. if(availableindexes[i]>quicki && !reverseqp){
  6925. above.push(availableindexes[i]);
  6926. }
  6927. else if(availableindexes[i]<quicki && reverseqp){
  6928. above.push(availableindexes[i]);
  6929. }
  6930. }
  6931. if(above.length>0){
  6932. quicki = above[0];
  6933. if(reverseqp){
  6934. above[above.length-1];
  6935. }
  6936. }
  6937. else{
  6938. quicki = availableindexes[0];
  6939. if(reverseqp){
  6940. quicki = availableindexes[availableindexes.length-1];
  6941. }
  6942. }
  6943. }
  6944. }
  6945. startedinqp = true;
  6946. dontswitch = true;
  6947. gotonextmap(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  6948. }
  6949. if(Gdocument.getElementById("ingamewinner").style["visibility"]=="inherit" && dontswitch == false && !document.hidden && !qppaused){
  6950. if(roundsperqp2>=roundsperqp){
  6951. if(shuffle){
  6952. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6953. var available = [];
  6954. var availableindexes = [];
  6955. var notempty = false;
  6956. for(var i = 0; i<e.length;i++){
  6957. var a = false;
  6958. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6959. available.push(a);
  6960. if(a){
  6961. availableindexes.push(i);
  6962. notempty = true;
  6963. }
  6964. }
  6965. if(notempty){
  6966. if(availableindexes.length!=1){
  6967. availableindexes.splice(availableindexes.indexOf(quicki%Gdocument.getElementById("maploadwindowmapscontainer").children.length),1);
  6968. }
  6969. quicki = availableindexes[Math.floor(Math.random()*availableindexes.length)];
  6970. }
  6971. }
  6972. else{
  6973. var e = Gdocument.getElementById("maploadwindowmapscontainer").children;
  6974. var available = [];
  6975. var availableindexes = [];
  6976. var notempty = false;
  6977. for(var i = 0; i<e.length;i++){
  6978. var a = false;
  6979. [...e[i].children].forEach(function(e1){if(e1.className=="quickplaycheckbox quickplaychecked"){a = e1.checked}});
  6980. available.push(a);
  6981. if(a){
  6982. availableindexes.push(i);
  6983. notempty = true;
  6984. }
  6985. }
  6986. if(notempty){
  6987. var above = [];
  6988. for(var i = 0;i<availableindexes.length;i++){
  6989. if(availableindexes[i]>quicki && !reverseqp){
  6990. above.push(availableindexes[i]);
  6991. }
  6992. else if(availableindexes[i]<quicki && reverseqp){
  6993. above.push(availableindexes[i])
  6994. }
  6995. }
  6996. if(above.length>0){
  6997. quicki = above[0];
  6998. if(reverseqp){
  6999. quicki = above[above.length-1];
  7000. }
  7001. }
  7002. else{
  7003. quicki = availableindexes[0];
  7004. if(reverseqp){
  7005. quicki = availableindexes[availableindexes.length-1];
  7006. }
  7007. }
  7008. }
  7009. }
  7010. }
  7011. transitioning = true;
  7012. startedinqp = true;
  7013. map(quicki%(Gdocument.getElementById("maploadwindowmapscontainer").children.length));
  7014. dontswitch = true;
  7015. setTimeout(function(){Gdocument.getElementById("ingamewinner").style["visibility"]="hidden"; dontswitch = false;},timedelay);
  7016. }
  7017. }
  7018. else{
  7019. if(!checkboxhidden){
  7020. checkboxhidden = true;
  7021. var classes = Gdocument.getElementsByClassName("quickplaycheckbox");
  7022. for(var i = 0; i<classes.length;i++){
  7023. classes[i].style["display"] = "none";
  7024. classes[i].className = "quickplaycheckbox quickplayunchecked";
  7025. }
  7026. Gdocument.getElementById('clearallcheckboxes').style["display"] = "none";
  7027. }
  7028. }
  7029. new_message = false;
  7030. };
  7031. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址