Server

The ak47_lib automatically detects the running framework. You can access these functions by importing the lib export in your script.

local Lib47 = exports['ak47_lib']:GetLibObject()

Lib47.Framework

A built-in variable that stores the active framework detected by the library. This is highly useful for writing dynamic, multi-framework scripts that need to execute different logic depending on the server's core environment.

Expected Values: 'esx', 'qb', or 'qbx'.

--- @type string The name of the currently active framework
local currentFramework = Lib47.Framework

-- Example usage for framework-specific logic
if Lib47.Framework == 'qb' then
    print("Detected Framework: QBCore")
    -- Execute QBCore specific code here
    
elseif Lib47.Framework == 'esx' then
    print("Detected Framework: ESX")
    -- Execute ESX specific code here
    
elseif Lib47.Framework == 'qbx' then
    print("Detected Framework: Qbox")
    -- Execute Qbox specific code here
    
else
    print("No supported framework detected (Standalone)")
end

Lib47.GetCoreConfig

Retrieves the main configuration table of the active framework (e.g., QBCore.Config or ESX.GetConfig()). This is highly useful for fetching default framework settings without needing to directly reference the core objects, keeping your script standalone-friendly.

Note: When using ESX, you can optionally pass a specific string key to return a single value instead of the entire table. In QBCore/Qbox, the key parameter is ignored and the full configuration table is always returned.

Core Player & Identity

These functions handle identifying players and retrieving their basic information across all frameworks.

Lib47.GetPlayer

Retrieves the raw framework-specific player object (e.g., xPlayer for ESX, Player for QBCore).

Lib47.GetIdentifier

Returns the unique identifier for the player (CitizenID for QBCore/QBX, Identifier for ESX).

Lib47.GetName

Returns the player's full character name.

Lib47.GetPhoneNumber

Returns the player's phone number.

Lib47.GetLicense

Returns the Rockstar license of the player.

Lib47.GetSourceFromIdentifier

Finds a player's server ID based on their identifier.

Lib47.GetCoreConfig

Retrieves the active framework's core configuration table on the server.

Lib47.GetSource

Gets the server ID from a framework player object.

Lib47.GetPlayerFromIdentifier

Retrieves the framework player object using their identifier.

Lib47.GetIdentifierByType

Fetches a specific type of identifier (e.g., 'steam', 'license', 'discord') from a player.

Lib47.GetNameFromIdentifier

Fetches a player's full character name directly from the database using their identifier.

Lib47.GetMetaData / Lib47.SetMetaData

Lib47.HasGroupPermission

Checks if a player belongs to a specific permission group.


Jobs, Gangs & Permissions

Lib47.GetJob

Returns a standardized job table.

Lib47.SetJob

Sets the player's job and grade.

Lib47.GetGang

Returns a standardized gang table.

Lib47.SetGang

Sets the player's gang and grade.

Lib47.HasPermission

Checks if a player meets any permission criteria (Ace, License, Identifier, or Group) defined in a configuration table. Optionally prints a success notification to the server console.

Lib47.IsAdmin

Checks if the player has admin privileges (checks for 'command' ace permission).


Economy

Lib47.GetMoney

Retrieves the balance of a specific account.

Lib47.AddMoney

Adds money to a specific account.

Lib47.RemoveMoney

Removes money from a specific account.

Lib47.GetSocietyMoney

Gets the money associated with a job/society. Supports esx_addonaccount, qb-management, qb-banking, okokBanking, and Renewed-Banking.

Lib47.AddSocietyMoney / Lib47.RemoveSocietyMoney

Modifies society funds.


Basic Vehicle Management

Lib47.IsVehicleOwner

Checks if a player owns a vehicle with a specific plate.

Lib47.GetVehicleOwner

Returns the identifier of the owner of a specific plate.

Lib47.GeneratePlate

Generates a unique plate based on a pattern.

Lib47.GiveVehicle

Inserts a vehicle into the database (owned_vehicles / player_vehicles).

Offline Data Management

Lib47.GetAllOfflinePlayers

Fetches all players from the database with their basic character info, money, and job data.

Lib47.GetJobs

Retrieves the shared list of all jobs and their grades from the framework.

Lib47.GetOfflineMoney

Gets the balance of a specific account for an offline player from the database.

Lib47.AddOfflineMoney / Lib47.RemoveOfflineMoney

Modifies the money balance of an offline player directly in the database.

Lib47.GetOfflineMetaData / Lib47.SetOfflineMetaData

Gets or sets metadata for an offline player directly in the database.

Last updated