Part of TPG namespace
TPG.PlayerTeams.AssignPlayer(ply, teamId)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
| Name | Type | Description |
|---|---|---|
ply | Player | |
teamId | number | TEAM_GREEN, TEAM_RED or TEAM_UNASSIGNED. |
Returns
| Type | Description |
|---|---|
boolean | True if the player ended up on `teamId`. |
Examples
No examples available.
Used In
No usages found in the codebase.