SetPlayerTeam: Difference between revisions
Jump to navigation
Jump to search
m (→See Also) |
|||
(5 intermediate revisions by 5 users not shown) | |||
Line 7: | Line 7: | ||
bool setPlayerTeam ( player thePlayer, team theTeam ) | bool setPlayerTeam ( player thePlayer, team theTeam ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[player]]:setTeam|team|getPlayerTeam}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''thePlayer:''' The [[player]] you wish to add to a team. | *'''thePlayer:''' The [[player]] you wish to add to a team. | ||
*'''theTeam:''' The [[team]] you want to add the player to | *'''theTeam:''' The [[team]] you want to add the player to, or ''nil'' if you wish to unassign a player from his team. | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the player was successfully added to the specified team, ''false'' otherwise. | Returns ''true'' if the player was successfully added to the specified team or removed from his previous one, ''false'' otherwise. | ||
==Example== | ==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 | 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 his team. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function assignNewTeam ( source, commandName, teamName ) | function assignNewTeam ( source, commandName, teamName ) | ||
Line 28: | Line 26: | ||
addCommandHandler ( "gimmeateam", assignNewTeam ) | addCommandHandler ( "gimmeateam", assignNewTeam ) | ||
function | function unassignTeam ( source, commandName ) | ||
local theTeam = getPlayerTeam ( source ) -- Check if the player is on a team | local theTeam = getPlayerTeam ( source ) -- Check if the player is on a team | ||
if theTeam then -- this player is on a team, so we can remove them from it | if theTeam then -- this player is on a team, so we can remove them from it | ||
Line 34: | Line 32: | ||
end | end | ||
end | end | ||
addCommandHandler ( " | addCommandHandler ( "takeawaymyteam", unassignTeam ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{ | {{Player functions|server}} | ||
{{Team functions|server}} |
Latest revision as of 23:01, 6 September 2024
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 )
OOP Syntax Help! I don't understand this!
- Method: player:setTeam(...)
- Variable: .team
- Counterpart: getPlayerTeam
Required Arguments
- thePlayer: The player you wish to add to a team.
- theTeam: The team you want to add the player to, or nil if you wish to unassign a player from his team.
Returns
Returns true if the player was successfully added to the specified team or removed from his previous one, 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 his team.
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 unassignTeam ( source, commandName ) local theTeam = getPlayerTeam ( source ) -- Check if the player is on a team if theTeam then -- this player is on a team, so we can remove them from it setPlayerTeam ( source, nil ) -- remove the player from the current team end end addCommandHandler ( "takeawaymyteam", unassignTeam )
See Also
- getAlivePlayers
- getDeadPlayers
- getPlayerACInfo
- getPlayerAnnounceValue
- getPlayerCount
- getPlayerIdleTime
- getPlayerIP
- getPlayerVersion
- getRandomPlayer
- isPlayerMuted
- redirectPlayer
- resendPlayerACInfo
- resendPlayerModInfo
- setPlayerAnnounceValue
- setPlayerMuted
- setPlayerScriptDebugLevel
- setPlayerTeam
- setPlayerVoiceBroadcastTo
- setPlayerVoiceIgnoreFrom
- setPlayerWantedLevel
- spawnPlayer
- takePlayerScreenShot
- Shared
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState
- createTeam
- setPlayerTeam
- setTeamColor
- setTeamFriendlyFire
- setTeamName
- Shared
- countPlayersInTeam
- getPlayerTeam
- getPlayersInTeam
- getTeamColor
- getTeamFriendlyFire
- getTeamFromName
- getTeamName