CountPlayersInTeam: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 15: | Line 15: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function outputTeamSize ( source, commandName ) | |||
function outputTeamSize ( | |||
-- Get player's team | -- Get player's team | ||
local | local theTeam = getPlayerTeam ( source ) | ||
-- If the player is in any team | -- If the player is in any team | ||
if team then | if team then | ||
-- Tell the player how big his team is | -- Tell the player how big his team is | ||
outputChatBox ( "Your team has " .. countPlayersInTeam ( | outputChatBox ( "Your team has " .. countPlayersInTeam ( theTeam ) .. " players.", source ) | ||
else | else | ||
outputChatBox ( "You're not in a team.", | outputChatBox ( "You're not in a team.", source ) | ||
end | end | ||
end | end | ||
addCommandHandler ( "teamsize", outputTeamSize ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Team functions}} | {{Team functions}} |
Revision as of 19:12, 15 July 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
function outputTeamSize ( source, commandName ) -- Get player's team local theTeam = getPlayerTeam ( source ) -- If the player is in any team if team then -- Tell the player how big his team is outputChatBox ( "Your team has " .. countPlayersInTeam ( theTeam ) .. " players.", source ) else outputChatBox ( "You're not in a team.", source ) end end addCommandHandler ( "teamsize", outputTeamSize )
See Also
- countPlayersInTeam
- getPlayerTeam
- getPlayersInTeam
- getTeamColor
- getTeamFriendlyFire
- getTeamFromName
- getTeamName