GetTeamFromName

From Multi Theft Auto: Wiki

Jump to: navigation, search

This function finds a team object by the team's name.

Syntax

team getTeamFromName ( string teamName )

Required Arguments

  • teamName: A string determining the name of the team you wish to find.

Returns

Returns the team object if it was found, false otherwise.

Example

This example joins a team named "Red", if it is found.

function joinRedTeam ( source )
 	-- Try to find the team named 'Red'
	local redteam = getTeamFromName ( "Red" )
 
	if ( redteam ) then -- If it was found (not false)
		setPlayerTeam ( source, redteam )
	end
end
 
--Add console command to join the team when 'joinTeam' is typed.
addCommandHandler ( "joinTeam", joinRedTeam )

See Also