Development
Players in UASECO
The Playerlist in UASECO are accessible in several ways, here i want to show you all possible ways:
Check if there are Players connected
// Bail out if there are no Players if ($aseco->server->players->count() == 0) { return; }
Get the amount of the current connected Players
$amount = $aseco->server->players->count();
Check if the Player has left the Server
$login = 'han_solo'; if (!$id = $aseco->server->players->getPlayerIdByLogin($login)) { // Bail out if the Player left the Server return; }
Walk through the Playerlist
$login = 'han_solo'; foreach ($aseco->server->players->player_list as $player) { if ($player->login == $login) { // Do something... } } unset($player);
Receive a specific Player object from a given $login
$login = 'han_solo'; $player = $aseco->server->players->getPlayerByLogin($login);
With this $player
object you can access the Nickname, the Database-Id (for using it in a SQL-Query)
and many more of this Player:
Examples
$nick = $player->nickname; $dbid = $player->id;
Do not mix up with
$player->id
and$player->pid
! The$player->id
is the Database-Player-Id and$player->pid
is the Player-Id from the dedicated Server.
If you only need the Database-Player-Id from a $login
, then you can use this,
instead of copy the whole Player object (which is huge!):
Get the Database-Player-Id from a given $login
$login = 'han_solo'; $dbid = $aseco->server->players->getPlayerIdByLogin($login);
To see all possible variables, just dump the whole $player
object into the logfile from UASECO:
Dump $player object
$aseco->dump( $player );
or take a look at the class documentation for includes/types/player.class.php.
Development
Players rights
Sometimes it is required to figure out if the calling Player is a Operator
,
Admin
or MasterAdmin
. For such situations there are functions they know it.
Functions which require only the $login
from a Player:
Function | Description |
---|---|
$aseco->isOperatorByLogin($login) |
Checks if the given player login is in operator list. |
$aseco->isAdminByLogin($login) |
Checks if the given player login is in admin list. |
$aseco->isMasterAdminByLogin($login) |
Checks if the given player login is in masteradmin list. |
$aseco->isAnyAdminByLogin($login) |
Checks if the given player login is in operator list. |
Functions which require the whole $player
object:
Function | Description |
---|---|
$aseco->isOperator($player) |
Checks if the given player is in operator list with, optionally, an authorized IP. |
$aseco->isAdmin($player) |
Checks if the given player is in admin list with, optionally, an authorized IP. |
$aseco->isMasterAdmin($player) |
Checks if the given player is in masteradmin list with, optionally, an authorized IP. |
$aseco->isAnyAdmin($player) |
Checks if the given player is in any admin tier with, optionally, an authorized IP. |
All of the above functions are returning true
or false
Development
Players state
Each Player can be a Player
or a Spectator
, in several situations it is required,
that some of your Widgets are hidden if the Player is a Spectator
to not overlay some of the
in-game Widgets.
Check Player state
if ($player->is_spectator == 1) { // Hide Widget... }
The event onPlayerInfoChanged
is fired everytime when there are changes at the Player. With this event
you are able to interact on temporary Spectator changes, because with the above you can only find PureSpectator
:
Check Player state at the event onPlayerInfoChanged
public function onPlayerInfoChanged ($aseco, $changes) { // Catch all Spectators (e.g.: Spectator, TemporarySpectator or PureSpectator) if ($changes['SpectatorStatus'] > 0) { // Hide Widget... } else { // Show Widget... } }
This is a private enthusiast Website. Maniaplanet, Trackmania, Shootmania, Nadeo are trademarks of Ubisoft Entertainment.
Windows is a registered trademark of Microsoft Corporation.