Hooks hooks
Part of Factions System
Hooks called by Factions System
Summary
Hooks
Player:set_faction has moved a player into a faction: their name, rank, team, gender and model have been updated, the on_player_leave and on_player_join callbacks of the factions have run, and the player has been given the weapons, maximum health and armor and rank model of the new faction.Player:set_rank has changed the rank of a player, networked it, regenerated their name and given them the model, the weapons and the maximum health and armor of the rank.Hooks
GetFactionLimit(faction_table, limit, rank_table)
shared plugins/factions/plugin/lib/sh_faction.lua:216Lets plugins change how many members of a faction, or holders of one of its ranks, may
be online at once, for example to scale the limit with the amount of players online.
Called on both realms by Factions.get_limit.
Parameters
- faction_table Faction the faction
- limit Number the limit set by the definition of the faction or of the rank, 0 for no limit
- rank_table Map the rank whose limit is asked for, nil when it is the limit of the whole faction
Returns
- Number the limit to use instead, 0 for no limit; return nothing to keep the limit of the definition
Called from
Call sites
Lets plugins decide the maximum health of a player. Called on the server by
Factions.apply_vitals when a player spawns and when their faction or rank changes,
after the maximum health of the faction and rank has been looked up. The Levels plugin
answers it with the maximum health of the player's level.
Parameters
- target Player The player whose vitals are being applied
- max_health Number Maximum health of the faction and rank; nil when they set none
Returns
- Number Return a maximum health to use instead, rounded down and never lower than 1. It is applied, and filled up on spawn, the way the maximum health of a faction is. Return nothing to keep the one of the faction and rank
Called from
Call sites
OnPlayerFactionChanged(self, faction_table, old_faction)
server plugins/factions/plugin/lib/sh_faction.lua:882Called on the server after Player:set_faction has moved a player into a faction:
their name, rank, team, gender and model have been updated, the on_player_leave
and on_player_join callbacks of the factions have run, and the player has been given
the weapons, maximum health and armor and rank model of the new faction.
Parameters
- target Player
- faction_table Faction the faction the player is in now
- old_faction Faction the faction the player was in before, nil if that was not a registered faction
Called from
Call sites
Called on the server after Player:set_rank has changed the rank of a player,
networked it, regenerated their name and given them the model, the weapons and the
maximum health and armor of the rank.
Parameters
- target Player
- rank Number the new rank index
- old_rank Number the rank index before the change
Called from
Call sites
PlayerCanBypassFactionCreationLimits(target, data)
shared plugins/factions/plugin/lib/sh_faction.lua:310Decides whether a player may create a character in a faction they are not whitelisted for, or beyond the amount of characters the faction allows them. Called on the server when a creation request is checked, and on the client for the local player when the faction stage of the creation screen lists the factions and checks the chosen one, so a handler that is meant to be seen in the menu has to be shared.
Parameters
- target Player the player who creates the character
- data Map the creation data on the server; the extra data of the creation screen on the client, nil when it has none
Returns
- Boolean return true to let the player create the character regardless of the whitelist and the limit
Called from
Call sites
PlayerCanBypassFactionLimit(actor, faction_table, rank_table, character)
server plugins/factions/plugin/sv_hooks.lua:31Decides whether a player may load a character although its faction, or its rank in that faction, already has as many members online as the limit allows, or although the faction is whitelisted and the player is not on its whitelist. Called on the server when a player asks to load such a character.
Parameters
- actor Player the player who wants to load the character
- faction_table Faction the faction of the character
- rank_table Map the rank that is full, nil when it is the faction that is full or the whitelist that is missing
- character Character the character they want to load
Returns
- Boolean return true to let the player in regardless of the limit
Called from
can_bypass_limit
Call sites
PlayerCanTransferFaction(target, faction_table, old_faction)
server plugins/factions/plugin/lib/sh_faction.lua:481Decides whether a player may be moved into a faction. Called on the server by
Factions.can_transfer, which the SetFaction command uses, after the can_transfer
callback of the faction has allowed it.
Parameters
- target Player the player who is to be moved
- faction_table Faction the faction they are to be moved into
- old_faction Faction the faction they are in, nil if it is not registered
Returns
- Boolean return false to refuse the transfer
- String a language phrase that tells why and Map the arguments of the phrase; a generic text is used when the reason is omitted
Called from
Call sites
Lets plugins regroup the players of the scoreboard before its faction categories are created. Called on the client each time the scoreboard is rebuilt.
Parameters
- players_table Map lists of players keyed by faction ID, with an entry for every faction that has players online; modify it in place. An entry under the 'players_online' key becomes a category titled with the 'ui.scoreboard.players_online' phrase; every other key has to be the ID of a registered faction
Called from
Call sites
ShouldNameGenerate(target, self, char_name, rank, default_data)
shared plugins/factions/plugin/models/faction.lua:384Decides whether a character name is generated for a player. Called by
Faction:generate_name before the name template of the faction is applied; the Factions
plugin itself returns false for bots.
Parameters
- target Player
- faction Faction the faction that generates the name
- char_name String the current name of the player
- rank Number/String rank index or rank ID the name is generated for
- default_data Map values for the {data:key} placeholders of the template
Returns
- Boolean return false to keep the current name of the player