Colors List
From SA-MP Wiki
Colors are everywhere in SA-MP - vehicles, player names and blips, textdraws, gametext and since 0.3c in chat, 3D texts and dialogs (as color embedding)! Below you can find information about these different things.
Contents |
Chat text and player color
Colors in SA-MP are generally represented in hexadecimal notation (though integers can be used also). A chattext or player color looks like this: 0xRRGGBBAA.
RR is the red part of the color, GG the green and BB the blue. AA is the alpha value. If FF is used there, the color will display without transparency and if 00 is used, it will be invisible.
For the Hex code for these colors, go to the Hex colors page.
Alpha values (transparency)
The following images display the effect of transparency values used with a white quare under the player marker and left to the saving floppy icon.
Convert string to value with pawn
Since the colors are just numbers you have to convert them sometimes from an input string "RRGGBBAA" to its number. This can be done using sscanf or the following function:
// Author: DracoBlue http://forum.sa-mp.com/index.php?topic=638.msg8635#msg8635 HexToInt(string[]){ if (string[0]==0) return 0; new i; new cur=1; new res=0; for (i=strlen(string);i>0;i--) { if (string[i-1]<58) res=res+cur*(string[i-1]-48); else res=res+cur*(string[i-1]-65+10); cur=cur*16; } return res; }
Edition WhiteJoker
stock HexToInt(string[]) { if (string[0] == 0) { return 0; } new i; new cur = 1; new res = 0; for (i = strlen(string); i > 0; i--) { if (string[i-1] < 58) { res = res + cur * (string[i - 1] - 48); } else { res = res + cur * (string[i-1] - 65 + 10); cur = cur * 16; } } return res; }
Use HexToInt("RRGGBBAA") and you'll get a usable number as result for SetPlayerColor.
Color embedding
It is possible to use colors within text in client messages, dialogs, 3D text labels, object material texts and vehicle numberplates.
It is very similar to gametext colors, but allows any color to be used.
| Note: This type of color embedding does not work in textdraws. See GameTextStyle. |
Example
{FFFFFF}Hello this is {00FF00}green {FFFFFF}and this is {FF0000}red
Another example
![]()
The code for the above chat line looks like this:
SendClientMessage(playerid, COLOR_WHITE, "Welcome to {00FF00}M{FFFFFF}a{FF0000}r{FFFFFF}c{00FF00}o{FFFFFF}'{FF0000}s {FFFFFF}B{00FF00}i{FFFFFF}s{FF0000}t{FFFFFF}r{00FF00}o{FFFFFF}!");
You can define colors to use like so:
#define COLOR_RED_EMBED "{FF0000}" SendClientMessage(playerid, -1, "This is white and "COLOR_RED_EMBED"this is red.");
Or
#define COLOR_RED_EMBED "FF0000" SendClientMessage(playerid, -1, "This is white and {"COLOR_RED_EMBED"}this is red.");
The second example would be better as is it clearer that embedding is used.
Using GetPlayerColor
To use a player's color as an embedded color, you must first remove the alpha value. To do this, perform a logical right shift.
new msg[128]; format(msg, sizeof(msg), "{ffffff}This is white and {%06x}this is the player's color!", GetPlayerColor(playerid) >>> 8); SendClientMessage(playerid, 0xffffffff, msg);
The %x is the placeholder for hexadecimal values, the 6 ensures that the output string will always be six characters long and the 0 will pad it with zeros if it's not. Note that GetPlayerColor only works properly if SetPlayerColor has been used beforehand.
The colors used in color embedding are not like normal hex colors in Pawn. There is no '0x' prefix and no alpha value (last 2 digits).
Color choosers
GameText
For GameText colors you can use special tags to set the following text to a specific color.
~r~ red ~g~ green ~b~ blue ~w~ white ~y~ yellow ~p~ purple ~l~ black ~h~ lighter color
Example
~w~Hello this is ~b~blue ~w~and this is ~r~red
Now these colors are pretty dark. You can make them brighter by using ~h~ after the color code:
~w~Hello this is ~b~~h~blue ~w~and this is ~r~~h~red
Vehicle Color IDs
There is a full list of vehicle color IDs. You can find the colors used in single player for each car on the Original Car Colors page.


