How the FiveM resource talks to LonexOne
For developers: the resource's convars, how it signs in, the sync loop, the API endpoints it calls, what it sends, and the server exports you can use from your own scripts.
This article is for developers and server owners who want to know what the LonexOne resource does under the hood: what it sends, where it sends it, how often, and how your own scripts can ask it whether a player is on duty.
You don't need any of this to use the resource. Everything a community changes is set on the Game resource tab of Status & servers in the control panel, and reaches the server on its own.
Convars#
The resource reads three convars from server.cfg. Set them with set, above ensure lonexone.
| Convar | What it does | Default |
|---|---|---|
lonexone_key |
The server key from Status & servers. Required. | None |
lonexone_debug |
"true" prints every request path, body and reply to the console. |
"false" |
lonexone_api |
The API address. Only change it if LonexLabs asks you to. | https://api.lonexone.com/v1/fivem |
Use set, never setr. A replicated convar is sent to every player, and the key gives full access to your community's game API.
How it signs in#
Every request carries the server key as a bearer token (Authorization: Bearer lx_...). The key picks both the community and the game server, so each server needs its own. LonexOne only keeps a hash of the key, which is why it's shown once.
A wrong or revoked key gets a 401 with the message That server key isn't valid. Make a new one in the LonexOne panel under Status & servers.
Some FiveM server builds drop the body of any reply that isn't a success, which would hide the real error. So the resource sends an X-LonexOne-Envelope header, and LonexOne answers failures with a 200 holding the real status and message under _error. The resource unwraps it, so players and the console see the real message.
Each game server can make 240 requests a minute. Requests time out after 10 seconds.
Starting up#
When the resource starts it:
- Calls
GET /ping, which returns the community name, the server name and whether the CAD is installed. This is the Connected to LonexOne line in the console. - Calls
GET /configfor everything set on the Game resource tab: command names, keys, 911 settings, notification style and the Staff Panel settings. The config has a version. - Calls
GET /camerasfor the community's speed and plate cameras.
The sync loop#
Every 2 seconds, the server sends POST /sync. LonexOne chooses the interval and can change it (the resource keeps it between 2 and 60 seconds).
Each sync sends, for every player who has a Discord identifier:
- Their server ID, Discord ID and FiveM name.
- Their position and heading. With OneSync these come from the server; without it, from the player's own report.
- The street and cross street, which always come from the player's game.
- Whether they're in a vehicle.
It also sends any camera passes recorded since the last sync. Players without Discord aren't sent, and if nobody with Discord is on and there are no camera passes, the sync is skipped.
The reply holds:
- The units on duty for those players, with their callsign, department, status and current call. The resource uses this to set waypoints and tell players when they're assigned, moved or cleared.
- A
config_versionandcameras_version. When either changes, the resource fetches the new config or cameras. That's how panel changes reach the server within seconds. - Camera alerts for players on duty.
Each player's game reports its position to the server at the same interval.
How players are matched#
Every player-facing request identifies the player by their Discord ID. LonexOne looks for a LonexOne account with that Discord ID that is a member of the community. If there isn't one, the request fails with Your Discord isn't linked to [community] on LonexOne. The only exception is 911, which can be allowed without Discord.
Endpoints#
All paths are under the API address above.
| Area | Endpoints |
|---|---|
| Start up, sync and postals | GET /ping, GET /config, POST /sync, GET /postals |
| Duty | GET /duty/options, POST /duty/on, POST /duty/off |
| Calls | POST /calls/911, POST /calls/quick, POST /calls/current/location, POST /calls/current/notes, POST /panic |
| Garage and fleet | GET /garage, POST /garage/spawn, POST /garage/spots, GET /fleet/matches, POST /fleet/copy |
| Uniforms | GET /uniforms, POST /uniforms/save |
| Photos and IDs | POST /photos/upload, GET /photos/targets, POST /photos/file, POST /photos/headshot, POST /mugshots, GET /mugshots/civilians, POST /mugshots/assign, POST /mugshots/discard, GET /id-card |
| Tablet | POST /tablet |
| Cameras and the plate reader | GET /cameras, GET /cameras/place-options, POST /cameras, POST /plate-reader, POST /plate-reader/run |
| Loading screen | POST /loading-screen, sent by the separate lonexone_loadscreen resource as each player connects |
| Staff Panel | /players/... and /staff/... endpoints for joins, leaves, ban checks, reports, actions, sits, duty and community service |
POST /duty/off with the reason left_server is sent for every player who leaves. LonexOne only signs them off if Sign off when leaving the game is on.
Photos#
Photos don't pass through your game server. The resource asks LonexOne for a one-time upload address, and the player's game posts the screenshot (from screenshot-basic) straight to it. Each address works once, for 2 minutes. Photos must be JPG, PNG or WebP and under 4 MB.
Staff Panel data#
When the community has the Staff Panel installed, the resource also:
- Sends each player who joins, with or without Discord: their name, game identifiers (such as license, Steam, Discord, Xbox, FiveM and IP) and hardware tokens.
- Checks bans while a player connects. If LonexOne can't be reached, players are let in unless the community has switched that off in its Staff settings.
- Sends the full player list every 30 seconds, and positions every 10 seconds for the staff live map.
- Sends damage, kills, deaths and chat every 10 seconds (chat can be switched off in the Staff settings).
- Checks for kicks, bans and messages from the panel every 5 seconds.
None of this is sent while the Staff Panel isn't installed.
Exports#
Three server-side exports let your own scripts read what the resource knows:
exports.lonexone:IsOnDuty(source) -- true or false
exports.lonexone:GetUnit(source) -- the player's unit table, or nil
exports.lonexone:GetPlayerId(source) -- their player ID in the Staff Panel, or nil
The unit table has unit_id, callsign, kind, department, department_short, rank, status and call, as LonexOne sent them in the last sync. Right after going on duty, until the next sync, status and call are missing. kind is leo, fire or ems.
IsOnDuty and GetUnit reflect the last sync, so a change made on the website shows up within a few seconds. After the resource restarts, they return nothing until the first sync.
Something not working?#
See Fix the FiveM resource not connecting for console messages, and turn on lonexone_debug to see each request and reply.
See also
Can't find what you need?
Open a ticket in our Discord and someone from the team will help. Found a bug, or missing a feature? Tell us on the feedback board.