Exports

Server-side exports for Possible Gang Levels.

Important

The resource folder on your server must be named exactly possible-gang-levels. Do not rename it. Gang MDT and other Possible Scripts look for that name.

AddGangXPForPlayer

Add XP to a gang and credit a player's contribution.

Lua
exports['possible-gang-levels']:AddGangXPForPlayer(source, gangName, xp, playerName)

Parameters

NameTypeRequiredDescription
sourcenumber✅Player server id (notified of the XP gain)
gangNamestring✅Gang name (e.g. "ballas")
xpnumber✅XP to add
playerNamestring✅Character name for contribution tracking

Example

Lua
local Player = exports.qbx_core:GetPlayer(source)local gangName = Player.PlayerData.gang.namelocal playerName = Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
if gangName ~= 'none' then    exports['possible-gang-levels']:AddGangXPForPlayer(source, gangName, 5, playerName)end

RemoveGangXPForPlayer

Remove XP from a gang. Optionally reduce that player's contribution too.

Lua
exports['possible-gang-levels']:RemoveGangXPForPlayer(targetPlayer, gangName, xp, playerName)

Parameters

NameTypeRequiredDescription
targetPlayernumber✅Player server id to notify
gangNamestring✅Gang name
xpnumber✅XP to remove
playerNamestring❌If set, also reduces that member's contribution

Example

Lua
local Player = exports.qbx_core:GetPlayer(source)local gangName = Player.PlayerData.gang.namelocal playerName = Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
if gangName ~= 'none' then    exports['possible-gang-levels']:RemoveGangXPForPlayer(source, gangName, 5, playerName)end

GetGangLevel

Async — callback only (does not return a level synchronously).

Lua
exports['possible-gang-levels']:GetGangLevel(gangName, callback)

Parameters

NameTypeRequiredDescription
gangNamestring✅Gang name
callbackfunction✅Called with gangLevel (number) or nil if not found

Example

Lua
local Player = exports.qbx_core:GetPlayer(source)local gangName = Player.PlayerData.gang.name
if gangName ~= 'none' then    exports['possible-gang-levels']:GetGangLevel(gangName, function(gangLevel)        if gangLevel and gangLevel >= 3 then            print(gangName .. ' is level ' .. gangLevel)        end    end)end

GetXPRequiredForLevel

Lua
exports['possible-gang-levels']:GetXPRequiredForLevel(level)

Parameters

NameTypeRequiredDescription
levelnumber✅Level from config.LevelRanges

Returns

TypeDescription
number|nilXP threshold for that level

GetXPForNextLevel

Lua
exports['possible-gang-levels']:GetXPForNextLevel(currentLevel)

Parameters

NameTypeRequiredDescription
currentLevelnumber✅Current gang level

Returns

TypeDescription
number|nilXP needed for the next level, or nil at max level

CalculateGangLevel

Lua
exports['possible-gang-levels']:CalculateGangLevel(xp)

Parameters

NameTypeRequiredDescription
xpnumber✅Total gang XP

Returns

TypeDescription
numberLevel for that XP amount

Shop management (MDT)

Needs ShopManagement.Mode = 'database' and ShopManagement.AllowMdtManagement = true.

After the first seed from config.Shops / config.ShopItems, set ShopManagement.SeedFromConfig = false so in-game / MDT changes are not overwritten on restart.

IsShopManagementEnabled

Lua
exports['possible-gang-levels']:IsShopManagementEnabled() -- boolean

GetAllGangShopLocations / GetGangShopLocation

Lua
local locations = exports['possible-gang-levels']:GetAllGangShopLocations()local location = exports['possible-gang-levels']:GetGangShopLocation('ballas')

Optional callback as last arg. Each location: gang_name, coord_x, coord_y, coord_z, radius, enabled.

UpdateGangShopLocation

Lua
local ok, err = exports['possible-gang-levels']:UpdateGangShopLocation('ballas', {    coord_x = x, coord_y = y, coord_z = z,    radius = 3.0,    enabled = true,}, updatedBy)
NameTypeRequiredDescription
gangNamestring✅Gang name
datatable✅Coords required (coord_x/y/z or coords.x/y/z). Optional radius, enabled
updatedBystring❌Who changed it (logging)
cbfunction❌Optional (success, errorMessage)

GetAllShopItems / AddShopItem / UpdateShopItem / RemoveShopItem

Lua
local items = exports['possible-gang-levels']:GetAllShopItems()
exports['possible-gang-levels']:AddShopItem({    item_spawn_name = 'lockpick',    item_label = 'Lockpick',    price = 100,    required_gang_level = 1,}, updatedBy)
exports['possible-gang-levels']:UpdateShopItem('lockpick', { price = 150 }, updatedBy)exports['possible-gang-levels']:RemoveShopItem('lockpick', updatedBy, nil, false) -- soft disable; hardDelete = true to delete

Item fields accept snake_case or camelCase (itemSpawnName, requiredGangLevel, etc.).

Stash management (MDT)

Needs StashLocations.Mode = 'database' and StashLocations.AllowMdtManagement = true.

After seeding, set StashLocations.SeedFromConfig = false so MDT moves are not overwritten on restart.

IsStashManagementEnabled

Lua
exports['possible-gang-levels']:IsStashManagementEnabled() -- boolean

GetAllGangStashLocations / GetGangStashLocation

Lua
local locations = exports['possible-gang-levels']:GetAllGangStashLocations()local location = exports['possible-gang-levels']:GetGangStashLocation('ballas')

Each location: gang_name, stash_id, label, coord_x, coord_y, coord_z, radius, enabled.

UpdateGangStashLocation

Lua
local ok, err = exports['possible-gang-levels']:UpdateGangStashLocation('ballas', {    coord_x = x, coord_y = y, coord_z = z,    radius = 2.0,    label = 'Ballas Stash',    enabled = true,}, updatedBy)
NameTypeRequiredDescription
gangNamestring✅Gang name
datatable✅Coords required. Optional radius, label, enabled. stash_id cannot change
updatedBystring❌Who changed it
cbfunction❌Optional (success, errorMessage)

State bags

Gang Levels does not set its own state bags. See State Bags.

JDB-NET Logo
Partner Service

Self-hosted unlimited logs with managed Grafana

JDB-NET provides a self-hosted solution with unlimited logs, a fully managed Grafana instance, and unlimited users. Perfect for FiveM servers that need comprehensive logging and monitoring.

Check out JDB-NET