πServer Exports
These exports are available exclusively on the server-side!
ATTENTION
These server-side exports do not include any built-in security. It's your responsibility to implement proper security measures when using them in your custom resources.
That said, the events and functions within our resource that utilize these exports are secured appropriately.
What do we mean by this?
Here's an example: If you plan to use the IncreasePrevalence
export inside one of your Net Events, you should first verify that the player is actually a member of a gang. Then, ensure the player legitimately performed the required action that justifies increasing their prevalence.
This is the kind of validation we're referring to when we say you need to implement your own security.
AllowedByPrevalence
Checks whether a gang meets the minimum required Prevalence Level to perform a specific restricted action.
local allowed = exports["cb-gangsystem"]:AllowedByPrevalence(gangID, action)
Parameters
gangID
(number): The unique ID of the gang.action
(string): The action being checked (e.g.,"gift"
,"drugs"
,"spray"
).
Returns
true
: The gangβs prevalence is equal to or above the required threshold for the action.false
: The gangβs prevalence is below the required threshold or the action is not found in the config.
Example
if exports["cb-gangsystem"]:AllowedByPrevalence(96, "drugs") then
-- Allow drug selling
else
-- Deny action
end
AddEscrowToRivalry
Adds an escrow amount to an active gang rivalry in a specific turf zone. If no active rivalry exists for that gang in the zone, one is created and initialized with a default cost.
exports["cb-gangsystem"]:AddEscrowToRivalry(gangID, zone, escrowedAmount)
Parameters
gangID
(number): The unique ID of the gang initiating or contributing to the rivalry.zone
(string): The turf zone where the rivalry is taking place.escrowedAmount
(number): The amount of money (or value) being added to the gangβs escrow in this rivalry.
Example
-- Add $1000 to an existing rivalry escrow in zone 'MORN' for Gang ID 96
exports["cb-gangsystem"]:AddEscrowToRivalry(96, "MORN", 1000)
AddLoyaltyToZone
Increases a gangβs loyalty value in a specific turf zone. If the zone is not already tracked for that gang, it creates a new entry in GlobalState["GangZoneData"]
.
exports["cb-gangsystem"]:AddLoyaltyToZone(gangID, zoneName, increaseAmount)
Parameters
gangID
(number): The unique ID of the gang controlling the zone.zone
(string): The identifier of the turf zone.increaseAmount
(number): The amount of loyalty to be added to the zone for the gang.
Example
-- Add 5 loyalty to the "MORN" zone for gang ID 96
exports["cb-gangsystem"]:AddLoyaltyToZone(96, "MORN", 5)
DecreaseLoyaltyInZone
Decreases the loyalty of a specific gang within a specific turf zone. If loyalty falls to zero or below, the turf is removed from GlobalState
and the associated database record is deleted.
exports['cb-gangsystem']:DecreaseLoyaltyInZone(gangID, zone, amount)
Parameters
gangID
(number): The ID of the gang controlling the zone.zone
(string): The name of the turf zone.amount
(number): How much loyalty to subtract from the zone.
Behavior When Loyalty Hits Zero
Loyalty drops to 0 or less
Turf is deleted from Database and GlobalState
Loyalty remains above 0
Turf remains with reduced loyalty
Example
-- Decrease loyalty in "MORN" turf by 25 for Gang 2
exports['cb-gangsystem']:DecreaseLoyaltyInZone(2, "MORN", 25)
IncreasePrevalence
Increases a gangβs prevalence value, which reflects their notoriety and influence in the Gang System. The export also notifies all online gang members of the prevalence change.
exports["cb-gangsystem"]:IncreasePrevalence(gangID, increaseAmount)
Parameters
gangID
(number): The unique ID of the gang whose prevalence you want to increase.increaseAmount
(number): The numeric value to add to the gangβs current prevalence.
Example
-- Give 10 prevalence to gang ID 21 (e.g., after completing a drug sale)
exports["cb-gangsystem"]:IncreasePrevalence(21, 10)
DecreasePrevalence
Decreases a gangβs prevalence value, typically in response to negative behavior or penalties (e.g., vendettas, police kills, or administrative actions). The export also notifies all online gang members of the prevalence change.
exports["cb-gangsystem"]:DecreasePrevalence(gangID, decreaseAmount)
Parameters
gangID
(number): The unique identifier for the gang.decreaseAmount
(number): The amount by which to reduce the gangβs prevalence.
Example
-- Penalize gang ID 12 with a 15-point prevalence reduction
exports["cb-gangsystem"]:DecreasePrevalence(12, 15)
AddLoyaltyToHomeTurf
Adds loyalty to a gangβs designated home turf. If no Home Turf is declared, loyalty is not added to any turf.
exports['cb-gangsystem']:AddLoyaltyToHomeTurf(gangID, amount)
Parameters
gangID
(number): The unique identifier of the gang.increaseAmount
(number): How much loyalty to add.
Example
-- Add 45 loyalty to the gang's home turf
exports['cb-gangsystem']:AddLoyaltyToHomeTurf(3, 45)
ChangeHomeTurf
Updates a gang's home turf to a new zone, handling conflicts and notifying online members of the change or if their Home Turf was taken over.
exports['cb-gangsystem']:ChangeHomeTurf(gangID, zone)
Parameters
gangID
(number): The ID of the gang declaring a new home turf.zone
(string): The zone name being set as the new home turf.
Zone Notification Behavior
None
Turf Removed
Turf has been unset/cleared
warning
Taken
Home Turf Taken
Another gangβs turf was overridden
success
Zone Name
Home Turf Changed
Turf set to the given zone
success
Example
-- Change Gang 3's home turf to "GroveStreet"
exports['cb-gangsystem']:ChangeHomeTurf(3, "ROCKF")
Last updated