GetTeamFromName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
Line 16: Line 16:
This example destroys a team named "Red", if it is found.
This example destroys a team named "Red", if it is found.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
team = getTeamFromName ( "Red" ) -- try to find the team named 'Red'
function joinRedTeam ( source )
if ( team ) then -- if it was found
-- Try to find the team named 'Red'
  destroyTeam ( team )
team = getTeamFromName ( "Red" )
if ( team ) then -- If it was found (not false)
addPlayerToTeam ( source, team )
end
end
end
--Add console command to join the team when 'joinTeam' is typed.
addCommandHandler ( "joinTeam", joinRedTeam )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Team_functions}}
{{Team_functions}}

Revision as of 22:01, 1 August 2007

This function is for finding a team object from its 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 destroys a team named "Red", if it is found.

function joinRedTeam ( source )
 	-- Try to find the team named 'Red'
	team = getTeamFromName ( "Red" )
	
	if ( team ) then -- If it was found (not false)
		addPlayerToTeam ( source, team )
	end
end

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

See Also