GetTeamFromName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
{{Server client function}}
__NOTOC__
__NOTOC__
This function is for finding a team object from its name.
This function finds a team object by the team's name.


==Syntax==
==Syntax==
Line 11: Line 12:


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


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

Revision as of 18:55, 17 August 2007

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 ( team ) 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