RX Scripts Logo
Player

Events

Client-side player events that can be listened to for player state changes.

The Player adapter triggers unified events that work across both ESX and QBCore, allowing you to listen for player state changes.

Events

fm:player:onJobUpdate

Triggered when the player's job is updated.

RegisterNetEvent('fm:player:onJobUpdate', function(job)
    local src = source
end)
job
Job

The new job data

Job Structure:

{
    name = "police",           -- Job name
    label = "Police",          -- Display label
    grade = 2,                 -- Job grade/rank number
    gradeLabel = "Sergeant"    -- Grade display label
}

Example:

RegisterNetEvent('fm:player:onJobUpdate', function(job)
    local src = source
    if job then
        print(string.format("Job changed to: %s (%s)", job.label, job.gradeLabel))

        if job.name == "police" then
            -- Enable police-specific features
            print("You are now a police officer!")
        end
    end
end)

fm:player:onGangUpdate

Triggered when the player's gang is updated (QB only).

RegisterNetEvent('fm:player:onGangUpdate', function(gang)
    local src = source
end)
gang
Gang

The new gang data

Gang Structure:

{
    name = "ballas",          -- Gang name
    label = "Ballas",         -- Display label
    grade = 1,                -- Gang grade/rank number
    gradeLabel = "Member"     -- Grade display label
}
Note: This event is only triggered in QBCore. For ESX, use fm:player:onJobUpdate as gangs are typically implemented as jobs.

Example:

RegisterNetEvent('fm:player:onGangUpdate', function(gang)
    local src = source
    if gang then
        print(string.format("Gang changed to: %s (%s)", gang.label, gang.gradeLabel))

        if gang.name == "ballas" then
            -- Enable gang-specific features
            print("You joined the Ballas!")
        end
    end
end)

fm:player:onPlayerLoaded

Triggered when the player character is loaded.

RegisterNetEvent('fm:player:onPlayerLoaded', function()
    local src = source
end)

Example:

RegisterNetEvent('fm:player:onPlayerLoaded', function()
    local src = source
    print("Character loaded successfully!")

    -- Initialize your resource for this player
    local job = FM.player.getJob()
    if job then
        print("Current job:", job.label)
    end

    -- Start your client-side logic
end)