Server/no_escrow.lua

-- # Framework ------------------------------------------------------------------------------------

if Config.Settings['Framework'] == 'esx' then
    ESX = exports['es_extended']:getSharedObject()
elseif Config.Settings['Framework'] == 'old-esx' then
    ESX = nil
    TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
elseif Config.Settings['Framework'] == 'qb' then
    QBCore = exports['qb-core']:GetCoreObject()
elseif Config.Settings['Framework'] == 'old-qb' then
    QBCore = nil
    Citizen.CreateThread(function()
        while QBCore == nil do
            TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end)
            Citizen.Wait(200)
        end
    end)
elseif Config.Settings['Framework'] == 'qbx' then
    if GetResourceState('qbx_core') == 'started' then
        QBCore = exports['qbx-core']:GetCoreObject()
    elseif GetResourceState('qbx-core') == 'started' then
        QBCore = exports['qbx_core']:GetCoreObject()
    end
elseif Config.Settings['Framework'] == 'custom' then
    -- | # If you are using a custom framework, fill in this section accordingly.
end

-- # Get Player Info ------------------------------------------------------------------------------------

Get_Player_Info = function(source)
    local src = tonumber(source)
    local ply_photo = Get_Player_Photo(src)

    if Config.Settings['Framework'] == "esx" or Config.Settings['Framework'] == "old-esx" then
        local Player = ESX.GetPlayerFromId(src)
        local Result = nil
        if Config.Settings['SQL'] == "mysql-async" then
            Result = MySQL.Sync.fetchAll('SELECT firstname, lastname, dateofbirth FROM users WHERE identifier = @identifier', {
                ['@identifier'] = Player.identifier
            })
        elseif Config.Settings['SQL'] == "ghmattimysql" then
            Result = exports.ghmattimysql:executeSync('SELECT firstname, lastname, dateofbirth FROM users WHERE identifier = @identifier', {
                ['@identifier'] = Player.identifier
            })
        elseif Config.Settings['SQL'] == "oxmysql" then
            Result = exports.oxmysql:executeSync('SELECT firstname, lastname, dateofbirth FROM users WHERE identifier = @identifier', {
                ['@identifier'] = Player.identifier
            })
        end
        return {
            Id = src,
            Name = Result[1].firstname .. " " .. Result[1].lastname,
            Cash = Player.getAccount('money').money,
            Photo = ply_photo,
        }
    elseif Config.Settings['Framework'] == "qb" or Config.Settings['Framework'] == "old-qb" or Config.Settings['Framework'] == "qbx" then
        local Player = QBCore.Functions.GetPlayer(src)
        return {
            Id = src,
            Name = Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname,
            Cash = Player.PlayerData.money.cash,
            Photo = ply_photo,
        }
    elseif Config.Settings['Framework'] == "custom" then
        return {
            Id = src,
            Name = Custom_Get_Player_Full_Name(src),
            Cash = Custom_Get_Player_Cash(src),
            Photo = ply_photo,
        }
    end
end

-- # Money Actions ------------------------------------------------------------------------------------

Money_Actions = function(Player_Id, Action, Amount)
    local src = Player_Id
    local Player = nil

    if Config.Settings['Framework'] == 'esx' or Config.Settings['Framework'] == 'old-esx' then
        Player = ESX.GetPlayerFromId(src)
    elseif Config.Settings['Framework'] == 'qb' or Config.Settings['Framework'] == 'old-qb' or Config.Settings['Framework'] == 'qbx' then
        Player = QBCore.Functions.GetPlayer(src)
    elseif Config.Settings['Framework'] == 'custom' then
        -- | # If you are using a custom framework, fill in this section accordingly.
    end

    if Action == "Add" then
        if Config.Settings['Framework'] == 'esx' or Config.Settings['Framework'] == 'old-esx' then
            Player.addMoney(Amount)
        elseif Config.Settings['Framework'] == 'qb' or Config.Settings['Framework'] == 'old-qb' or Config.Settings['Framework'] == 'qbx' then
            Player.Functions.AddMoney('cash', Amount)
        elseif Config.Settings['Framework'] == 'custom' then
            Custom_Add_Money(src, Amount)
        end
    elseif Action == "Remove" then
        if Config.Settings['Framework'] == 'esx' or Config.Settings['Framework'] == 'old-esx' then
            Player.removeMoney(Amount)
        elseif Config.Settings['Framework'] == 'qb' or Config.Settings['Framework'] == 'old-qb' or Config.Settings['Framework'] == 'qbx' then
            Player.Functions.RemoveMoney('cash', Amount)
        elseif Config.Settings['Framework'] == 'custom' then
            Custom_Remove_Money(src, Amount)
        end
    end
end

-- # Functions for Using Custom Framework  ------------------------------------------------------------------------------------

Custom_Get_Player_Full_Name = function(source)
    -- | # If you are using a custom framework, fill in this section accordingly.
    return -- | # Value
end

Custom_Get_Player_Cash = function(source)
    -- | # If you are using a custom framework, fill in this section accordingly.
    return -- | # Value
end

Custom_Add_Money = function(source, amount)
    -- | # If you are using a custom framework, fill in this section accordingly.
end

Custom_Remove_Money = function(source, amount)
    -- | # If you are using a custom framework, fill in this section accordingly.
end

Last updated