Color Embedding FR

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search

Revision as of 03:27, 5 January 2013

Image:32px-Ambox_warning_orange.png It has been suggested that this page or section be merged into Colors List. Discuss.

L'intégration des couleurs a été introduise dans SA:MP 0.3c. Elle permettait alors de pouvoir mettre plusieurs couleurs différentes en un seul message. Le format {RRVVBB}, est similaire aux couleurs ordinaire de l'hexadecimal, mais il n'a pas de valeurs de transparences. Vous pouvez utiliser le color picker pour trouver facilement vos couleurs.


Contents


Color embedding is currently supported in:


Examples

SendClientMessage(playerid, -1, "Hello, and welcome to {00FF00}ASDASDFASFAS{FFFFFF}!");

'ASDASDFASFAS' will be green (00FF00) and the rest white (-1 and FFFFFF).


Another example:

SendClientMessage(playerid, -1, "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}!");

Turns into Image:cembed.png


You can also define colours on top of your script and then use them inside messages:

#define RED_EMBED "{FF0000}"
 
 
SendClientMessage(playerid, -1, "This is white"RED_EMBED" and this is red.");

A similar system can be used with textdraws.

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.

See Also