GetPlayersInTeam: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 12: | Line 12: | ||
===Returns=== | ===Returns=== | ||
Returns a table of all the players in the team, or an empty one if there are none. | Returns a [[table]] of all the players in the team, or an empty one if there are none. | ||
==Example== | ==Example== | ||
Find and kill all the players in the specified team (for example 'killTeam Red'). | Find and kill all the players in the specified team (for example 'killTeam Red'). | ||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function killTeamFunction(player,command,teamName) | function killTeamFunction(player,command,teamName) | ||
Line 32: | Line 33: | ||
addCommandHandler("killTeam",killTeamFunction) | addCommandHandler("killTeam",killTeamFunction) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
This example will show all players in a team, when a player types the 'showTeam TeamName' command. | |||
<section name="Client" class="client"> | |||
<syntaxhighlight lang="lua"> | |||
function showTeamFunction(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 | |||
outputChatBox ( getPlayerName(playerValue) ) | |||
end | |||
end | |||
end | |||
addCommandHandler("showTeam",showTeamFunction) | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{Team functions}} | {{Team functions}} |
Revision as of 11:49, 7 August 2007
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').
Click to collapse [-]
Serverfunction 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)
This example will show all players in a team, when a player types the 'showTeam TeamName' command.
Click to expand [+]
ClientSee Also
- countPlayersInTeam
- getPlayerTeam
- getPlayersInTeam
- getTeamColor
- getTeamFriendlyFire
- getTeamFromName
- getTeamName