server/no_escrow.lua
-- | # Global Variables ------------------------------------------------------------------------------------
Framework_OBJ = nil
-- | # Load Framework Function ------------------------------------------------------------------------------------
Load_Framework = function()
local framework = Config.Settings['Framework']
if framework == 'esx' then
Framework_OBJ = exports['es_extended']:getSharedObject()
elseif framework == 'old-esx' then
Framework_OBJ = nil
TriggerEvent('esx:getSharedObject', function(obj) Framework_OBJ = obj end)
elseif framework == 'qb' then
Framework_OBJ = exports['qb-core']:GetCoreObject()
elseif framework == 'old-qb' then
Framework_OBJ = nil
Citizen.CreateThread(function()
while Framework_OBJ == nil do
TriggerEvent('QBCore:GetObject', function(obj) Framework_OBJ = obj end)
Citizen.Wait(200)
end
end)
elseif framework == 'qbox' then
if GetResourceState("qbx_core") == "started" then
Framework_OBJ = exports['qbx_core']:GetCoreObject()
elseif GetResourceState("qbx-core") == "started" then
Framework_OBJ = exports['qbx-core']:GetCoreObject()
end
end
end
-- | # Get Player Function ------------------------------------------------------------------------------------
Get_Player = function(source)
if not Framework_OBJ then return nil end
local framework = Config.Settings['Framework']
if framework == 'esx' or framework == 'old-esx' then
return Framework_OBJ.GetPlayerFromId(source)
elseif framework == 'qb' or framework == 'old-qb' then
return Framework_OBJ.Functions.GetPlayer(source)
elseif framework == 'qbox' then
return exports.qbx_core:GetPlayer(source)
end
return nil
end
-- | # Get Player Charname Function ------------------------------------------------------------------------------------
Get_Player_Charname = function(source)
local framework = Config.Settings['Framework']
if framework == 'esx' or framework == 'old-esx' then
local xPlayer = Get_Player(source)
if xPlayer then
local result = Execute_Sql('SELECT firstname, lastname FROM users WHERE identifier = ?', {xPlayer.identifier})
if result and result[1] then
return result[1].firstname .. ' ' .. result[1].lastname
end
end
elseif framework == 'qb' or framework == 'old-qb' then
local Player = Get_Player(source)
if Player then
return Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
end
elseif framework == 'qbox' then
local Player = Get_Player(source)
if Player then
return Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
end
end
return nil
end
-- | # Get Player Name Function ------------------------------------------------------------------------------------
Get_Player_Name = function(source)
local nameType = Config.Player_Display['Name_Type']
if nameType == 'steam' then
return GetPlayerName(source)
elseif nameType == 'custom' then
-- | You can implement your own custom name fetching system here.
-- | For example: Discord username, database nickname, or any other source you prefer.
elseif nameType == 'charname' then
local charname = Get_Player_Charname(source)
if charname then
return charname
end
end
return GetPlayerName(source)
end
-- | # Get Player Avatar Function ------------------------------------------------------------------------------------
Get_Player_Avatar = function(source)
local p = promise.new()
local ppType = Config.Player_Display['PP_Type']
if ppType == 'steam' then
local src_hex = nil
for _, identifier in pairs(GetPlayerIdentifiers(source)) do
if string.sub(identifier, 1, string.len("steam:")) == "steam:" then
src_hex = string.sub(identifier, string.len("steam:") + 1)
break
end
end
if src_hex then
PerformHttpRequest('http://steamcommunity.com/profiles/' .. tonumber(src_hex, 16) .. '/?xml=1', function(error, content, head)
local Photo = Config.Player_Display['Default_Player_Photo']
if content then
for line in content:gmatch("[^\r\n]+") do
if line:find("<avatarFull>") then
Photo = line:gsub("<avatarFull><!%[CDATA%[", ""):gsub("]]></avatarFull>", "")
break
end
end
end
p:resolve(Photo)
end)
else
p:resolve(Config.Player_Display['Default_Player_Photo'])
end
elseif ppType == 'custom' then
-- | You can implement your own custom avatar fetching system here.
-- | For example: Discord avatar, database photo URL, or any other source you prefer.
-- | Make sure to resolve the promise with the photo URL: p:resolve(photoUrl)
else
p:resolve(Config.Player_Display['Default_Player_Photo'])
end
return Citizen.Await(p)
end
Last updated