Garry's Mod Wiki

GM:PlayerChangedTeam

GM:PlayerChangedTeam( Player ply, number oldTeam, number newTeam )

Description

Called when a player has changed team using Player:SetTeam.

Avoid calling Player:SetTeam in this hook as it may cause an infinite loop!

Arguments

1 Player ply
Player whose team has changed.
2 number oldTeam
Index of the team the player was originally in. See team.GetName and the team library.
3 number newTeam
Index of the team the player has changed to.

Example

Print the old Team name and the new Team name of players.

hook.Add( "PlayerChangedTeam", "PrintOldAndNewTeam", function( ply, oldTeam, newTeam ) PrintMessage( HUD_PRINTTALK, ply:Nick() .. " switched from " .. team.GetName( oldTeam ) .. " to " .. team.GetName( newTeam ) ) end )
Output: Player1 switched from Team1 to Team2

Page Links


Special Pages


Wikis

?

Render Time: 98ms

DB GetPage 60
Generate Html 16
SaveChanges (1) 13
Render Body 0
Render Sidebar 6