Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var room = HBInit({
- roomName: ">>>>>>> FREE PLAY <<<<<<< [TEST V2]",
- maxPlayers: 18,
- public: true,
- noPlayer: true // Remove host player (recommended!)
- });
- room.setDefaultStadium("Big");
- room.setScoreLimit(3);
- room.setTimeLimit(3);
- // If there are no admins left in the room give admin to one of the remaining players.
- function updateAdmins() {
- // Get all players
- var players = room.getPlayerList();
- if (players.length == 0) return; // No players left, do nothing.
- var nb = players.filter((player) => player.admin).length;
- if (nb >= 2) return;
- if (nb == 1)
- if (players.length > 1){
- room.setPlayerAdmin(players[1].id, true); // Give admin to the first non admin player in the list
- room.setPlayerAdmin(players[0].id, true);
- }
- if (nb == 0)
- if (players.length > 0)
- 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