CountPlayersInTeam: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 15: Line 15:
==Example==
==Example==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
blah blah
addCommandHandler ( "teamsize", "outputTeamSize" )
function outputTeamSize ( player )
-- Get player's team
local team = getPlayerTeam ( player )
-- If the player is in any team
if team then
-- Tell the player how big his team is
outputChatBox ( "Your team has " .. countPlayersInTeam ( team ) .. " players.", player )
else
outputChatBox ( "You're not in a team.", player )
end
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Team functions}}
{{Team functions}}
[[Category: Incomplete]]

Revision as of 17:43, 11 January 2007

This function is for returning the number of players in the specified team.

Syntax

int countPlayersInTeam ( team theTeam )

Optional Arguments

  • theTeam: The team you wish to retrieve the player count of.

Returns

Returns an integer containing the number of players in the team.

Example

addCommandHandler ( "teamsize", "outputTeamSize" )
function outputTeamSize ( player )
	-- Get player's team
	local team = getPlayerTeam ( player )
	-- If the player is in any team
	if team then
		-- Tell the player how big his team is
		outputChatBox ( "Your team has " .. countPlayersInTeam ( team ) .. " players.", player )
	else
		outputChatBox ( "You're not in a team.", player )
	end
end

See Also