Skip to the content
Docs

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

FileRuns onWhat it is
config.luaserver and gameAll settings. See the Configuration pages, starting with General.
config_server.luaserverConfigServer.Webhooks and ConfigServer.FairShield. Keep it private.
locales/*.luaserver and gameEvery text. See Localization.
bridge/framework_server.luaserverReads players and characters from your framework.
bridge/framework_client.luagameTells the panel when the local character loads and logs out.
bridge/notify.luagameShows a notice.
bridge/ambulance.luaserver and gameTells your ambulance script that staff revived a player.
bridge/appearance.luagameAsks your clothing script to load a player's saved character (Reset look).
bridge/inventory.luaserverGives items.
bridge/jail.luaserverHands a player to your prison script.
bridge/world.luaserverWeather, 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-adminpanel after 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

FunctionGetsMust return
Bridge.GetPlayer(src)Server IDThe framework's player object, or nil
Bridge.GetPlayerByCitizenId(citizenid)Citizen IDThe player object, or nil
Bridge.GetLicense(src)Server ID'license:…', or nil
Bridge.OnPlayerLoaded(cb)A functionNothing. Call cb(src) each time a character has entered the world
Bridge.OnPlayerUnload(cb)A functionNothing. Call cb(src) when a player goes back to the character screen without leaving
Bridge.GetLiveProfile(src)Server ID of an online playerOne table (below), or nil
Bridge.SearchOffline(query, limit)Search text, most rows wantedA list of rows (below)
Bridge.GetOfflineProfile(identifier, citizenid)'license:…' and, when known, the citizen IDOne table (below), or nil
Bridge.SetJob(src, job, grade)Server ID, job name, grade numbertrue when the framework accepted it

What the tables hold (the same on every framework):

lua
-- 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 }
DetailWhy it matters
The player object needs PlayerData.citizenidUsed 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 falseThey become the statuses Dead or downed and Handcuffed.
On ESX cuffed is always falseESX 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 playerA 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

FunctionGetsMust do
Bridge.OnPlayerLoaded(cb)A functionCall cb() when the local character has entered the world
Bridge.OnPlayerUnload(cb)A functionCall cb() when the character logs out to the character screen
Bridge.GetPlayerData()NothingReturn a table with at least job.name
Bridge.OnJobUpdate(cb)A functionCall 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

FunctionGetsMust 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:

FunctionRuns onGetsMust do
Ambulance.ReviveServer(target)serverThe server id of the revived playerTell an ambulance script that is told on the server. Nothing to return
Ambulance.Revive()the revived player's gameNothingTell an ambulance script that is told in the game. Nothing to return

Out of the box:

Ambulance scriptTold byHow
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:

lua
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
end

Told on the server:

lua
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
end

my-ambulance, its event and its export are placeholders.

DetailWhy it matters
The file runs on the server and on the player's gamePut a server export in Ambulance.ReviveServer, a client event or client export in Ambulance.Revive.
A mistake cannot stop a reviveThe 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.

FunctionGetsMust return
Appearance.Reload()Nothingtrue 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:

lua
    if running('my-clothing') then
        exports['my-clothing']:reloadSkin()   -- the call that loads the player's saved character
        return true
    end

    return false

my-clothing and its export are placeholders. running(name) is a helper in the file: it is true when that resource is started.

DetailWhy it matters
The file runs on the game of the player whose look is resetUse a client event or a client export of your clothing script.
The panel calls it once the character's model has stopped changingYou need no wait of your own after a Set Model.
The look may arrive a moment laterReturn true right after you asked your script. The panel waits for the new look by itself.
false, or a mistake in the fileThe player reads: "No clothing script was found to load your character."

bridge/inventory.lua

FunctionGetsMust return
Inventory.System()NothingThe name of the inventory in use, for example 'ox_inventory'
Inventory.AddItem(src, item, amount)Server ID, item name, amounttrue when the item was given
Inventory.RemoveItem(src, item, amount)Server ID, item name, amounttrue when the item was taken
Inventory.GetItemCount(src, item)Server ID, item nameA number
Inventory.HasItem(src, item, amount)Server ID, item name, amounttrue 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

FunctionGetsMust return
JailBridge.System()NothingThe name of the running prison script, or nil
JailBridge.Available()Nothingtrue when a prison script was found
JailBridge.Jail(src, minutes, reason)An online player, whole minutes, the reason texttrue when the prison script took the player
JailBridge.Unjail(src)An online playertrue when the player is out
JailBridge.Status(src)An online playerMinutes still to serve, or 0 when not in prison

How to add a prison script: Prison Scripts.

bridge/world.lua

FunctionGetsMust return
World.SetWeather(weather)A GTA weather name in capital letters, for example RAINtrue when the weather was set
World.SetTime(hour, minute)Hour 0 to 23, minute 0 to 59true when the time was set
World.SetBlackout(on)true or falsetrue
World.SendTo(src)A player who has just entered the worldNothing

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.