Server Configuration

This guide covers the server-side configuration options available in src/server/sv_open.lua.

Framework Detection

The script automatically detects and configures itself for your framework:

if Config.Framework == "esx" then
    ESX = exports["es_extended"]:getSharedObject()
elseif Config.Framework == "qbcore" then
    QBCore = exports["qb-core"]:GetCoreObject()
end

Player Job Functions

getPlayerJob(id)

Returns the player's current job.

Default implementation:

function getPlayerJob(id)
    if Config.Framework == "esx" then
        local xPlayer = ESX.GetPlayerFromId(id)
        if xPlayer and xPlayer.job then
            return xPlayer.job.name
        end
    elseif Config.Framework == "qbcore" then
        local QBCore = exports["qb-core"]:GetCoreObject()
        local Player = QBCore.Functions.GetPlayer(id)
        if Player and Player.PlayerData and Player.PlayerData.job then
            return Player.PlayerData.job.name
        end
    end
    return "Unknown"
end

getPlayerDuty(id)

Checks if a player is on duty.

Default implementation:

function getPlayerDuty(id)
    if not Config.UseDutySystem then
        return false
    end

    if Config.Framework == "esx" then
        local xPlayer = ESX.GetPlayerFromId(id)
        if xPlayer and xPlayer.job and xPlayer.job.onduty ~= nil then
            return xPlayer.job.onduty
        end
    elseif Config.Framework == "qbcore" then
        local QBCore = exports["qb-core"]:GetCoreObject()
        local Player = QBCore.Functions.GetPlayer(id)
        if Player and Player.PlayerData and Player.PlayerData.job then
            return Player.PlayerData.job.onduty
        end
    end

    return false
end

isPlayerAdmin(id)

Checks if a player has admin permissions.

Default implementation:

function isPlayerAdmin(id)
    if Config.Framework == "esx" then
        local xPlayer = ESX.GetPlayerFromId(id)
        if xPlayer and xPlayer.getGroup and xPlayer.getGroup() == "admin" then
            return true
        end
    elseif Config.Framework == "qbcore" then
        local QBCore = exports["qb-core"]:GetCoreObject()
        local Player = QBCore.Functions.GetPlayer(id)
        if Player and Player.PlayerData and Player.PlayerData.permission == "admin" then
            return true
        end
    end
    return false
end

Customization

You can modify these functions to match your server's specific needs. For example:

  • Add custom job logic

  • Modify duty system behavior

  • Implement custom admin checks

  • Add additional player data

Remember to test thoroughly after making any changes to these functions.

Last updated