Advertisement
Slowstone72

RoomSaver

Dec 20th, 2024 (edited)
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.69 KB | Software | 0 0
  1. /* Ancient code published for archival purposes. May or may not work or be relevant.
  2. Feel free to do whatever you want with this, if anything.
  3. Archive from 2017-10-07 - contents may be older. */
  4.  
  5. //RoomSaver
  6.  
  7.  
  8. clientWebsite = 'multiplayerpiano.com';
  9. clientWebsitePort = '8080';
  10. clientWebsocket = 'ws://' + clientWebsite + ':' + clientWebsitePort;
  11. startroom = 'test/RoomSaver';
  12. message = true;
  13. roomOwner = '';
  14. function start() {
  15. roomOwner = MPP.client.channel.crown.userId;
  16. rs = new Client(clientWebsocket);
  17. rs.setChannel(startroom);
  18. rs.start();
  19. send = function(message) {rs.sendArray([{m:"a", message: message}]);}
  20. setTimeout(function() {
  21. send('Hello! I\'m RoomSaver. If the owner of this room disconnects for any reason, I will pick up the crown to prevent others from stealing it. Once the owner of the room is connected again, I will give the crown back to the owner.');
  22. send('This bot was made to prevent rooms from being took over when the owner leaves the room.');
  23. pickupcrown = setInterval(function() {rs.sendArray([{m: "chown", id: rs.getOwnParticipant().id}]);
  24. if(rs.isOwner()) {if(message){send('room owner disconnected. picking up crown');message = false}}
  25. }, 0);
  26. setTimeout(function() {
  27. rs.on("participant added", function(msg){ if(msg._id==roomOwner) {send('room owner connected. welcome back.');setTimeout(function() {send('giving crown back to ' + msg._id + '');clearInterval(pickupcrown);rs.sendArray([{m: "chown", id: roomOwner}]);pickupcrown = setInterval(function() {rs.sendArray([{m: "chown", id: rs.getOwnParticipant().id}]);
  28. if(rs.isOwner()) {if(message){send('room owner disconnected. picking up crown');message = false}}
  29. }, 0);message = true;}, 10000);} }) });
  30.  
  31. }, 3000);}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement