Server/no_escrow.lua

-- | # Framework ------------------------------------------------------------------------------------

local Framework = {}

if Config.Settings['Framework'] == 'esx' or Config.Settings['Framework'] == 'old-esx' then
    Framework = {
        Get_Player = function(src)
            if Config.Settings['Framework'] == 'esx' then
                return exports['es_extended']:getSharedObject().GetPlayerFromId(src)
            elseif Config.Settings['Framework'] == 'old-esx' then
                local Player = nil
                TriggerEvent('esx:getSharedObject', function(obj) Player = obj.GetPlayerFromId(src) end)
                return Player
            end
        end,
        Get_Player_Info = function(player)
            return {
                name = player.get('firstName') .. ' ' .. player.get('lastName'),
                money = player.getAccount('money').money,
                job = player.getJob().name
            }
        end,
    }
elseif Config.Settings['Framework'] == 'qb' or Config.Settings['Framework'] == 'old-qb' or Config.Settings['Framework'] == 'qbox' then
    Framework = {
        Get_Player = function(src)
            if Config.Settings['Framework'] == 'qb' then
                return exports['qb-core']:GetCoreObject().Functions.GetPlayer(src)
            elseif Config.Settings['Framework'] == 'old-qb' then
                local Player = nil
                Citizen.CreateThread(function()
                    while Player == nil do
                        TriggerEvent('QBCore:GetObject', function(obj) Player = obj.Functions.GetPlayer(src) end)
                        Citizen.Wait(200)
                    end
                end)
                return Player
            elseif Config.Settings['Framework'] == 'qbx' then
                if GetResourceState('qbx_core') == 'started' then
                    return exports['qbx-core']:GetCoreObject().Functions.GetPlayer(src)
                elseif GetResourceState('qbx-core') == 'started' then
                    return exports['qbx_core']:GetCoreObject().Functions.GetPlayer(src)
                end
            end
        end,
        Get_Player_Info = function(player)
            return {
                name = player.PlayerData.charinfo.firstname .. ' ' .. player.PlayerData.charinfo.lastname,
                money = player.PlayerData.money['cash'],
                job = player.PlayerData.job.label
            }
        end,
    }
elseif Config.Settings['Framework'] == 'custom' then
    Framework = {
        Get_Player = function(src)
            return -- | # If you are using a custom framework, fill in this section accordingly.
        end,
        Get_Player_Info = function(player)
            return -- | # If you are using a custom framework, fill in this section accordingly.
        end,
    }
end

-- | # Get Player Details -------------------------------------------------------------------------

Get_Player_Details = function(source)
    local src = source
    local Player = Framework.Get_Player(src)
    local Name = nil

    if not Player then return nil end

    local PlayerInfo = Framework.Get_Player_Info(Player)
    if not PlayerInfo then return nil end

    if Config.Settings['Name_Type'] == 'steam' then
        Name = GetPlayerName(src)
    else
        Name = PlayerInfo.name
    end

    return {
        Name = Name,
        Id = src,
        Money = PlayerInfo.money,
        Job = PlayerInfo.job
    }
end

Last updated