GetTeamFromName: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
|||
Line 15: | Line 15: | ||
==Example== | ==Example== | ||
This example | This example creates a team, and sets the player's team to it's partial name: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- Creates a red team | |||
createTeam("Red", 255, 0, 0) | |||
function joinRedTeam (source) | |||
if ( redteam ) then -- If | if (redteam) then -- If the team was successfully created | ||
-- Sets the player's team by getting the partial name of the red team. | |||
setPlayerTeam(client, getTeamFromName("Red")) | |||
outputChatBox("You are now in the 'Red' team", source) | |||
else | |||
outputChatBox("Sorry, we can't set your team. An error occurred!", source) | |||
end | end | ||
end | end | ||
--Add console command to join the team when 'joinTeam' is typed. | --Add console command to join the team when 'joinTeam' is typed. | ||
addCommandHandler ( " | addCommandHandler("jointeam", joinRedTeam) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Team_functions}} | {{Team_functions}} |
Revision as of 07:28, 11 April 2014
This function finds a team object by the team's name.
Syntax
team getTeamFromName ( string teamName )
Required Arguments
- teamName: A string determining the name of the team you wish to find.
Returns
Returns the team object if it was found, false otherwise.
Example
This example creates a team, and sets the player's team to it's partial name:
-- Creates a red team createTeam("Red", 255, 0, 0) function joinRedTeam (source) if (redteam) then -- If the team was successfully created -- Sets the player's team by getting the partial name of the red team. setPlayerTeam(client, getTeamFromName("Red")) outputChatBox("You are now in the 'Red' team", source) else outputChatBox("Sorry, we can't set your team. An error occurred!", source) end end --Add console command to join the team when 'joinTeam' is typed. addCommandHandler("jointeam", joinRedTeam)
See Also
- countPlayersInTeam
- getPlayerTeam
- getPlayersInTeam
- getTeamColor
- getTeamFriendlyFire
- getTeamFromName
- getTeamName