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_Name = function(player)
            local result = Execute_Sql('SELECT firstname, lastname FROM users WHERE identifier = @identifier', {['@identifier'] = player.identifier})
            if result[1] then
                return result[1].firstname .. ' ' .. result[1].lastname
            end
            return 'Unknown'
        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_Name = function(player)
            return player.PlayerData.charinfo.firstname .. ' ' .. player.PlayerData.charinfo.lastname
        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_Name = function(player)
            return -- | # If you are using a custom framework, fill in this section accordingly.
        end
    }
end

-- Get Player Information -------------------------------------------------------------------------

Get_Player_Info = function(source)
    local src = tonumber(source)
    local Name = nil
    if Config.Settings['Name_Type'] == 'steam' then
        Name = GetPlayerName(src)
    else
        local Player = Framework.Get_Player(src)
        if not Player then return nil end
        Name = Framework.Get_Player_Name(Player)
    end
    return {
        Name = Name,
        Photo = Get_Player_Photo(src)
    }
end

Last updated