The Framework Bridge abstracts framework-specific logic into a common, easy-to-use API, allowing seamless interaction with multiple frameworks such as boii_core, qb-core, es_extended, and ox_core.
By consolidating functionality into a single bridge, developers can write framework-independent code, improving maintainability and scalability.
Addtional default support will be added for other frameworks as time progresses. If your framework is not currently covered and you would like it to be, reach out through discord.
Handlers
Table of handlers for different frameworks.
Covered by default: boii_core, ox_core, qb-core, es_extended
Client
local handlers = { boii_core = {init=function() return exports.boii_core:get() end,get_data=function(fw,key) return fw.get_data(key) end,get_identity=function(player)return { first_name = player.identity.first_name, last_name = player.identity.last_name, dob = player.identity.dob, sex = player.identity.sex, nationality = player.identity.nationality }end,get_player_id=function(player) return player.passport end }, ['qb-core'] = {init=function() return exports['qb-core']:GetCoreObject() end,get_data=function(fw) return fw.Functions.GetPlayerData() end,get_identity=function(player)return { first_name = player.charinfo.firstname, last_name = player.charinfo.lastname, dob = player.charinfo.birthdate, sex = player.charinfo.gender, nationality = player.charinfo.nationality }end,get_player_id=function(player) return player.citizenid end }, es_extended = {init=function() return exports['es_extended']:getSharedObject() end,get_data=function(fw) return fw.GetPlayerData() end,get_identity=function(player)return { first_name = player.firstName or'firstName missing', last_name = player.lastName or'lastName missing', dob = player.dateofbirth or'dateofbirth missing', sex = player.sex or'sex missing', nationality ='LS, Los Santos' }end,get_player_id=function(player) return player.identifier end }, ox_core = {init=function()local file = ('imports/%s.lua'):format(IsDuplicityVersion() and'server' or'client')local import =LoadResourceFile('ox_core', file)local chunk =assert(load(import, ('@@ox_core/%s'):format(file)))chunk()return Oxend,get_data=function(fw) return fw.GetPlayerData() end,get_identity=function(player)return { first_name = player.firstName, last_name = player.lastName, dob = player.dob, sex = player.gender, nationality ='LS, Los Santos' }end,get_player_id=function(player) return player.stateId end }--- Add other frameworks here}
Server
Client Functions
get_data
Retrieve the players data from the active framework.
--- Utils objectlocal data = utils.fw.get_data()print('Data:', json.encode(data))--- Direct exportexports.boii_utils:get_data()
get_identity
Retrieves players identity information.
Function
localfunctionget_identity()local player =get_data()ifnot player thenreturnfalseendreturncall_function('get_identity', player)endexports('get_identity', get_identity)utils.fw.get_identity = get_identity
Example
--- Utils objectlocal identity = utils.fw.get_identity()print('Identity:', json.encode(identity))--- Direct exportexports.boii_utils:get_identity()
get_player_id
Retrieve players unique ID: citizenid, stateId, passport, identifier etc.
Function
localfunctionget_player_id()local player =get_data()ifnot player thenreturnfalseendreturncall_function('get_player_id', player)endexports('get_player_id', get_player_id)utils.fw.get_player_id = get_player_id
Example
--- Utils objectlocal unique_id = utils.fw.get_player_id()print('Unique ID:', json.encode(unique_id))--- Direct exportexports.boii_utils:get_player_id()
player_has_job
Checks if player has a job by performing a server callback.
--- Job names to checklocal jobs = { 'police', 'fib' }--- If true will only return true if player is on duty.--- If false will return true regardless of duty statuslocal on_duty =true--- Utils objectutils.fw.player_has_job(job, on_duty, function(has_job)if has_job then--- Do somethingelse--- Do something elseendend)--- Direct exportexports.boii_utils:player_has_job(...)
get_player_job_grade
Get the players grade in a specified job by performing a server callback.
--- Define item namelocal item_name ='weapon_pistol'--- Utils objectutils.fw.get_item(item_name, function(item)if item thenprint('Player has the item:', json.encode(item))elseprint('Item not found in inventory.')endend)--- Direct exportexports.boii_utils:get_item(...)
--- Define item namelocal item_name ='lockpick'--- Define required quantity *(optional will default to 1)*local quantity =3--- Utils objectutils.fw.has_item(item_name, quantity, function(has_item)if has_item thenprint('Player has the required item and quantity.')elseprint('Player does not have the required item or quantity.')endend)--- Direct exportexports.boii_utils:has_item(...)
Guides
Initial Setup
Framework detection is done automatically on load, however if you run a server with a dual core you may run into some issues.
If you are using one of the pre-defined frameworks then you should not need to do anything for the bridge to work.
If your desired framework is not covered by default reach out through discord.
Adding Handlers
To add support for additional frameworks you need to add a handler into the handlers table inside .../bridges/frameworks.lua
Client
local handlers = { ['your framework core resource name'] = {init=function()--[[your frameworks function equivalent]]end,get_data=function(fw) return--[[your frameworks function equivalent]]end,get_identity=function(player)return {--[[your frameworks data equivalent]] }end,get_player_id=function(player) return--[[your frameworks uid]]end--- Any additional framework functions can be added below. }}
Once you have added your handler, update the provided the ['your framework core resource name'] matches your core resource folder you should be good to go.
If for any reason you are unable to set this up yourself put a support post in discord.