Players
Players work like in FiveM. Each player gets a numeric ID for the time they are on the server. Server scripts see it as source in events and pass it to the player functions.
Joining and leaving
Section titled “Joining and leaving”AddEventHandler('playerJoining', function() local src = source print(('%s joined with %s'):format(GetPlayerName(src), GetPlayerIdentifierByType(src, 'license')))end)
AddEventHandler('playerDropped', function(reason) -- The player still exists here: GetPlayerName and the identifiers work. print(('%s left: %s'):format(GetPlayerName(source), reason))end)playerJoining runs once the server has checked the player’s join ticket (see below), before the player spawns. playerConnecting with deferrals is not available yet.
Identifiers
Section titled “Identifiers”| Identifier | Example | Meaning |
|---|---|---|
gampeon: |
gampeon:4821 |
The player’s GAMPEON account. Stable, the same on every server. |
license: |
license:3f0c… (40 hex characters) |
Derived from the account and the server’s salt. Stable on your server, different on other servers. |
license: has the same format as in FiveM, so existing tables keyed by license: (ESX, QBCore, Qbox) keep working. Servers of one community can share players by setting the same salt in server.cfg:
set sv_licenseSalt "my-community"Without it, the salt is the server ID. Scripts cannot read or change the salt.
Player functions
Section titled “Player functions”| Function | Returns |
|---|---|
GetPlayers() |
All player IDs as strings |
GetNumPlayerIndices(), GetPlayerFromIndex(i) |
Number of players, player ID by index |
DoesPlayerExist(id) |
true while the player is on the server |
GetPlayerName(id) |
The player’s GAMPEON display name |
GetPlayerIdentifiers(id), GetNumPlayerIdentifiers(id), GetPlayerIdentifier(id, i) |
All identifiers or one by index |
GetPlayerIdentifierByType(id, 'license') |
The first identifier with that prefix |
GetPlayerEndpoint(id) |
IP address |
GetPlayerPing(id) |
Round trip time in milliseconds |
GetPlayerLastMsg(id) |
Milliseconds since the player last sent a network event |
DropPlayer(id, reason) |
Disconnects the player with that message |
The full list with types is in the Lua API reference.
Join check
Section titled “Join check”Players join through the GAMPEON launcher. The launcher gives the game a one-time join ticket, and the server checks it with GAMPEON before scripts see the player. The name and the gampeon: identifier come from that check, so players cannot pretend to be someone else.
For the check, the server needs its ID and key from registering the server. For local tests without the launcher, turn the check off:
set sv_requireJoinToken falsePlayers then get identifiers like gampeon:dev-1 and the name their game sends.
Network events from players
Section titled “Network events from players”Events from players reach only handlers registered with RegisterNetEvent. Before scripts see them, the server checks the size (60 KB in the game), the rate (200 per second, short bursts up to 400) and the format. A player who keeps sending invalid or too many events is disconnected.