Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Josh's MPP Room Locker
- // @description Lock an MPP room and only allow entrance if the name is set to the passphrase
- // @namespace Copyright 2018 SYZYGY-DEV333; licensed under Apache v2
- // @version 0.1
- // @author Josh (SYZYGY-DEV333)
- // @match http://www.multiplayerpiano.com/*
- // @match https://www.multiplayerpiano.com/*
- // @match http://ourworldofpixels.com/piano/*
- // @grant none
- // ==/UserScript==
- var pass = "passphrase";
- var locked = false; // <===
- function kickban(id, ms) {
- MPP.client.sendArray([{m: "kickban", _id: id, ms: ms}]);
- }
- MPP.client.on("participant added", function(pp) {
- if (locked) { // <===
- if (MPP.client.channel.crown.userId == MPP.client.getOwnParticipant()._id) {
- if (pp.name == pass) { // <===
- } else {
- kickban(pp._id, 10000);
- }
- }
- }
- });
- MPP.client.on('a', function(m) {
- if (m.a == '-lock') {
- if (m.p._id == MPP.client.getOwnParticipant()._id) {
- locked = true; // <===
- MPP.chat.send("Room Locked.");
- }
- } else if (m.a == '-unlock') {
- if (m.p._id == MPP.client.getOwnParticipant()._id) {
- locked = false; // <===
- MPP.chat.send("Room Unlocked.");
- }
- } else if (m.a.startsWith('-setpass')) {
- if (m.p._id == MPP.client.getOwnParticipant()._id) {
- pass = m.a.slice(9);
- MPP.chat.send("Passphrase set to: "+m.a.slice(9));
- }
- } else if (m.a == '-help') {
- if (m.p._id == MPP.client.getOwnParticipant()._id) {
- MPP.chat.send("[[ Josh's MPP Room Locker v0.1 ]]");
- MPP.chat.send("-lock -- Locks room.");
- MPP.chat.send("-unlock -- Unlocks room.");
- MPP.chat.send("-setpass [pass] -- sets a passphrase for entry.");
- MPP.chat.send("All users must have this as their name when entering the room.");
- MPP.chat.send("-help -- displays this help message.");
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement