Closed Sielinton closed 4 years ago
https://github.com/haxball/haxball-issues/wiki/Headless-Host
Check "Example:" just below api
Thanks.
I tried it this way: if (players.find ((player) => player.admin)> 1) return; But player.find just looks for the administrator, does not return the amount.
I will try the following command: if (players.length ((player) => player.admin)> 1) return;
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
What you're looking for is the filter method, and apply the length property.
players.filter(p => p.admin).length
returns the number of admins in the room.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
What you're looking for is the filter method, and apply the length property.
players.filter(p => p.admin).length
returns the number of admins in the room.
Exactly, thank you very much for your help!
How can I add a condition that if there is only 1 administrator online, the bot will grant administrator rights to another random player?
I tried some ways, like example = byPlayer.length but I believe it is necessary to check the list of players online with getPlayerList ()?