Gamemode.PlayerRequestTeam

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NamePlayerRequestTeam
SyntaxGM:PlayerRequestTeam( Player player, Integer teamid )
DescriptionCalled when a players uses the "changeteam" console command.
ReturnsBoolean
Lua StateNewerServer.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.PlayerRequestTeam]Gamemode.PlayerRequestTeam [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionHow the base gamemode handles it.
Used onNewerServer.png
Code
function GM:PlayerRequestTeam( ply, teamid )
 
	// No changing teams if not teambased!
 
	if ( !GAMEMODE.TeamBased ) then return end
 
 
 
	// This team isn't joinable
 
	if ( !team.Joinable( teamid ) ) then
 
		ply:ChatPrint( "You can't join that team" )
 
	return end
 
	// This team isn't joinable
 
	if ( !GAMEMODE:PlayerCanJoinTeam( ply, teamid ) ) then
 
		 // Messages here should be outputted by this function
 
	return end
 
	GAMEMODE:PlayerJoinTeam( ply, teamid )
 
end
OutputN/A

Additional Notes

See Also


Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox