π€Shared Exports
These exports work on client-side and server-side!
GetGangID
Returns the gang ID of a player using their citizenid from the GlobalState["GangMembers"] structure. This is essential for fetching gang-specific data like name, permissions, ranks, etc.
exports['cb-gangsystem']:GetGangID()exports['cb-gangsystem']:GetGangID(playerID)Parameters
target(optional): Server ID of the player.If
nil, defaults to the calling player (usually client-side).If provided, checks the gang membership of that server ID.
Returns
number: The gang ID the player belongs to.nil: If player data or gang membership is not found.
Example Usage
-- Get your own gang ID (client-side)
local gangID = exports['cb-gangsystem']:GetGangID()
print("My Gang ID is:", gangID)-- Get someone else's gang ID (server-side)
local gangID = exports['cb-gangsystem']:GetGangID(playerID)
print("Player Gang ID is:", gangID)GetGangTag
Returns the tag/abbreviation of a gang based on its gangID.
Parameters
gangID(number): The unique identifier for the gang.
Returns
(string): The gang's short tag or abbreviation (e.g.,
"grm","bld"), as defined in Global State.Returns
nilif the gang does not exist.
Example
GetGangName
Returns the name of a gang based on its gangID.
Parameters
gangID(number): The unique identifier for the gang.
Returns
(string): The gang's official name (e.g.,
"Grim Reapers","Bloods"), as defined in Global State.Returns
nilif the gang does not exist.
Example
GetGangType
Returns the type of a gang based on its gangID.
Parameters
gangID(number): The unique identifier for the gang.
Returns
(string): The type of the gang (e.g.,
"street","mafia","cartel"), as defined in Global StateReturns
nilif the gang does not exist.
Example
GetTurfName
Retrieves the display name (label) of a gang turf based on its unique zone identifier.
Parameters
zoneID(string): The unique identifier (zoneID) of the turf zone to look up.
Returns
(string)
label: The name/label associated with the specified turf zone.nil: Returned if no turf matches the providedzoneID.
Example
GetTurfType
Determines the type of a turf (gang zone) based on its identifier. Returns whether it is a "Community Turf" or a "Gang Turf".
Parameters
zoneID(string): The unique identifier (zoneID) of the turf zone to check.
Returns
(string)
"Community Turf": If the turf is marked as a community turf.(string)
"Gang Turf": If the turf is not a community turf.nil: Returned if no turf matches the providedzoneID.
Example
GetPrevalenceLevel
Converts a numeric prevalence value into a star-based level (1 to 5) based on configured thresholds.
Parameters
prevalence(number): The numeric value representing turf activity or dominance.
Returns
(number): An integer from
1to5representing the prevalence level, based on defined star thresholds inConfig.Prevalence.Stars.
Example
IsCommunityTurf
Checks whether a specific turf (gang zone) is designated as a community turf.
Parameters
zoneID(string): The unique identifier (zoneID) of the turf zone to check.
Returns
(boolean):
trueif the turf is a community turf,falseif it's not.nil: Returned if no turf matches the providedzoneID.
Example
GetGangZoneByCoords
Determines which gang zone a specific set of coordinates falls into. Useful for checking static or dynamic positions on the map.
Parameters
coords(table): A table containingxandycoordinates (e.g.,{ x = 315.7, y = -940.2 }).
Returns
(string)
zoneID: The identifier (zoneID) of the gang zone that includes the specified coordinates.nil: Returned if the coordinates do not fall within any gang zone.
Example
IsGangTimeout
Checks if a gang currently has an active timeout/penalty applied.
Parameters
gangID(string or number): The unique identifier of the gang.
Returns
(boolean):
trueif the gang has an active penalty (penalty ~= 0),falseotherwise.
Example
HasLoyaltyInZone
Checks if a specific gang currently controls (has loyalty in) a given turf zone.
Parameters
gangID(string or number): The unique identifier of the gang.zoneID(string): The identifier (zoneID) of the turf zone.
Returns
(boolean):
trueif the gang is the current controller of the specified zone,falseotherwise.
Example
GetGangAtZoneReturnID
Retrieves the gang ID of the current top controller (i.e., gang with the highest loyalty) in a specific turf zone.
Parameters
zoneID(string): The identifier (zoneID) of the turf zone.
Returns
(string or number)
gangID: The ID of the gang with the highest loyalty in the specified zone.nil: Returned if no gang controls the zone or if the zone is not found.
Example
GetGangLastActive
Retrieves the timestamp of the last activity recorded for a specific gang.
Parameters
gangID(string or number): The unique identifier of the gang.
Returns
(number): A timestamp representing when the gang was last active.
Example
GetZoneController
Retrieves the gang identifier of the controller with the highest loyalty in a specified turf zone.
Parameters
zoneID(string): The identifier (zoneID) of the turf zone.
Returns
(number)
controller: The gang ID of the controller with the highest loyalty in the zone.nil: If the zone is not found or no controller exists.
Example
GetTotalGangCount
Returns the total number of gangs currently registered in the system.
Returns
(number): The total number of gangs registered in the Gang System
Example
GetPlayerGangType
Retrieves the type of the gang that the player is currently a member of. Returns nil if the player is not in a gang.
Returns
(string): The gang type of the player's current gang.
Default Gang Types:
syndicate,motorcycle,mob,cartel,southside
nil: If the player is not part of any gang.
Example
GetGangRank
Returns the gang rank index of a player based on their citizenid, retrieved from the GlobalState["GangMembers"] table. This rank is used to determine the player's permission level within their gang.
Parameters
target(optional): The server ID of the player.If
targetisnil, it defaults to the calling player (client-side).If
targetis provided, the function will fetch the rank of that player.
Returns
number: The rank index of the player in their gang (e.g.,0,1,2, etc.)nil: If the player or their data is not found.
Example
GetGangZonePlayerIsIn
Determines which gang zone the player is currently located in, based on their coordinates.
Returns
(string)
zone: The identifier (tag) of the gang zone the player is inside.nil: If the player is not inside any defined gang zone.
Example
AllowedByPrevalence
Checks whether a gang is allowed to perform a specific action based on their prevalence level, using a lockout system defined in Config.Prevalence.PrevalenceLockout.
Parameters
gangID(number): The ID of the gang (typically fromGlobalState["GangData"])action(string): The action being validated (e.g.,"drugs","spray","gift", etc.)
Returns
true: If the gang'sprevalencemeets or exceeds the minimum required for that action.false: If the prevalence is too low or the action is not listed inPrevalenceLockout.
How it Works
Looks up the gangβs current prevalence from:
Looks up the required prevalence level from:
Compares them and returns
trueorfalse.
Example
IsActiveRivalry
Checks if there is an active gang rivalry taking place in the specified zone.
Parameters
gangZone(string): The turf or zone identifier to check (e.g.,"MORN","ROCKF").
Returns
trueβ if there is an active rivalry happening in the specified zone.falseβ if there is no active rivalry in that zone.
Example
GetGangPrevalence
Checks and returns the gang's prevalence.
Parameters
gangID(number): The Gang ID of the gang you wish to check
Returns
nilβ if there is no prevalence for the gang ID that was passednumberβ The prevalence for the gang ID that was passed
Example
Last updated
