GetTeamColor: Difference between revisions
Jump to navigation
Jump to search
m (→Returns) |
|||
Line 14: | Line 14: | ||
==Example== | ==Example== | ||
This example outputs the name | This example outputs the player's team name and colors if he is on a team. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function teamInfo ( source ) | |||
function | local r, g, b = 255, 255, 255 | ||
r, g, b = 255, 255, 255 | local team = getPlayerTeam( source ) | ||
string = getClientName ( source ) .. " spawned" | |||
if ( team ) then | -- Make a string to print out the player's team information | ||
local string = getClientName ( source ) .. " spawned" | |||
string = string.." as | |||
if ( team ) then -- If the player is on a team (team is not false) | |||
-- Add the team name to the string | |||
string = string.." as ".. getTeamName ( team ) | |||
-- Get the red, green, and blue values of the team's color | |||
r, g, b = getTeamColor ( team ) | r, g, b = getTeamColor ( team ) | ||
-- Convert the colors to strings and add them to the string | |||
string = string .. " with team colors: " .. tostring(r) .. ", " .. tostring(g) .. ", " .. tostring(b) | |||
end | end | ||
outputChatBox ( string | |||
-- Print the string with the player's team information | |||
outputChatBox ( string ) | |||
end | end | ||
-- Add console command to print out your team information | |||
addCommandHandler ( "teamInfo", teamInfo ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Team_functions}} | {{Team_functions}} |
Revision as of 03:40, 2 August 2007
This function is for retrieving the color of a team.
Syntax
int, int, int getTeamColor ( team theTeam )
Required Arguments
- theTeam: The team you want to get the color of.
Returns
Returns 3 integers representing the red, green, and blue color values of the team if valid, otherwise 'false'.
Example
This example outputs the player's team name and colors if he is on a team.
function teamInfo ( source ) local r, g, b = 255, 255, 255 local team = getPlayerTeam( source ) -- Make a string to print out the player's team information local string = getClientName ( source ) .. " spawned" if ( team ) then -- If the player is on a team (team is not false) -- Add the team name to the string string = string.." as ".. getTeamName ( team ) -- Get the red, green, and blue values of the team's color r, g, b = getTeamColor ( team ) -- Convert the colors to strings and add them to the string string = string .. " with team colors: " .. tostring(r) .. ", " .. tostring(g) .. ", " .. tostring(b) end -- Print the string with the player's team information outputChatBox ( string ) end -- Add console command to print out your team information addCommandHandler ( "teamInfo", teamInfo )
See Also
- countPlayersInTeam
- getPlayerTeam
- getPlayersInTeam
- getTeamColor
- getTeamFriendlyFire
- getTeamFromName
- getTeamName