added withoutbots to getplayercount
This commit is contained in:
parent
12e72c7398
commit
1c06e7ff6e
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#Additions
|
#Additions
|
||||||
- added changelog
|
- added changelog
|
||||||
|
- added SocketManager which acts like a webserver you can connect to and interact with ManiaControl
|
||||||
- added "//removerights login" command
|
- added "//removerights login" command
|
||||||
- added new EchoManager which handles Interactions between different Controllers
|
- added new EchoManager which handles Interactions between different Controllers
|
||||||
- It is possible to send an Echo command via the Method sendEcho, as message Parameter strings, objects or arrays can get used
|
- It is possible to send an Echo command via the Method sendEcho, as message Parameter strings, objects or arrays can get used
|
||||||
@ -10,7 +11,9 @@
|
|||||||
- On sending an Echo Message from another controller you need to provide an string to the dedicated method or an json_encoded array or object
|
- On sending an Echo Message from another controller you need to provide an string to the dedicated method or an json_encoded array or object
|
||||||
- 4 Echos are Implemented by ManiaControl (ManiaControl.Restart, ManiaControl.AuthenticationManager.GrandLevel, ManiaControl.AuthenticationManager.RevokeLevel, ManiaControl.PlayerManager.WarnPlayer)
|
- 4 Echos are Implemented by ManiaControl (ManiaControl.Restart, ManiaControl.AuthenticationManager.GrandLevel, ManiaControl.AuthenticationManager.RevokeLevel, ManiaControl.PlayerManager.WarnPlayer)
|
||||||
- added Method getServerLoginByIndex to Server object
|
- added Method getServerLoginByIndex to Server object
|
||||||
|
- added Parameter withoutBots to getPlayerCount (default on true)
|
||||||
- added some missing PHP Docs
|
- added some missing PHP Docs
|
||||||
|
- added some depency libraries as they are used by the Socket Handler
|
||||||
- updated some depency libraries
|
- updated some depency libraries
|
||||||
|
|
||||||
#Bug Fixes
|
#Bug Fixes
|
||||||
|
@ -382,15 +382,24 @@ class PlayerManager implements CallbackListener, TimerListener, EchoListener {
|
|||||||
* Get the count of all Players
|
* Get the count of all Players
|
||||||
*
|
*
|
||||||
* @param bool $withoutSpectators
|
* @param bool $withoutSpectators
|
||||||
|
* @param bool $withoutBots
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getPlayerCount($withoutSpectators = true) {
|
public function getPlayerCount($withoutSpectators = true, $withoutBots = true) {
|
||||||
if (!$withoutSpectators) {
|
|
||||||
return count($this->players);
|
|
||||||
}
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($this->players as $player) {
|
foreach ($this->players as $player) {
|
||||||
if (!$player->isSpectator) {
|
$valid = true;
|
||||||
|
if ($withoutSpectators) {
|
||||||
|
if ($player->isSpectator) {
|
||||||
|
$valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($withoutBots) {
|
||||||
|
if ($player->isFakePlayer()) {
|
||||||
|
$valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($valid) {
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user