Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. var room = HBInit({
  2. roomName: ">>>>>>> FREE PLAY <<<<<<< [TEST V2]",
  3. maxPlayers: 18,
  4. public: true,
  5. noPlayer: true // Remove host player (recommended!)
  6. });
  7. room.setDefaultStadium("Big");
  8. room.setScoreLimit(3);
  9. room.setTimeLimit(3);
  10.  
  11. // If there are no admins left in the room give admin to one of the remaining players.
  12. function updateAdmins() {
  13. // Get all players
  14. var players = room.getPlayerList();
  15.  
  16. if (players.length == 0) return; // No players left, do nothing.
  17. var nb = players.filter((player) => player.admin).length;
  18.  
  19. if (nb >= 2) return;
  20.  
  21. if (nb == 1)
  22. if (players.length > 1){
  23. room.setPlayerAdmin(players[1].id, true); // Give admin to the first non admin player in the list
  24. room.setPlayerAdmin(players[0].id, true);
  25. }
  26.  
  27. if (nb == 0)
  28. if (players.length > 0)
  29. room.setPlayerAdmin(players[0].id, true); // Give admin to the first non admin player in the list
  30. }
  31.  
  32. room.onPlayerJoin = function (player) {
  33. updateAdmins();
  34. }
  35.  
  36. room.onPlayerLeave = function (player) {
  37. updateAdmins();
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement