Colors List

From SA-MP Wiki

Revision as of 18:32, 19 July 2012; view current revision
←Older revision | Newer revision→
Jump to: navigation, search

Colors are everywhere in SA:MP - vehicles, player names and blips, textdraw, gametext and since 0.3c in chat, 3D texts and dialogs (as colour embedding)! Below you can find information about these different things.


Contents

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
~n~    new line
~h~    lighter color


Example

~w~Hello this is ~b~blue ~w~and this is ~r~red
Hello this is blue and this is red

Chat text and player color

A chattext or player color looks like this 0xRRGGBBAA The RR is the red part of the color, the GG the green and the BB the blue. AA is the alphavalue. If you use FF there it will be displayed without transparency and if you put it to 00 it will be invisible.

For the Hex code for these colors, go to the Hex colors page.


Alpha values (transparency)


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 choosers

Car colors

These are the color IDs that can be used for cars:

Image:Carcolors.jpg

You can find the colors they used in single player for each car on the Original Car Colors page.

Other Car Colors

sampcarcol.png Warning: These might not sync properly and/or cause clients to crash.

Color ID Description
130 Very pale pink
132 Pale pistachio
142 Electric blue
144, 145, 181, 182 Turquoise blue
146, 183 Fluorescent pink
147, 184 Sky fluorescent blue
148, 185 Purple
149, 186 Other purple
150, 165 Fuschia
151, 166 Fluorescent red
152, 167 Bind wine color
153, 168, 180 Dark brown
154, 169 Night blue
155, 170 Average red
156, 171 Very dark purple
157, 172 Dark purple
158 King blue
159 Dark pink
160 Other dark pink
161, 176 Lively red
173 Dark fuschia
174 Less dark fuschia
175 Even less dark fuschia
182 Very very bright green
183 Bright Pink
236 Dark green
237, 238, 247, 248, 249, 250, 251 A little less dark green
239, 240, 241, 242, 245, 246 Very dark green
243, 244 Very very dark green (almost black)
252 Brilliant green

There is also another page about the hidden Color IDs.

Chat/dialog embedding

Since the release of SA:MP 0.3c, it has been made possible to use colors in chat and dialogs.

It is very similar to gametext colors, but instead of just a few colors you can enter a color hex, allowing you to use any colors you like.

Example

{FFFFFF}Hello this is {0000FF}blue {FFFFFF}and this is {FF0000}red
Hello this is blue and this is red

Another example

Image:cembed.png
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}!");

The colors used in color embedding is not like normal hex colors in pawno. There is no '0x' prefix and no alpha value (last 2 digits).

You can also use colors on vehicle license plates!

Personal tools