GetPlayerTeam: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Server client function}} | |||
__NOTOC__ | __NOTOC__ | ||
This function | This function gets the current [[team]] a [[player]] is on. | ||
==Syntax== | ==Syntax== | ||
Line 11: | Line 12: | ||
==Example== | ==Example== | ||
<section name="Server" class="server" show="true"> | |||
This example finds the team a player is on, and then changes its name. | This example finds the team a player is on, and then changes its name. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function teamName ( source, key, newTeamName ) | function teamName ( source, key, newTeamName ) | ||
local playerTeam = getPlayerTeam ( source ) -- get the player's team | |||
if ( playerTeam ) then -- if he's on a team | |||
local oldTeamName = getTeamName ( playerTeam ) -- get the team's current name | |||
setTeamName ( playerTeam, newTeamName ) -- change its name | |||
outputChatBox ( "Changed " .. getClientName ( source ).."'s team name from " .. oldTeamName .. " to " .. newTeamName ) | |||
else | |||
outputChatBox ( getClientName ( source ) .. " isn't on a team" ) | |||
end | |||
end | end | ||
addCommandHandler ( "teamname", teamName ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Player functions}} | {{Player functions}} |
Revision as of 14:08, 19 August 2007
This function gets the current team a player is on.
Syntax
team getPlayerTeam ( player thePlayer )
Required Arguments
- thePlayer: The player whose team you want to find out.
Example
Click to collapse [-]
ServerThis example finds the team a player is on, and then changes its name.
function teamName ( source, key, newTeamName ) local playerTeam = getPlayerTeam ( source ) -- get the player's team if ( playerTeam ) then -- if he's on a team local oldTeamName = getTeamName ( playerTeam ) -- get the team's current name setTeamName ( playerTeam, newTeamName ) -- change its name outputChatBox ( "Changed " .. getClientName ( source ).."'s team name from " .. oldTeamName .. " to " .. newTeamName ) else outputChatBox ( getClientName ( source ) .. " isn't on a team" ) end end addCommandHandler ( "teamname", teamName )
See Also
- 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