Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var room = HBInit({ roomName: My room, maxPlayers: 16 });
- room.setDefaultStadium(Big);
- room.setScoreLimit(5);
- room.setTimeLimit(0);
- // If there are no admins left in the room give admin to one of the remaining players.
- function updateAdmins() {
- // Get all players except the host (id = 0 is always the host)
- var players = room.getPlayerList().filter((player) => player.id != 0 );
- if ( players.length == 0 ) return; // No players left, do nothing.
- if ( players.find((player) => player.admin) != null ) return; // There's an admin left so do nothing.
- room.setPlayerAdmin(players[0].id, true); // Give admin to the first non admin player in the list
- }
- room.onPlayerJoin = function(player) {
- updateAdmins();
- }
- room.onPlayerLeave = function(player) {
- updateAdmins();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement