-
Notifications
You must be signed in to change notification settings - Fork 15
Bans Request
In order to get the bans for a player, you can call the bans()
method on the Client
instance. This method takes 1 parameter which can either be the players SteamID64 or TruckersMP ID like so:
SteamID64
<?php
require_once('vendor/autoload.php');
$client = new TruckersMP\APIClient\Client();
$player = $client->bans('76561198154335536')->get();
TruckersMP ID
<?php
require_once('vendor/autoload.php');
$client = new TruckersMP\APIClient\Client();
$player = $client->bans(28159)->get();
This will return an instance of BanCollection
.
The BanCollection
returns an array of Ban
models. You can loop through the bans like so:
<?php
require_once('vendor/autoload.php');
$client = new TruckersMP\APIClient\Client();
$bans = $client->bans(28159)->get();
foreach ($bans as $ban) {
// $ban is an instance of a `Ban` model
}
To get the data from the model, a number of helpful getters have been created as shown below.
Method | Type | Description |
---|---|---|
getExpirationDate() |
?Carbon | The time that the ban will expire (UTC) or null if permanent |
getCreatedAt() |
Carbon | The players username |
isActive() |
bool | If the ban is still active [1] |
getReason() |
string | The reason the user was banned |
getAdminName() |
string | The name of the admin who banned the user) |
getAdminId() |
int | The TruckersMP ID of the admin that banned the user |
[1] For the player to be banned the expiration date has to either be passed or isActive()
has to be false.
Below is an example of how you would get the reason for each ban:
<?php
require_once('vendor/autoload.php');
$client = new TruckersMP\APIClient\Client();
$bans = $client->bans(28159)->get();
foreach ($bans as $ban) {
$reason = $ban->getReason();
}
If you have any questions about the library, you can create a topic on our forum.
This package is open-source and is licensed under the MIT license.