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
            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 Details -------------------------------------------------------------------------

Get_Player_Details = function(source)
    local src = tonumber(source)
    if not src then return nil end

    local Name = nil
    local Photo = Player_Photos[src] or Config.Settings['Default_Player_Photo']
    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

    local Identifiers = {steam = "N/A", discord = "N/A", license = "N/A", xbl = "N/A", live = "N/A"}
    for _, v in ipairs(GetPlayerIdentifiers(src)) do
        if v:match("^steam:") then
            Identifiers.steam = v
        elseif v:match("^license:") then
            Identifiers.license = v
        elseif v:match("^live:") then
            Identifiers.live = v
        elseif v:match("^xbl:") then
            Identifiers.xbl = v
        elseif v:match("^discord:") then
            Identifiers.discord = v
        end
    end

    local Settings = {}
    local Data = json.decode(LoadResourceFile(GetCurrentResourceName(), Config.Settings['Database_Location']))
    if Data and Identifiers.license and Data[Identifiers.license] then
        Settings = {
            Streamer_Mode = Data[Identifiers.license].Streamer_Mode,
            Theme_Color = Data[Identifiers.license].Theme_Color,
            Message = Data[Identifiers.license].Message
        }
    end

    return {
        Info = {Name = Name, Id = src, Photo = Photo},
        Identifiers = Identifiers,
        Settings = Settings
    }
end

Last updated