GetTeamFromName

From Multi Theft Auto: Wiki
Revision as of 18:55, 17 August 2007 by Arc (talk | contribs)
Jump to navigation Jump to 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)
		addPlayerToTeam ( source, redteam )
	end
end

--Add console command to join the team when 'joinTeam' is typed.
addCommandHandler ( "joinTeam", joinRedTeam )

See Also