faction library
Summary
Functions
default set.position is one lower.position.position is one higher.position.Functions
Finds a faction by index, exact name or part of its name.
Partial matches are case-insensitive plain text; the faction with the shortest matching name wins.
Parameters
- identifier Any Faction index (Number or numeric String), name or part of the name
Returns
- Faction The faction, or
nilif none matches
Returns every registered faction keyed by name.
Returns
- Map<Faction> Factions keyed by name
Returns the registered factions keyed by numeric index.
Returns
- Map<Faction> Factions keyed by the CRC-based index from
cw.core:GetShortCRC
faction.GetDefaultRank(factionID)
shared gamemodes/catwork/gamemode/core/libraries/sh_faction.lua:349Returns the faction's default rank, the first rank with default set.
Parameters
- factionID Any Faction name, index or part of the name
Returns
- String The rank's name, or
nilif the faction is not found or has no default rank - Map The rank table
faction.GetHigherRank(factionID, rank)
shared gamemodes/catwork/gamemode/core/libraries/sh_faction.lua:313Returns the rank one step above a rank, the one whose position is one lower.
Parameters
- factionID Any Faction name, index or part of the name
- rank Map The current rank table
Returns
- String The higher rank's name, or
nilifrankis already the highest - Map The higher rank table
See also
faction.GetHighestRank(factionID)
shared gamemodes/catwork/gamemode/core/libraries/sh_faction.lua:245Returns the faction's highest rank, the one with the lowest position.
Parameters
- factionID Any Faction name, index or part of the name
Returns
- String The rank's name, or
nilif the faction is not found or has no ranks - Map The rank table
See also
Returns how many players may be in a faction right now.
A faction's limit is relative to a full 128-player server, so the real limit scales with the
current player count. Factions with the default limit of 128 return game.MaxPlayers().
Parameters
- name Any Faction name, index or part of the name
Returns
- Number The current limit, or 0 if the faction is not found
faction.GetLowerRank(factionID, rank)
shared gamemodes/catwork/gamemode/core/libraries/sh_faction.lua:332Returns the rank one step below a rank, the one whose position is one higher.
Parameters
- factionID Any Faction name, index or part of the name
- rank Map The current rank table
Returns
- String The lower rank's name, or
nilifrankis already the lowest - Map The lower rank table
See also
faction.GetLowestRank(factionID)
shared gamemodes/catwork/gamemode/core/libraries/sh_faction.lua:278Returns the faction's lowest rank, the one with the highest position.
Parameters
- factionID Any Faction name, index or part of the name
Returns
- String The rank's name, or
nilif the faction is not found or has no ranks - Map The rank table
See also
Returns every initialized player in a faction.
Parameters
- faction String Faction name, as returned by
Player:GetFaction
Returns
- List<Player> The players in the faction
Returns the registered factions keyed by name.
Returns
- Map<Faction> Factions keyed by name
See also
faction.HasReachedMaximum(player, factionID)
shared gamemodes/catwork/gamemode/core/libraries/sh_faction.lua:369On the server
Returns whether a player already has the maximum number of characters in a faction.
Only factions with a maximum field limit characters.
Parameters
- player Player The player whose characters are counted
- factionID Any Faction name, index or part of the name
Returns
- Boolean
trueif the maximum is reached, otherwisenil
On the client
Returns whether the local player already has the maximum number of characters in a faction.
Client version of the server's faction.HasReachedMaximum, counting the characters in
cw.character:GetAll.
Parameters
- factionID Any Faction name, index or part of the name
Returns
- Boolean
trueif the maximum is reached, otherwisenil
Defined in
faction.IsGenderValid(faction, gender)
shared gamemodes/catwork/gamemode/core/libraries/sh_faction.lua:157Returns whether a gender may be chosen for a faction.
Factions with a singleGender only accept that gender.
Parameters
- faction Any Faction name, index or part of the name
- gender String
GENDER_MALEorGENDER_FEMALE
Returns
- Boolean
trueif the gender is valid, otherwisenil
faction.IsModelValid(faction, gender, model)
shared gamemodes/catwork/gamemode/core/libraries/sh_faction.lua:173Returns whether a model is one of a faction's models for a gender.
Parameters
- faction Any Faction name, index or part of the name
- gender String
GENDER_MALEorGENDER_FEMALE - model String Model path
Returns
- Boolean
trueif the model is valid, otherwisenil
Creates a new, unregistered faction object.
Set its fields (models, whitelist, material, limit, maximum, singleGender,
ranks...) and callbacks, then call CLASS_TABLE:Register on it.
local FACTION = faction.New('#Faction_MPF')
FACTION.whitelist = true
FACTION.material = 'halfliferp/factions/mpf'
FACTION_MPF = FACTION:Register()
Parameters
- name String optional, defaults to
'Unknown'Name of the faction, can be a language phrase
Returns
- Faction The new faction object
Registers a faction.
Missing models.male and models.female lists default to the Half-Life 2 citizen models,
limit defaults to 128 and the index is a short CRC of name. On the server, during the first
boot, the faction's models and its material PNG are added to the client download list.
Parameters
- data Faction The faction object or table
- name String Name of the faction, used when
data.nameis not set
Returns
- String The faction's name