Client
Every client export and state bag, with examples.
All exports below are client side.
Gang#
GetGang#
Returns the gang of the local player.
local gang = exports.cube_gang:GetGang()- returns:
tableornilid:numbername:stringlabel:stringtype:stringcolor:string-#RRGGBBlogo:stringornilpoints:numbermoney:numbergrade:number- rank of the player,1is the lowestrank:string- rank labelleader:boolean- the player has the highest rankowner:boolean- the player owns the gangpermissions:table<string, boolean>- every permission of the player, inheritance included
local gang = exports.cube_gang:GetGang()
if gang then
print(('%s - %s'):format(gang.label, gang.rank))
endHasPermission#
local allowed = exports.cube_gang:HasPermission(permission)- permission:
string - returns:
boolean
Client checks are for display only. Always check permissions again on the server before doing anything.
State bag#
The gang of every player is replicated in a state bag, readable by any resource without calling an export.
local gang = LocalPlayer.state.gangFrom the server, or for another player:
local gang = Player(playerId).state.gangid:numbername:stringlabel:stringcolor:stringgrade:number
The value is nil when the player has no gang. React to changes with a state bag handler:
AddStateBagChangeHandler('gang', ('player:%s'):format(cache.serverId), function(_, _, value)
print('gang changed', value and value.label)
end)Color the name of a player with the color of their gang.
local gang = Player(GetPlayerServerId(player)).state.gang
local color = gang and gang.color or '#FFFFFF'Only show a blip to members of the gang that owns it.
local gang = LocalPlayer.state.gang
if gang and gang.name == 'ballas' then
local blip = AddBlipForCoord(85.0, -1959.0, 20.0)
SetBlipSprite(blip, 84)
endTerritories#
GetCurrentZone#
Returns the territory the local player is standing in.
local zone = exports.cube_gang:GetCurrentZone()- returns:
tableornilid:numbername:stringlabel:stringowner:numberornil- gang idownerLabel:stringornilcolor,logo: owner color and logodrugs:{ name, label, multiplier }[]- current drug demandpoints:{ x, y, z? }[]
local zone = exports.cube_gang:GetCurrentZone()
local gang = exports.cube_gang:GetGang()
if zone and gang and zone.owner == gang.id then
print('You are home')
endGetZone#
local zone = exports.cube_gang:GetZone(zoneId)- zoneId:
number - returns:
tableornil- same structure asGetCurrentZone
Map#
GetHoveredZone#
Returns the territory under the cursor of the pause map.
local zone = exports.cube_gang:GetHoveredZone()- returns:
tableornil
IsMapZonesHidden#
local hidden = exports.cube_gang:IsMapZonesHidden()SetMapZonesHidden#
Hides or shows every territory on the minimap and the pause map, for the local player. The choice is remembered.
exports.cube_gang:SetMapZonesHidden(true)- state:
boolean
ToggleMapZones#
exports.cube_gang:ToggleMapZones()Hide the territories during a cinematic, then bring them back:
exports.cube_gang:SetMapZonesHidden(true)
-- ... cutscene ...
exports.cube_gang:SetMapZonesHidden(false)