Players
Players on the server: IDs, names, identifiers and kicking. Provided by the GAMPEON server (game plugin or gampeon-server), not by the bare runtime.
GetPlayers
Section titled “GetPlayers”GetPlayers() --> string[]List the IDs of all players on the server. Server only.
Returns
string[]: Player IDs as strings, like in FiveM.
for _, id in ipairs(GetPlayers()) do print(id, GetPlayerName(id))endCompared to FiveM: Same as in FiveM.
GetNumPlayerIndices
Section titled “GetNumPlayerIndices”GetNumPlayerIndices() --> integerNumber of players on the server. Server only.
Returns
integer: Player count.
Compared to FiveM: Same as in FiveM.
GetPlayerFromIndex
Section titled “GetPlayerFromIndex”GetPlayerFromIndex(index) --> string?Player ID at a position in the player list. Server only.
| Parameter | Type | Description |
|---|---|---|
index |
integer |
0 to GetNumPlayerIndices() - 1. |
Returns
string?: Player ID, or nil if the index is out of range.
Compared to FiveM: Same as in FiveM.
DoesPlayerExist
Section titled “DoesPlayerExist”DoesPlayerExist(playerSrc) --> booleanCheck whether a player ID is on the server. Server only.
| Parameter | Type | Description |
|---|---|---|
playerSrc |
string|integer |
Player ID (source). |
Returns
boolean: true if the player is connected.
Compared to FiveM: Same as in FiveM.
GetPlayerName
Section titled “GetPlayerName”GetPlayerName(playerSrc) --> string?Display name of a player. Server and client.
| Parameter | Type | Description |
|---|---|---|
playerSrc |
string|integer |
Player ID (source) on the server. On the client only your own player (PlayerId()) for now. |
Returns
string?: The name, or nil for unknown IDs on the server. On the client “Invalid” for other players.
Compared to FiveM: Same as in FiveM. The name is the player’s GAMPEON display name. Client scripts can only read their own name for now.
GetPlayerIdentifiers
Section titled “GetPlayerIdentifiers”GetPlayerIdentifiers(playerSrc) --> string[]All identifiers of a player. Server only.
The first is always gampeon:<account id>. license:<40 hex> is derived from the account and the convar sv_licenseSalt, so databases from ESX and Qbox that key players by license keep working.
| Parameter | Type | Description |
|---|---|---|
playerSrc |
string|integer |
Player ID (source). |
Returns
string[]: Identifiers like “gampeon:42” and “license:…”.
for _, id in ipairs(GetPlayerIdentifiers(source)) do print(id) endCompared to FiveM: Same as in FiveM. There are no steam:, discord:, xbl: or ip: identifiers yet.
GetNumPlayerIdentifiers
Section titled “GetNumPlayerIdentifiers”GetNumPlayerIdentifiers(playerSrc) --> integerNumber of identifiers of a player. Server only.
| Parameter | Type | Description |
|---|---|---|
playerSrc |
string|integer |
Player ID (source). |
Returns
integer: Count, 0 for unknown IDs.
Compared to FiveM: Same as in FiveM.
GetPlayerIdentifier
Section titled “GetPlayerIdentifier”GetPlayerIdentifier(playerSrc, index) --> string?One identifier of a player by position. Server only.
| Parameter | Type | Description |
|---|---|---|
playerSrc |
string|integer |
Player ID (source). |
index |
integer |
0-based position. |
Returns
string?: The identifier, or nil.
Compared to FiveM: Same as in FiveM.
GetPlayerIdentifierByType
Section titled “GetPlayerIdentifierByType”GetPlayerIdentifierByType(playerSrc, identifierType) --> string?The identifier of a player with a given prefix. Server only.
| Parameter | Type | Description |
|---|---|---|
playerSrc |
string|integer |
Player ID (source). |
identifierType |
string |
Prefix without colon, for example “license” or “gampeon”. |
Returns
string?: For example “license:3f2a…”, or nil.
local license = GetPlayerIdentifierByType(source, 'license')Compared to FiveM: Same as in FiveM.
GetPlayerEndpoint
Section titled “GetPlayerEndpoint”GetPlayerEndpoint(playerSrc) --> string?Network address of a player, as far as the server shares it. Server only.
| Parameter | Type | Description |
|---|---|---|
playerSrc |
string|integer |
Player ID (source). |
Returns
string?: Address text, may be empty.
Compared to FiveM: Like FiveM. Servers may hide addresses for privacy, then it is empty.
GetPlayerPing
Section titled “GetPlayerPing”GetPlayerPing(playerSrc) --> integerRound-trip time to a player in milliseconds. Server only.
| Parameter | Type | Description |
|---|---|---|
playerSrc |
string|integer |
Player ID (source). |
Returns
integer: Ping in ms, 0 for unknown IDs.
Compared to FiveM: Same as in FiveM.
GetPlayerLastMsg
Section titled “GetPlayerLastMsg”GetPlayerLastMsg(playerSrc) --> integerMilliseconds since the last network event from a player. Server only.
| Parameter | Type | Description |
|---|---|---|
playerSrc |
string|integer |
Player ID (source). |
Returns
integer: Time in ms.
Compared to FiveM: Counts script events, not every network packet.
PlayerId
Section titled “PlayerId”PlayerId() --> integerHandle of your own player on the client. Pass it to GetPlayerServerId or GetPlayerName. Client only.
Returns
integer: Always 0 for now (the local player).
local myId = GetPlayerServerId(PlayerId())print('my server id is ' .. myId)Compared to FiveM: Same use as in FiveM. Other players’ handles come with the game natives in a later step.
GetPlayerServerId
Section titled “GetPlayerServerId”GetPlayerServerId(player) --> integerServer ID (source) of a player, as server scripts see it. Client only.
| Parameter | Type | Description |
|---|---|---|
player |
integer |
Player handle, for now only PlayerId(). |
Returns
integer: The server ID, 0 for unknown players.
TriggerServerEvent('myres:ready', GetPlayerServerId(PlayerId()))Compared to FiveM: Same as in FiveM for your own player.
DropPlayer
Section titled “DropPlayer”DropPlayer(playerSrc, reason?)Disconnect a player with a reason. Server only.
| Parameter | Type | Description |
|---|---|---|
playerSrc |
string|integer |
Player ID (source). |
reason (optional) |
string |
Shown to the player. |
DropPlayer(source, 'You were kicked for spamming.')Compared to FiveM: Same as in FiveM. playerDropped fires with the reason.