Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // make me a new year gift
- if(!window.Players) {
- Players = {};
- OWOP.on(26, up => {
- for(let p in up) Players[p] = {
- id: p,
- x: (up[p].x >> 4) | 0,
- y: (up[p].y >> 4) | 0,
- color: up[p].rgb,
- tool: up[p].tool
- }
- });
- OWOP.on(27, up => {
- for(let p of up) delete Players[p];
- })
- };
- teleporting = {};
- teleported = {};
- function makePortal(x, y, r, x2, y2) {
- OWOP.chat.local(`Created portal at ${x}, ${y} and ${x2}, ${y2} with size of ${r}x${r}`);
- OWOP.on(26, up => {
- for(let p in up) {
- if(teleporting[p]) continue;
- let pl = Players[p];
- if(x-r <= pl.x && x+r >= pl.x && y-r <= pl.y && y+r >= pl.y) {
- setTimeout(() => {
- pl = Players[p];
- if(x-r <= pl.x && x+r >= pl.x && y-r <= pl.y && y+r >= pl.y) {
- if(teleported[p]) return;
- OWOP.chat.send(`/tp ${pl.id} ${x2} ${y2}`);
- teleported[p] = 1;
- } else delete teleported[p];
- delete teleporting[p];
- }, 1000);
- teleporting[p] = 1;
- };
- if(x2-r <= pl.x && x2+r >= pl.x && y2-r <= pl.y && y2+r >= pl.y) {
- setTimeout(() => {
- pl = Players[p];
- if(x2-r <= pl.x && x2+r >= pl.x && y2-r <= pl.y && y2+r >= pl.y) {
- if(teleported[p]) return;
- OWOP.chat.send(`/tp ${pl.id} ${x} ${y}`);
- teleported[p] = 1;
- } else delete teleported[p];
- delete teleporting[p];
- }, 1000);
- teleporting[p] = 1;
- };
- // ik bug
- if(!(x-r <= pl.x && x+r >= pl.x && y-r <= pl.y && y+r >= pl.y) || !(x2-r <= pl.x && x2+r >= pl.x && y2-r <= pl.y && y2+r >= pl.y)) delete teleported[p];
- };
- });
- };
- oldCh = OWOP.chat.sendModifier;
- OWOP.chat.sendModifier = msg => {
- msg = oldCh(msg);
- if(msg.startsWith("/portal")) {
- let args = msg.split(" ").slice(1);
- if(args.length < 5) OWOP.chat.local("Command usage: /portal x y size x_dest y_dest");
- else makePortal(...args.map(i => +i));
- msg = "/";
- };
- return msg;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement