π€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
.
exports['cb-gangsystem']:GetGangTag(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
local tag = exports['cb-gangsystem']:GetGangTag(1)
if tag then
print("Gang tag is: " .. tag)
end
GetGangType
Returns the type of a gang based on its gangID
.
local gangType = exports['cb-gangsystem']:GetGangType(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
nil
if the gang does not exist.
Example
local type = exports['cb-gangsystem']:GetGangType(1)
if type then
print("Gang type is: " .. type)
end
GetTurfName
Retrieves the display name (label) of a gang turf based on its unique zone identifier.
exports['cb-gangsystem']:GetTurfName(zoneID)
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
local turfLabel = exports['cb-gangsystem']:GetTurfName("ROCKF")
if turfLabel then
print("Turf Name: " .. turfLabel)
else
print("Turf not found.")
end
GetTurfType
Determines the type of a turf (gang zone) based on its identifier. Returns whether it is a "Community Turf" or a "Gang Turf".
exports['cb-gangsystem']:GetTurfType(zoneID)
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
local turfType = exports['cb-gangsystem']:GetTurfType("ROCKF")
if turfType then
print("Turf Type: " .. turfType)
else
print("Turf not found.")
end
GetPrevalenceLevel
Converts a numeric prevalence value into a star-based level (1 to 5) based on configured thresholds.
exports['cb-gangsystem']:GetPrevalenceLevel(prevalence)
Parameters
prevalence
(number): The numeric value representing turf activity or dominance.
Returns
(number): An integer from
1
to5
representing the prevalence level, based on defined star thresholds inConfig.Prevalence.Stars
.
Example
local level = exports['cb-gangsystem']:GetPrevalenceLevel(73)
print("Prevalence Level: " .. level) -- Output might be: "Prevalence Level: 4"
IsCommunityTurf
Checks whether a specific turf (gang zone) is designated as a community turf.
exports['cb-gangsystem']:IsCommunityTurf(zoneID)
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 providedzoneID
.
Example
local isCommunity = exports['cb-gangsystem']:IsCommunityTurf("ROCKF")
if isCommunity == true then
print("This is a Community Turf.")
elseif isCommunity == false then
print("This is a Gang Turf.")
else
print("Turf not found.")
end
GetGangZoneByCoords
Determines which gang zone a specific set of coordinates falls into. Useful for checking static or dynamic positions on the map.
exports['cb-gangsystem']:GetGangZoneByCoords(coords)
Parameters
coords
(table): A table containingx
andy
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
local someCoords = { x = 250.0, y = -800.0 }
local zone = exports['cb-gangsystem']:GetGangZoneByCoords(someCoords)
if zone then
print("The coordinates are inside zone: " .. zone)
else
print("Coordinates are not inside any gang zone.")
end
IsGangTimeout
Checks if a gang currently has an active timeout/penalty applied.
exports['cb-gangsystem']:IsGangTimeout(gangID)
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
local gangID = 82
local hasTimeout = exports['cb-gangsystem']:IsGangTimeout(gangID)
if hasTimeout then
print("Gang is currently on timeout.")
else
print("Gang is active.")
end
HasLoyaltyInZone
Checks if a specific gang currently controls (has loyalty in) a given turf zone.
exports['cb-gangsystem']:HasLoyaltyInZone(gangID, zoneID)
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
local gangID = 82
local zone = "ROCKF"
local hasLoyalty = exports['cb-gangsystem']:HasLoyaltyInZone(gangID, zone)
if hasLoyalty then
print("Gang controls the zone.")
else
print("Gang does not control the zone.")
end
GetGangAtZoneReturnID
Retrieves the gang ID of the current top controller (i.e., gang with the highest loyalty) in a specific turf zone.
exports['cb-gangsystem']:GetGangAtZoneReturnID(zoneID)
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
local zone = "ROCKF"
local gangID = exports['cb-gangsystem']:GetGangAtZoneReturnID(zone)
if gangID then
print("Zone is controlled by gang ID: " .. gangID)
else
print("No gang currently controls this zone.")
end
GetGangLastActive
Retrieves the timestamp of the last activity recorded for a specific gang.
exports['cb-gangsystem']:GetGangLastActive(gangID)
Parameters
gangID
(string or number): The unique identifier of the gang.
Returns
(number): A timestamp representing when the gang was last active.
Example
local gangID = 82
local lastActive = exports['cb-gangsystem']:GetGangLastActive(gangID)
print("Gang last active at timestamp: " .. lastActive)
GetZoneController
Retrieves the gang identifier of the controller with the highest loyalty in a specified turf zone.
exports['cb-gangsystem']:GetZoneController(zoneID)
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
local zoneID = "ROCKF"
local controller = exports['cb-gangsystem']:GetZoneController(zoneID)
if controller then
print("Zone controller gang ID: " .. controller)
else
print("No controller found for this zone.")
end
GetTotalGangCount
Returns the total number of gangs currently registered in the system.
exports['cb-gangsystem']:GetTotalGangCount()
Returns
(number): The total number of gangs registered in the Gang System
Example
local totalGangs = exports['cb-gangsystem']:GetTotalGangCount()
print("Total gangs: " .. totalGangs)
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.
exports['cb-gangsystem']:GetPlayerGangType()
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
local gangType = exports['cb-gangsystem']:GetPlayerGangType()
if gangType then
print("Player's gang type: " .. gangType)
else
print("Player is not in a gang.")
end
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.
exports['cb-gangsystem']:GetGangRank()
Parameters
target
(optional): The server ID of the player.If
target
isnil
, 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
local rank = exports['cb-gangsystem']:GetGangRank()
if rank ~= nil then
print("Player Rank is:", rank)
end
GetGangZonePlayerIsIn
Determines which gang zone the player is currently located in, based on their coordinates.
exports['cb-gangsystem']:GetGangZonePlayerIsIn()
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
local currentZone = exports['cb-gangsystem']:GetGangZonePlayerIsIn()
if currentZone then
print("Player is currently in zone: " .. currentZone)
else
print("Player is not in any gang zone.")
end
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
.
exports['cb-gangsystem']:AllowedByPrevalence(gangID, action)
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'sprevalence
meets 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:
GlobalState["GangData"][gangID].prevalence
Looks up the required prevalence level from:
Config.Prevalence.PrevalenceLockout[action]
Compares them and returns
true
orfalse
.
Example
local gangID = exports['cb-gangsystem']:GetGangID(source)
if exports['cb-gangsystem']:AllowedByPrevalence(gangID, "drugs") then
-- allow drug sale
else
-- notify player: "Your gang's influence is too low to do this."
end
IsActiveRivalry
Checks if there is an active gang rivalry taking place in the specified zone.
local isRivalryActive = exports["cb-gangsystem"]:IsActiveRivalry("ZONE_TAG")
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
local turf = "MORN"
if exports["cb-gangsystem"]:IsActiveRivalry(turf) then
print("There's a rivalry in " .. turf .. "!")
else
print(turf .. " is currently peaceful.")
end
Last updated