π Framework Integration
π Shared Framework
The core bridge logic is entirely open-source allowing you to adapt vehicle fetching, notifications, and client-server sync dynamically to your server framework.
RIO = {}
function RIO.GetFramework()
if Config.Framework ~= "auto" then
return Config.Framework
end
if GetResourceState('qb-core') == 'started' then
return 'qb'
elseif GetResourceState('qbox') == 'started' then
return 'qbox'
elseif GetResourceState('es_extended') == 'started' then
return 'esx'
end
return nil
end
function RIO.GetCore()
local framework = RIO.GetFramework()
if framework == 'qb' then
return exports['qb-core']:GetCoreObject()
elseif framework == 'qbox' then
return exports['qbx_core'] -- Assuming qbx_core provides needed functions
elseif framework == 'esx' then
return exports['es_extended']:getSharedObject()
end
return nil
end
function RIO.GetPlayerData()
local framework = RIO.GetFramework()
local core = RIO.GetCore()
if not core then return nil end
if framework == 'qb' or framework == 'qbox' then
return core.Functions.GetPlayerData()
elseif framework == 'esx' then
return core.GetPlayerData()
end
return nil
end
function RIO.GetPlayerName()
local data = RIO.GetPlayerData()
if not data then return GetPlayerName(PlayerId()) end
local framework = RIO.GetFramework()
if framework == 'qb' or framework == 'qbox' then
if data.charinfo then
return data.charinfo.firstname .. " " .. data.charinfo.lastname
end
elseif framework == 'esx' then
-- ESX usually stores name in variables like firstName/lastName or just name
return data.firstName and (data.firstName .. " " .. data.lastName) or GetPlayerName(PlayerId())
end
return GetPlayerName(PlayerId())
end
function RIO.GetIdentifier(source)
local framework = RIO.GetFramework()
local core = RIO.GetCore()
if framework == 'qb' or framework == 'qbox' then
local player = core.Functions.GetPlayer(source)
return player and player.PlayerData.citizenid or nil
elseif framework == 'esx' then
local player = core.GetPlayerFromId(source)
return player and player.getIdentifier() or nil
else
-- Standalone: Use License or Steam
return GetPlayerIdentifier(source, 0)
end
end
-- Server side specific (this file is shared, so check Side)
if IsDuplicityVersion() then
function RIO.RegisterCallback(name, cb)
local framework = RIO.GetFramework()
local core = RIO.GetCore()
if (framework == 'qb' or framework == 'qbox') and core then
core.Functions.CreateCallback(name, cb)
elseif framework == 'esx' and core then
core.RegisterServerCallback(name, cb)
else
-- Basic Standalone Callback (Simplified)
RegisterNetEvent('rio-carplay:server:triggerCallback:'..name, function(...)
local src = source
cb(src, function(...)
TriggerClientEvent('rio-carplay:client:receiveCallback:'..name, src, ...)
end, ...)
end)
end
end
else
function RIO.TriggerCallback(name, cb, ...)
local framework = RIO.GetFramework()
local core = RIO.GetCore()
if (framework == 'qb' or framework == 'qbox') and core then
core.Functions.TriggerCallback(name, cb, ...)
elseif framework == 'esx' and core then
core.TriggerServerCallback(name, cb, ...)
else
-- Basic Standalone Trigger
local p = promise.new()
RegisterNetEvent('rio-carplay:client:receiveCallback:'..name, function(...)
p:resolve({...})
end)
TriggerServerEvent('rio-carplay:server:triggerCallback:'..name, ...)
local result = Citizen.Await(p)
cb(table.unpack(result))
end
end
end