countPlayersInTeam | Multi Theft Auto: Wiki Skip to content

countPlayersInTeam

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


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

OOP Syntax Help! I don't understand this!

  • Method:team:countPlayers(...)
  • Variable: .playerCount

Syntax

int countPlayersInTeam ( team theTeam )
Required Arguments
  • theTeam: The team you wish to retrieve the player count of.

Returns

  • int: value

Returns an integer containing the number of players in the team, false if it could not be retrieved.

Code Examples

shared

This example adds a command in the console to find out how many players are on your team.

function outputTeamSize ( source, commandName )
-- Get player's team
local theTeam = getPlayerTeam ( source )
-- If the player is in any team
if theTeam 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