Client
Local player. These calls do not take a server id.
GetPlayerData
Parameters
None.
Returns
table|nil — same shape as server GetPlayer, or nil before the character exists.
Example
local me = Bridge.GetPlayerData()
if not me then
return
end
print(me.identifier)
print(me.job.name, me.job.grade, me.job.onDuty)
print(me.gang.name)IsPlayerLoaded
Parameters
None.
Returns
boolean
Example
CreateThread(function()
while not Bridge.IsPlayerLoaded() do
Wait(200)
end
local me = Bridge.GetPlayerData()
print(me.name, me.job.label)
end)GetIdentifier
Parameters
None.
Returns
string|nil — vRP and standalone return nil.
Example
local identifier = Bridge.GetIdentifier()
if identifier then
print(identifier)
endGetPlayerJob
Parameters
None.
Returns
table — { name, grade, label, gradeLabel, onDuty }.
Example
local job = Bridge.GetPlayerJob()
if job.name == 'ambulance' and job.onDuty then
Bridge.ShowText('On duty')
endGetPlayerGang
Parameters
None.
Returns
table — same shape as the job. name is none when there is no gang. vRP has no gang.
Example
local gang = Bridge.GetPlayerGang()
if gang.name ~= 'none' then
print(gang.label, gang.gradeLabel)
endGetPlayerMoney
Parameters
accountstring— optional.cashis the default. ESX maps it to themoneyaccount. vRP returns0.
Returns
number
Example
local cash = Bridge.GetPlayerMoney('cash')
local bank = Bridge.GetPlayerMoney('bank')
if cash < 50 then
Bridge.Notify({ description = 'Not enough cash', kind = 'error' })
endGetPlayerMetadata
Reads the local metadata table. Changing metadata stays on the server.
Parameters
keystring
Returns
any
Example
local hunger = Bridge.GetPlayerMetadata('hunger')
if type(hunger) == 'number' then
print(('hunger %s'):format(hunger))
endGetCharacter
Parameters
None.
Returns
table|nil — { firstName, lastName, phone, gender, dateOfBirth }. Phone is nil on ox and ND. vRP returns nil.
Example
local character = Bridge.GetCharacter()
if character then
print(character.firstName, character.lastName)
endIsBoss
Parameters
None.
Returns
boolean — false on ND and vRP.
Example
if Bridge.IsBoss() then
Bridge.OpenBossMenu()
endTriggerCallback
Asks the server callback registered with RegisterCallback. The result arrives in handler.
Parameters
namestringhandlerfunction— receives the values passed toreply...— extra arguments forwarded to the server handler
Returns
boolean — true when the request was sent.
Example
Bridge.TriggerCallback('garage:price', function(price)
print(price)
end, plate)AwaitCallback
Same request as TriggerCallback, but it yields and returns the server's values.
Parameters
namestringtimeoutnumber— ms, optional. Defaults to5000....— extra arguments forwarded to the server handler
Returns
... — the values the server passed to reply, or nothing on timeout.
Example
local price = Bridge.AwaitCallback('garage:price', 3000, plate)RegisterClientCallback
The handler runs on this client when the server calls TriggerClientCallback or AwaitClientCallback. Call reply once with the values the server should receive.
Parameters
namestringhandlerfunction—handler(reply, ...)
Returns
boolean
Example
Bridge.RegisterClientCallback('garage:nearest', function(reply, radius)
local vehicle = Bridge.GetClosestVehicle(nil, radius)
reply(vehicle ~= 0 and Bridge.GetPlate(vehicle) or nil)
end)GetClosestPlayer
Parameters
coordsvector3— optional. Defaults to the local player.radiusnumber— optional. Defaults to5.0.
Returns
number|nil, number|nil — server id and distance. Both are nil when nobody is inside the radius.
Example
local playerId, distance = Bridge.GetClosestPlayer(nil, 3.0)
if playerId then
print(playerId, distance)
endGetNearbyPlayers
Parameters
coordsvector3— optionalradiusnumber— optional. Defaults to5.0.
Returns
table — list of { id, distance }. id is a server id.
Example
local nearby = Bridge.GetNearbyPlayers(nil, 8.0)
for i = 1, #nearby do
print(nearby[i].id, nearby[i].distance)
endGetClosestPed
Skips the local player and other players.
Parameters
coordsvector3— optionalradiusnumber— optional. Defaults to5.0.
Returns
number, number|nil — ped entity, or 0 when none is in range, and the distance.
Example
local ped = Bridge.GetClosestPed(nil, 4.0)
if ped ~= 0 then
print(ped)
endGetClosestObject
Parameters
coordsvector3— optionalradiusnumber— optional. Defaults to5.0.
Returns
number, number|nil — object entity, or 0 when none is in range, and the distance.
Example
local object = Bridge.GetClosestObject(GetEntityCoords(PlayerPedId()), 2.0)
if object ~= 0 then
print(object)
endOnPlayerReady
Parameters
handlerfunction— called with no server id
Returns
boolean
Example
Bridge.OnPlayerReady(function()
local me = Bridge.GetPlayerData()
print(me and me.job.name or 'unemployed')
end)