Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.nonefivem.com/llms.txt

Use this file to discover all available pages before exploring further.

If you’re using supported framework you dont have to make any changes in this section.
You can override player actions from no-base/configure/server/player.lua

Examples


Config.Player = {
    ---@param source number
    ---@return string | number
    GetIdentifier = function(source)
        return GetPlayerIdentifierByType(source, "steam") or GetPlayerIdentifierByType(source, "license") or GetPlayerIdentifierByType(source, "license2")
    end,
    ---@param identifier string
    ---@return number | nil
    GetSourceByIdentifier = function(identifier)
        local GetPlayerIdentifierByType = GetPlayerIdentifierByType
        for _, playerId in ipairs(GetPlayers()) do
            if GetPlayerIdentifierByType(playerId, "steam") == identifier or
               GetPlayerIdentifierByType(playerId, "license") == identifier or
               GetPlayerIdentifierByType(playerId, "license2") == identifier then
                return playerId
            end
        end
        return nil
    end,
    ---@param source number
    ---@return string
    GetFullname = function(source)
        return GetPlayerName(source)
    end,
    ---@return number[]
    GetLoadedPlayers = function()
        local players = {}
        for playerId in pairs(exports.qbx_core:GetQBPlayers()) do
            players[#players + 1] = playerId
        end
        return players
    end
    ---@param cb fun(source: number): void
    ---@return void
    OnPlayerLoaded = function(cb)
        AddEventHandler("QBCore:Server:PlayerLoaded", function(player)
            cb(player.PlayerData.source)
        end)
    end,
    ---@param cb fun(source: number): void
    ---@return void
    OnPlayerUnload = function(cb)
        AddEventHandler("QBCore:Server:OnPlayerUnload", function(source)
            cb(source)
        end)
    end,
    ---@param source number
    ---@param amount number
    ---@param reason string | nil
    ---@return boolean
    AddBank = function(source, amount, reason)
        return true
    end,
    ---@param source number
    ---@param amount number
    ---@param reason string | nil
    ---@return boolean
    RemoveBank = function(source, amount, reason)
        return true
    end,
    ---@param source number
    ---@param amount number
    ---@param reason string | nil
    ---@return boolean
    AddMoney = function(source, amount, reason)
        return true
    end,
    ---@param source number
    ---@param amount number
    ---@param reason string | nil
    ---@return boolean
    RemoveMoney = function(source, amount, reason)
        return true
    end
}
Should return unique id for the players current character. (E.g. citizenid on QB identifier on ESX)

Parameters

  • source: number

Returns

  • identifier: string | number
Should return the player id if player is online by provided identifier with GetIdentifier method.

Parameters

  • identifier: string

Returns

  • playerServerId: number (source)
Should return fullname of the player character.

Parameters

  • source: number

Returns

  • fullname: string
Should return array of loaded player server ids.

Returns

  • playerIds: number[]
Should add event handler that will execute the callback whenever the player is loaded.

Parameters

  • cb: func(source: number)
Should add event handler that will execute the callback whenever the player is unloaded.

Parameters

  • cb: func(source: number)
Adds money to player bank account.

Parameters

  • source: number
  • amount: number
  • reason?: string

Returns

  • success: boolean
Removes money from player bank account.

Parameters

  • source: number
  • amount: number
  • reason?: string

Returns

  • success: boolean
Adds money to player inventory.

Parameters

  • source: number
  • amount: number
  • reason?: string

Returns

  • success: boolean
Removes money from player inventory.

Parameters

  • source: number
  • amount: number
  • reason?: string

Returns

  • success: boolean