Framework
You can edit functions if you use any other framework non esx or qbcore
Framework (shared/framework.lua)
-- Select framework
Config.Framework = "QBCore" -- (ESX) or (QBCore)
-- Don't touch from here if any of your framworks is the one mentioned above
if Config.Framework == "QBCore" then
Config.CoreName = "qb-core" -- your core name
CObj = exports[Config.CoreName]:GetCoreObject()
elseif Config.Framework == "ESX" then
Config.CoreName = "es_extended" -- your core name
CObj = exports[Config.CoreName]:getSharedObject()
end
Config.FrameworkFunctions = {
PlayerData = {},
-- Client-side trigger callback
TriggerCallback = function(...)
if Config.Framework == 'QBCore' then
CObj.Functions.TriggerCallback(...)
else
CObj.TriggerServerCallback(...)
end
end,
-- Server-side register callback
CreateCallback = function(...)
if Config.Framework == 'QBCore' then
CObj.Functions.CreateCallback(...)
else
CObj.RegisterServerCallback(...)
end
end,
-- Client Notification Function
Notify = function(msg, src)
if IsDuplicityVersion() then -- Server
if Config.Framework == 'QBCore' then
TriggerClientEvent('QBCore:Notify', src, msg)
else
TriggerClientEvent('esx:showNotification', src, msg)
end
else
if Config.Framework == 'QBCore' then
CObj.Functions.Notify(msg)
else
CObj.ShowNotification(msg)
end
end
end,
-- Server-Side get permissions
HasPermissions = function(src)
if Config.Framework == 'QBCore' then
return CObj.Functions.HasPermission(src, Config.AdminGroup)
else
local _player = CObj.GetPlayerFromId(src)
if _player then
return (_player.getGroup() == Config.AdminGroup)
end
end
return nil
end,
-- Server-Side get job
GetJob = function(src)
if Config.Framework == 'QBCore' then
local _player = CObj.Functions.GetPlayer(src)
if _player then
return {job = _player.PlayerData.job.name, grade = _player.PlayerData.job.grade.level}
end
else
local _player = CObj.GetPlayerFromId(src)
if _player then
local _job = _player.getJob()
return {job = _job.name, grade = _job.grade}
end
end
return nil
end,
GetMoney = function(src)
if Config.Framework == 'QBCore' then
local _player = CObj.Functions.GetPlayer(src)
if _player then
return {money = _player.Functions.GetMoney("cash"), bank = _player.Functions.GetMoney("bank")}
end
else
local _player = CObj.GetPlayerFromId(src)
if _player then
return {money = _player.getAccount("money").money, bank = _player.getAccount("bank").money}
end
end
return nil
end,
RemoveMoney = function(src, acc, money)
if Config.Framework == 'QBCore' then
local _player = CObj.Functions.GetPlayer(src)
if _player then
_player.Functions.RemoveMoney(acc, money)
end
else
local _player = CObj.GetPlayerFromId(src)
if _player then
_player.removeAccountMoney(acc, money)
end
end
return nil
end,
GetIdentifier = function(src)
if IsDuplicityVersion() then -- Server
if Config.Framework == 'QBCore' then
local _player = CObj.Functions.GetPlayer(src)
if _player then
return _player.PlayerData.citizenid
end
else
local _player = CObj.GetPlayerFromId(src)
if _player then
return _player.getIdentifier()
end
end
else -- Client
if Config.Framework == 'QBCore' then
if not Config.FrameworkFunctions.PlayerData.identifier then
local _player = CObj.Functions.GetPlayerData()
if _player and _player.citizenid then
Config.FrameworkFunctions.PlayerData.identifier = _player.citizenid
end
else
return Config.FrameworkFunctions.PlayerData.identifier
end
else
if CObj.GetPlayerData() and CObj.GetPlayerData().identifier then
return CObj.GetPlayerData().identifier
end
end
end
return nil
end,
GetPlayerFromIdentifier = function (identifier)
if Config.Framework == 'QBCore' then
local _player = CObj.Functions.GetPlayerByCitizenId(identifier)
if _player then
return _player.PlayerData.source
end
else
local _player = CObj.GetPlayerFromIdentifier(identifier)
if _player then
return _player.source
end
end
return nil
end,
GetVehicleProperties = function (veh)
if Config.Framework == 'QBCore' then
return CObj.Functions.GetVehicleProperties(veh)
else
return CObj.Game.GetVehicleProperties(veh)
end
return nil
end,
SetVehicleProperties = function (veh, props)
if Config.Framework == 'QBCore' then
CObj.Functions.SetVehicleProperties(veh, props)
else
CObj.Game.SetVehicleProperties(veh, props)
end
end,
GetPlayerName = function(src)
if Config.Framework == 'QBCore' then
local _player = CObj.Functions.GetPlayer(src)
if _player then
return _player.PlayerData.charinfo.firstname .. " " .. _player.PlayerData.charinfo.lastname
end
else
local _player = CObj.GetPlayerFromId(src)
if _player then
return _player.getName()
end
end
return nil
end,
}
Last updated