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. Increments of 0x11 (decimal 17) are used for demonstration, but of course you can use any value.
Since colors are just numbers it is possible to calculate with them, although it may not always make sense. For example, it is possible to adjust the player's radar marker visibility (see above) while keeping their current color the same, regardless of what is is.
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:
Use HexToInt("RRGGBBAA") and you'll get a usable number as result for SetPlayerColor.
Colors List was added in SA-MP 0.3c and will not work in earlier versions!
It is very similar to gametext colors, but allows any color to be used.
This type of color embedding does not work in textdraws. See GameTextStyle.
Hello this is green and this is red
The code for the above chat line looks like this:
You can define colors to use like so:
The second example would be better as is it clearer that embedding is used.
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.
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).
For GameText colors you can use special tags to set the following text to a specific color.
Game text colour tags can be used to form different colours easily. The below colours are not exactly the same colour as above tags.
Now these colors are pretty dark. You can make them brighter by using ~h~ after the color code: