SetPlayerTeam: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ {{Server function}} This function adds a player to an existing team. The player will automatically be removed from his current team if he's on one. ==Syntax== <syntaxhighlight lang="lua">[lua...) |
|||
Line 34: | Line 34: | ||
end | end | ||
end | end | ||
addCommandHandler ( "takeawaymeteam", | addCommandHandler ( "takeawaymeteam", unassignNewTeam ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Team_functions}} | {{Team_functions}} |
Revision as of 10:30, 9 November 2007
This function adds a player to an existing team. The player will automatically be removed from his current team if he's on one.
Syntax
bool setPlayerTeam ( player thePlayer, team theTeam )
Required Arguments
Note: if you wish to unassign a player from a team, set theTeam to nil
Returns
Returns true if the player was successfully added to the specified team, false otherwise.
Example
This example adds a command to create a new team for a player, then add him to it. It also adds a command to remove him from the team too.
function assignNewTeam ( source, commandName, teamName ) local theTeam = createTeam ( teamName ) -- create a new team with the specified name if theTeam then -- if it was successfully created setPlayerTeam ( source, theTeam ) -- add the player to the new team end end addCommandHandler ( "gimmeateam", assignNewTeam ) function unassignNewTeam ( source, commandName ) local theTeam = getPlayerTeam ( source ) -- Check if the player is on a team if theTeam then -- if it was successfully created setPlayerTeam ( source, nil ) -- add the player to the new team end end addCommandHandler ( "takeawaymeteam", unassignNewTeam )
See Also
- countPlayersInTeam
- getPlayerTeam
- getPlayersInTeam
- getTeamColor
- getTeamFriendlyFire
- getTeamFromName
- getTeamName