Bonk Commands

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

当前为 2024-04-10 提交的版本,查看 最新版本

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