Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var room = HBInit({ roomName: My room, maxPlayers: 16 });
  2. room.setDefaultStadium(Big);
  3. room.setScoreLimit(5);
  4. room.setTimeLimit(0);
  5.  
  6. // If there are no admins left in the room give admin to one of the remaining players.
  7. function updateAdmins() {
  8.   // Get all players except the host (id = 0 is always the host)
  9.   var players = room.getPlayerList().filter((player) => player.id != 0 );
  10.   if ( players.length == 0 ) return; // No players left, do nothing.
  11.   if ( players.find((player) => player.admin) != null ) return; // There's an admin left so do nothing.
  12.   room.setPlayerAdmin(players[0].id, true); // Give admin to the first non admin player in the list
  13. }
  14.  
  15. room.onPlayerJoin = function(player) {
  16. updateAdmins();
  17. }
  18.  
  19. room.onPlayerLeave = function(player) {
  20. updateAdmins();
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement