Page cover

🀝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()

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)

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 nil if 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 nil if 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 State

  • Returns nil if 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 provided zoneID.

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 provided zoneID.

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 1 to 5 representing the prevalence level, based on defined star thresholds in Config.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): true if the turf is a community turf, false if it's not.

  • nil: Returned if no turf matches the provided zoneID.

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 containing x and y coordinates (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): true if the gang has an active penalty (penalty ~= 0), false otherwise.

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): true if the gang is the current controller of the specified zone, false otherwise.

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 target is nil, it defaults to the calling player (client-side).

    • If target is 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 from GlobalState["GangData"])

  • action (string): The action being validated (e.g., "drugs", "spray", "gift", etc.)

Returns

  • true: If the gang's prevalence meets or exceeds the minimum required for that action.

  • false: If the prevalence is too low or the action is not listed in PrevalenceLockout.

How it Works

  1. Looks up the gang’s current prevalence from:

  2. Looks up the required prevalence level from:

  3. Compares them and returns true or false.

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 passed

  • number β†’ The prevalence for the gang ID that was passed

Example


Last updated