RX Scripts Logo
Framework

Functions

Server-side framework functions that work across ESX and QBCore.

The Framework adapter provides unified access to core framework functionality on the server side.

Functions

notify

Sends a notification to a specific player.

FM.framework.notify(src, message, type)
src
number required

Player source ID

message
string required

Notification message to display

type
'success'|'error'|'info'

Notification type (optional, defaults to 'info')

Example:

RegisterNetEvent('myEvent', function()
    local src = source
    FM.framework.notify(src, "Payment received!", "success")
    FM.framework.notify(src, "Insufficient funds", "error")
    FM.framework.notify(src, "Transaction processing...", "info")
end)

getJobs

Returns all available jobs from the framework.

FM.framework.getJobs()

Returns: table<number, Job> - Array of job objects with grades

Job Structure:

{
    name = "police",           -- Job name
    label = "Police",          -- Display label
    grades = {                 -- Array of grades
        {
            grade = 0,
            name = "Cadet",
            label = "Cadet",
            salary = 1000
        },
        -- ... more grades
    }
}

Example:

local jobs = FM.framework.getJobs()
for _, job in ipairs(jobs) do
    print(string.format("Job: %s (%s)", job.label, job.name))
    for _, grade in ipairs(job.grades) do
        print(string.format("  Grade %d: %s - $%d", grade.grade, grade.label, grade.salary))
    end
end

getGangs

Returns all available gangs from the framework.

FM.framework.getGangs()

Returns: table<number, Gang> - Array of gang objects with grades

Gang Structure:

{
    name = "ballas",          -- Gang name
    label = "Ballas",         -- Display label
    grades = {                -- Array of grades
        {
            grade = 0,
            name = "Member",
            label = "Member",
            salary = 500      -- ESX only
        },
        -- ... more grades
    }
}
Note: In ESX, gangs are typically implemented as jobs. QB has native gang support.

registerUsableItem

Registers an item as usable, triggering a callback when the item is used.

FM.framework.registerUsableItem(itemName, cb)
itemName
string required

The name of the item to register as usable

cb
function required

Callback function(src, item) called when item is used

Example:

FM.framework.registerUsableItem("lockpick", function(src, item)
    local player = FM.player.get(src)
    if not player then return end

    -- Check if player is near a vehicle
    TriggerClientEvent('lockpick:start', src)
end)

FM.framework.registerUsableItem("bandage", function(src, item)
    local player = FM.player.get(src)
    if not player then return end

    -- Heal player
    TriggerClientEvent('esx_basicneeds:healPlayer', src, 25)
    player.removeItem("bandage", 1)
    player.notify("You used a bandage", "success")
end)

getItemLabel

Returns the display label for an item.

FM.framework.getItemLabel(item)
item
string required

The item name to get the label for

Returns: string|nil - The display label for the item, or nil if not found

Example:

local label = FM.framework.getItemLabel("water")
print(label) -- Output: "Water"

local weaponLabel = FM.framework.getItemLabel("weapon_pistol")
print(weaponLabel) -- Output: "Pistol"

getPlayers

Returns all online players with optional filtering.

FM.framework.getPlayers(filter)
filter
PlayerFilter

Optional filter for players. See PlayerFilter below.

PlayerFilter Options:

job
string

Filter players by job name

gang
string

Filter players by gang name

count
boolean

If true, returns only the count of players instead of player objects

Returns: table<string, Player>|number - Table of player objects indexed by source, or count if filter.count is true

Example:

-- Get all players
local allPlayers = FM.framework.getPlayers()
for src, player in pairs(allPlayers) do
    print("Player:", src, player.getFullName())
end

-- Get all police officers
local cops = FM.framework.getPlayers({ job = "police" })
for src, cop in pairs(cops) do
    print("Officer:", cop.getFullName())
end

-- Get count of mechanics
local mechanicCount = FM.framework.getPlayers({ job = "mechanic", count = true })
print("Mechanics online:", mechanicCount)

-- Get all gang members
local gangMembers = FM.framework.getPlayers({ gang = "ballas" })

getJobOnlineSources

Returns an array of player source IDs for a specific job.

FM.framework.getJobOnlineSources(job)
job
string required

The job name to get online sources for

Returns: table<number, number> - Array of player source IDs

Example:

local policeSources = FM.framework.getJobOnlineSources("police")
for _, src in ipairs(policeSources) do
    FM.framework.notify(src, "All units, respond to 10-71!", "info")
end

-- Check if any EMS are online
local emsSources = FM.framework.getJobOnlineSources("ambulance")
if #emsSources > 0 then
    print("EMS available:", #emsSources)
end

getJob

Returns detailed information about a specific job.

FM.framework.getJob(jobName)
jobName
string required

The job name to look up

Returns: Job|nil - Job object or nil if not found

Example:

local policeJob = FM.framework.getJob("police")
if policeJob then
    print("Job label:", policeJob.label)
    print("Number of grades:", #policeJob.grades)

    -- Find a specific grade
    for _, grade in ipairs(policeJob.grades) do
        if grade.grade == 3 then
            print("Lieutenant salary:", grade.salary)
        end
    end
end

getGang

Returns detailed information about a specific gang.

FM.framework.getGang(gangName)
gangName
string required

The gang name to look up

Returns: Gang|nil - Gang object or nil if not found


getJobBossGrade

Returns the highest grade (boss grade) for a specific job.

FM.framework.getJobBossGrade(jobName)
jobName
string required

The job name to get the boss grade for

Returns: Grade|nil - Highest grade object or nil if job not found

Grade Structure:

{
    grade = 3,
    name = "Chief",
    label = "Chief",
    salary = 5000
}

Example:

local bossGrade = FM.framework.getJobBossGrade("police")
if bossGrade then
    print("Boss rank:", bossGrade.label)
    print("Boss salary: $", bossGrade.salary)

    -- Check if player is boss
    local player = FM.player.get(src)
    local job = player.getJob()
    if job.grade == bossGrade.grade then
        print("Player is the boss!")
    end
end

getGangBossGrade

Returns the highest grade (boss grade) for a specific gang.

FM.framework.getGangBossGrade(gangName)
gangName
string required

The gang name to get the boss grade for

Returns: Grade|nil - Highest grade object or nil if gang not found

Exports

All framework server functions are available as exports:

exports['fmLib']:framework_notify(src, message, type)
exports['fmLib']:framework_getJobs()
exports['fmLib']:framework_getGangs()
exports['fmLib']:framework_registerUsableItem(itemName, cb)
exports['fmLib']:framework_getItemLabel(item)
exports['fmLib']:framework_getPlayers(filter)
exports['fmLib']:framework_getJobOnlineSources(job)
exports['fmLib']:framework_getJob(jobName)
exports['fmLib']:framework_getGang(gangName)
exports['fmLib']:framework_getJobBossGrade(jobName)
exports['fmLib']:framework_getGangBossGrade(gangName)