Advertisement
Guest User

Untitled

a guest
May 10th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name Josh's MPP Room Locker
  3. // @description Lock an MPP room and only allow entrance if the name is set to the passphrase
  4. // @namespace Copyright 2018 SYZYGY-DEV333; licensed under Apache v2
  5. // @version 0.1
  6. // @author Josh (SYZYGY-DEV333)
  7. // @match http://www.multiplayerpiano.com/*
  8. // @match https://www.multiplayerpiano.com/*
  9. // @match http://ourworldofpixels.com/piano/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. var pass = "passphrase";
  14.  
  15. var locked = false; // <===
  16.  
  17. function kickban(id, ms) {
  18.     MPP.client.sendArray([{m: "kickban", _id: id, ms: ms}]);
  19. }
  20.  
  21. MPP.client.on("participant added", function(pp) {
  22.     if (locked) {  // <===
  23.         if (MPP.client.channel.crown.userId == MPP.client.getOwnParticipant()._id) {
  24.             if (pp.name == pass) {  // <===
  25.             } else {
  26.                 kickban(pp._id, 10000);
  27.             }
  28.         }
  29.     }
  30. });
  31.  
  32. MPP.client.on('a', function(m) {
  33.     if (m.a == '-lock') {
  34.         if (m.p._id == MPP.client.getOwnParticipant()._id) {
  35.             locked = true; // <===
  36.             MPP.chat.send("Room Locked.");
  37.         }
  38.     } else if (m.a == '-unlock') {
  39.         if (m.p._id == MPP.client.getOwnParticipant()._id) {
  40.             locked = false; // <===
  41.             MPP.chat.send("Room Unlocked.");
  42.         }
  43.     } else if (m.a.startsWith('-setpass')) {
  44.         if (m.p._id == MPP.client.getOwnParticipant()._id) {
  45.             pass = m.a.slice(9);
  46.             MPP.chat.send("Passphrase set to: "+m.a.slice(9));
  47.         }
  48.     } else if (m.a == '-help') {
  49.         if (m.p._id == MPP.client.getOwnParticipant()._id) {
  50.             MPP.chat.send("[[ Josh's MPP Room Locker v0.1 ]]");
  51.             MPP.chat.send("-lock -- Locks room.");
  52.             MPP.chat.send("-unlock -- Unlocks room.");
  53.             MPP.chat.send("-setpass [pass] -- sets a passphrase for entry.");
  54.             MPP.chat.send("All users must have this as their name when entering the room.");
  55.             MPP.chat.send("-help -- displays this help message.");
  56.         }
  57.     }
  58. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement