GetTeamColor

From Multi Theft Auto: Wiki
Revision as of 03:40, 2 August 2007 by Sintax (talk | contribs) (→‎Example)
Jump to navigation Jump to search

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