Faction
Faction setup hooks.
Factions get their own hooks that are called for various reasons, but the most common one is to set up a character
once it's created and assigned to a certain faction. For example, giving a police faction character a weapon on creation.
These hooks are used in faction tables that are created in schema/factions/sh_factionname.lua
and cannot be used like
regular gamemode hooks.
Functions
FACTION:GetDefaultName(client)
Called when the default name for a character needs to be retrieved (i.e upon initial creation).
Parameters
-
client
Player
Client to get the default name for
Returns
-
string
Default name for the newly created character
Example Usage
function FACTION:GetDefaultName(client)
return "MPF-RCT." .. tostring(math.random(1, 99999))
end
FACTION:OnCharacterCreated(client, character)
Called when a character has been initally created and assigned to this faction.
Parameters
-
client
Player
Client that owns the character
-
character
Character
Character that has been created
Example Usage
function FACTION:OnCharacterCreated(client, character)
local inventory = character:GetInventory()
inventory:Add("pistol")
end
FACTION:OnSpawn(client)
Called when a character in this faction has spawned in the world.
Parameters
-
client
Player
Player that has just spawned
FACTION:OnTransferred(character)
Called when a player's character has been transferred to this faction.
Parameters
-
character
Character
Character that was transferred
Example Usage
function FACTION:OnTransferred(character)
character:SetModel(self.models[1])
end