Skip to content

Commit

Permalink
feat(framework): enable automatic framework detection
Browse files Browse the repository at this point in the history
  • Loading branch information
solareon committed Sep 6, 2024
1 parent 2bf9535 commit 8ff9647
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
11 changes: 4 additions & 7 deletions client/framework.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
local Framework = Config.framework
QBCore, ESX, FullyLoaded = nil, nil, nil --luacheck: ignore
if Framework == 'qb' then
QBCore = exports['qb-core']:GetCoreObject() --luacheck: ignore
FullyLoaded = Framework == 'qb' and LocalPlayer.state.isLoggedIn
elseif Framework == 'qbx' then
FullyLoaded = Framework == 'qbx' and LocalPlayer.state.isLoggedIn
local Framework = GetResourceState('es_extended') == 'started' and 'esx' or GetResourceState('qbx_core') == 'started' and 'qbx' or GetResourceState('qb-core') == 'started' and 'qb' or 'Unknown'
FullyLoaded = false
if Framework == 'qb' or Framework == 'qbx' then
FullyLoaded = LocalPlayer.state.isLoggedIn
elseif Framework == 'esx' then
ESX = exports['es_extended']:getSharedObject()
FullyLoaded = Framework == 'esx' and ESX.PlayerLoaded or false
Expand Down
3 changes: 2 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
lib.locale()
Config = {
framework = 'qb', -- QB, QBX, and ESX preconfigured edit the framework.lua to add functionality to other frameworks
-- Framework automatically detected
-- QB, QBX, and ESX preconfigured edit the framework.lua to add functionality to other frameworks
renewedMultiJob = false, -- QBCORE ONLY! https://github.com/Renewed-Scripts/qb-phone
progressbar = 'circle', -- circle or rectangle (Anything other than circle will default to rectangle)
currency = 'USD', -- USD, EUR, GBP ect.....
Expand Down
5 changes: 3 additions & 2 deletions server/framework.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local Framework = Config.framework == 'qb' and 'qb' or Config.framework == 'qbx' and 'qbx' or Config.framework == 'esx' and 'esx' or 'Unknown'
local Framework = GetResourceState('es_extended') == 'started' and 'esx' or GetResourceState('qbx_core') == 'started' and 'qbx' or GetResourceState('qb-core') == 'started' and 'qb' or 'Unknown'
local QBCore, ESX, Jobs, Gangs = nil, nil, nil, nil
local deadPlayers = {}

Expand Down Expand Up @@ -29,10 +29,11 @@ CreateThread(function()
ExportHandler("qb-management", "AddGangMoney", AddAccountMoney)
ExportHandler("qb-management", "RemoveMoney", RemoveAccountMoney)
ExportHandler("qb-management", "RemoveGangMoney", RemoveAccountMoney)
elseif Framework == 'esx'then
elseif Framework == 'esx' then
ESX = exports['es_extended']:getSharedObject()
ESX.RefreshJobs()
Jobs = ESX.GetJobs()
Gangs = {} -- ESX doesn't have gangs

-- Backwards Compatability
ExportHandler("esx_society", "GetSociety", GetAccountMoney)
Expand Down

0 comments on commit 8ff9647

Please sign in to comment.