Back to TPG

TPG.PlayerTeams.AssignPlayer

S🏷️ Playerteams

Part of TPG namespace

TPG.PlayerTeams.AssignPlayer(ply, teamId)
View on GitHub|gamemode/player/sv_teams.lua:33-78
📋 Has LDoc👁️ 0 viewsUpdated 1 month ago

Description

Move a player onto a team, subject to the switch cooldown and balance check. A no-op (returns true without touching the cooldown) if they are already on teamId. Otherwise: voluntary switches onto an actual team (not spectator) are throttled by TPG.Config.teamSwitchCooldown, which admins bypass and which only applies once the player has switched at least once before (ply.tpgLastTeamSwitch unset on first join). Leaving to spectator is always allowed and never stamps the cooldown. Passing the cooldown still requires CanJoin to allow the move; either rejection sends a chat message and returns false without moving the player. On success this also respawns the player and applies team colour via the normal spawn path.

Parameters

NameTypeDescription
plyPlayer
teamIdnumberTEAM_GREEN, TEAM_RED or TEAM_UNASSIGNED.

Returns

TypeDescription
booleanTrue if the player ended up on `teamId`.

Examples

No examples available.

Used In

No usages found in the codebase.