GetPlayersInTeam

From Multi Theft Auto: Wiki
Revision as of 14:08, 27 July 2007 by Driver2 (talk | contribs)
Jump to navigation Jump to search

This function retrieves all the players of the specified team.

Syntax

table getPlayersInTeam ( team theTeam )

Optional Arguments

  • theTeam: The team you wish to retrieve all the players from.

Returns

Returns a table of all the players in the team, or an empty one if there are none.

Example

-- Find and kill all the players in the specified team (for example 'killTeam Red').
function killTeamFunction(player,command,teamName)
	-- Find and kill all the players in a team called "red"
	local team = getTeamFromName ( teamName )
	if ( team ) then
		local players = getPlayersInTeam ( team )  
		-- Loop through the player table
		for playerKey, playerValue in ipairs(players) do
			-- kill the player
			killPlayer ( playerValue )
		end
	end
end

addCommandHandler("killTeam",killTeamFunction)

See Also

Shared