Bridge Files
On this page11
For the developer on your team: the files you may edit, and what each bridge file has to provide so the panel keeps working. Everything else in the resource is protected by asset escrow.
The open files
| File | Runs on | What it is |
|---|---|---|
config.lua | server and game | All settings. See the Configuration pages, starting with General. |
config_server.lua | server | ConfigServer.Webhooks and ConfigServer.FairShield. Keep it private. |
locales/*.lua | server and game | Every text. See Localization. |
bridge/framework_server.lua | server | Reads players and characters from your framework. |
bridge/framework_client.lua | game | Tells the panel when the local character loads and logs out. |
bridge/notify.lua | game | Shows a notice. |
bridge/ambulance.lua | server and game | Tells your ambulance script that staff revived a player. |
bridge/appearance.lua | game | Asks your clothing script to load a player's saved character (Reset look). |
bridge/inventory.lua | server | Gives items. |
bridge/jail.lua | server | Hands a player to your prison script. |
bridge/world.lua | server | Weather, time and blackout. |
Rules
- Keep every function name and its arguments. The protected code calls them by name.
- Return what the tables below say.
- Places made for your own script are marked
[[ ADD YOUR … HERE ]]. - Restart
5code-adminpanelafter an edit. - Keep a copy of your edits before you update: see Updating.
Exports and events
5code-adminpanel has no exports and no events meant for other scripts in this version. The bridge
files are the only place to connect your own scripts.
bridge/framework_server.lua
| Function | Gets | Must return |
|---|---|---|
Bridge.GetPlayer(src) | Server ID | The framework's player object, or nil |
Bridge.GetPlayerByCitizenId(citizenid) | Citizen ID | The player object, or nil |
Bridge.GetLicense(src) | Server ID | 'license:…', or nil |
Bridge.OnPlayerLoaded(cb) | A function | Nothing. Call cb(src) each time a character has entered the world |
Bridge.OnPlayerUnload(cb) | A function | Nothing. Call cb(src) when a player goes back to the character screen without leaving |
Bridge.GetLiveProfile(src) | Server ID of an online player | One table (below), or nil |
Bridge.SearchOffline(query, limit) | Search text, most rows wanted | A list of rows (below) |
Bridge.GetOfflineProfile(identifier, citizenid) | 'license:…' and, when known, the citizen ID | One table (below), or nil |
Bridge.SetJob(src, job, grade) | Server ID, job name, grade number | true when the framework accepted it |
What the tables hold (the same on every framework):
-- Bridge.GetLiveProfile(src)
{ citizenid, charName,
job = { name, label, grade, gradeLabel, onDuty },
money = { cash = 0, bank = 0 }, -- one entry per account
callsign, dead, cuffed }
-- Bridge.SearchOffline(query, limit): a list of
{ identifier = 'license:…', citizenid, name, account, job, lastSeen } -- lastSeen in unix seconds
-- Bridge.GetOfflineProfile(identifier, citizenid)
{ citizenid, name, account, job = { name, label, grade, gradeLabel }, money = { … }, callsign, lastSeen }| Detail | Why it matters |
|---|---|
The player object needs PlayerData.citizenid | Used as the citizen ID everywhere. |
The player object needs Functions.AddMoney(account, amount, reason) and Functions.RemoveMoney(account, amount, reason) | Give Money and Take Money. Return false to report a failure. |
identifier is always 'license:…' | A row with another kind of identifier is left out of the offline search. |
dead and cuffed are true or false | They become the statuses Dead or downed and Handcuffed. |
On ESX cuffed is always false | ESX has no standard handcuff flag. The line is marked: read the flag of your police script there. |
Bridge.OnPlayerLoaded may fire again for the same player | A character switch. Sits and the jail wait for this before they move a player. |
Bridge.Framework holds 'qb', 'qbx' or 'esx'. Bridge.CreateCallback and
Bridge.RegisterCommand belong to the panel itself: leave them as they are.
Bridge.GetPlayerByCitizenId is in the file, but the panel does not call it in this version.
More on the frameworks: Frameworks & Inventories.
bridge/framework_client.lua
| Function | Gets | Must do |
|---|---|---|
Bridge.OnPlayerLoaded(cb) | A function | Call cb() when the local character has entered the world |
Bridge.OnPlayerUnload(cb) | A function | Call cb() when the character logs out to the character screen |
Bridge.GetPlayerData() | Nothing | Return a table with at least job.name |
Bridge.OnJobUpdate(cb) | A function | Call cb(job) when the job changes |
The panel uses the first two for the player's ticket window: it comes back after a login and closes
on a logout. Bridge.GetPlayerData and Bridge.OnJobUpdate are in the file, but the panel does not
call them in this version. Bridge.TriggerCallback belongs to the panel itself: leave it as it is.
bridge/notify.lua
| Function | Gets | Must do |
|---|---|---|
Notify(msg, type) | The text, and 'primary', 'success' or 'error' | Show the notice. Nothing to return |
How to add a notify script: Notifications, Chat & Weather.
bridge/ambulance.lua
Used by Revive on a player and by Revive me. The panel brings the character back to life and fills the health itself. This file only tells your ambulance script, which keeps its own "this player is dead" state.
Some ambulance scripts are told on the server, others in the player's game. So the file runs on both sides and has one function for each:
| Function | Runs on | Gets | Must do |
|---|---|---|---|
Ambulance.ReviveServer(target) | server | The server id of the revived player | Tell an ambulance script that is told on the server. Nothing to return |
Ambulance.Revive() | the revived player's game | Nothing | Tell an ambulance script that is told in the game. Nothing to return |
Out of the box:
| Ambulance script | Told by | How |
|---|---|---|
qb-ambulancejob (QBCore) | Ambulance.Revive() | The event hospital:client:Revive |
qbx_medical (Qbox) | Ambulance.ReviveServer(target) | Its export Revive |
esx_ambulancejob (ESX up to 1.13) | Ambulance.Revive() | The event esx_ambulancejob:revive |
esx_death (ESX 1.16 and newer) | Ambulance.ReviveServer(target) | Its export Revive |
Nothing to choose: a script that does not run on your server is skipped.
Another ambulance script goes at one of the two marked places [[ ADD YOUR AMBULANCE SCRIPT HERE ]].
Its own docs tell you which side it is told on.
Told in the player's game:
function Ambulance.Revive()
TriggerEvent('hospital:client:Revive') -- qb-ambulancejob
TriggerEvent('esx_ambulancejob:revive') -- esx_ambulancejob (ESX up to 1.13)
if GetResourceState('my-ambulance') == 'started' then -- your ambulance script
TriggerEvent('my-ambulance:revive') -- use the event from its own docs
end
endTold on the server:
function Ambulance.ReviveServer(target)
-- ... the lines for qbx_medical and esx_death stay as they are ...
if GetResourceState('my-ambulance') == 'started' then -- your ambulance script
exports['my-ambulance']:Revive(target) -- use the export from its own docs
end
endmy-ambulance, its event and its export are placeholders.
| Detail | Why it matters |
|---|---|
| The file runs on the server and on the player's game | Put a server export in Ambulance.ReviveServer, a client event or client export in Ambulance.Revive. |
| A mistake cannot stop a revive | The panel brings the character back to life itself. The mistake is printed in the server console (server part) or in the F8 console of the revived player. |
bridge/appearance.lua
Used by Reset look, the way back from Set Model. The panel stores no looks. It asks your clothing script to load the player's own saved character: model, face, hair and clothes.
| Function | Gets | Must return |
|---|---|---|
Appearance.Reload() | Nothing | true when a clothing script was asked. false when there is none |
Out of the box, in this order: illenium-appearance, qb-clothing, then ESX skinchanger with
esx_skin. Another clothing script goes at the marked place [[ ADD YOUR CLOTHING SCRIPT HERE ]],
just before the last return false:
if running('my-clothing') then
exports['my-clothing']:reloadSkin() -- the call that loads the player's saved character
return true
end
return falsemy-clothing and its export are placeholders. running(name) is a helper in the file: it is true
when that resource is started.
| Detail | Why it matters |
|---|---|
| The file runs on the game of the player whose look is reset | Use a client event or a client export of your clothing script. |
| The panel calls it once the character's model has stopped changing | You need no wait of your own after a Set Model. |
| The look may arrive a moment later | Return true right after you asked your script. The panel waits for the new look by itself. |
false, or a mistake in the file | The player reads: "No clothing script was found to load your character." |
bridge/inventory.lua
| Function | Gets | Must return |
|---|---|---|
Inventory.System() | Nothing | The name of the inventory in use, for example 'ox_inventory' |
Inventory.AddItem(src, item, amount) | Server ID, item name, amount | true when the item was given |
Inventory.RemoveItem(src, item, amount) | Server ID, item name, amount | true when the item was taken |
Inventory.GetItemCount(src, item) | Server ID, item name | A number |
Inventory.HasItem(src, item, amount) | Server ID, item name, amount | true or false |
The panel calls Inventory.AddItem for Give Item and Inventory.System for the Inventory
button. The other three are in the file, but the panel does not call them in this version.
How to add an inventory: Frameworks & Inventories.
bridge/jail.lua
| Function | Gets | Must return |
|---|---|---|
JailBridge.System() | Nothing | The name of the running prison script, or nil |
JailBridge.Available() | Nothing | true when a prison script was found |
JailBridge.Jail(src, minutes, reason) | An online player, whole minutes, the reason text | true when the prison script took the player |
JailBridge.Unjail(src) | An online player | true when the player is out |
JailBridge.Status(src) | An online player | Minutes still to serve, or 0 when not in prison |
How to add a prison script: Prison Scripts.
bridge/world.lua
| Function | Gets | Must return |
|---|---|---|
World.SetWeather(weather) | A GTA weather name in capital letters, for example RAIN | true when the weather was set |
World.SetTime(hour, minute) | Hour 0 to 23, minute 0 to 59 | true when the time was set |
World.SetBlackout(on) | true or false | true |
World.SendTo(src) | A player who has just entered the world | Nothing |
Keep the World.own table. The panel stores in it what it set last, and uses it for players who join
later.
How to add a sync script: Notifications, Chat & Weather.