Color help
#1

Alright so the issue is quite simple, seems that this wont actually work properly or maybe Im not inserting correct color. Im using Decimal colors

PHP код:
YCMD:setcolor(playerid,params[],help) {
    if(
help) return SCM(playerid,COLOR_RED,"This command is used to change your color in game by inerting certain HexDecimal color");
    if(
GetPlayerVIPLevel(playerid) < 2) return SCM(playerid,COLOR_RED,"You are not VIP level 2+");
    new 
decimalColor[15];
    if(
sscanf(params,"s[15]",decimalColor)) return SCM(playerid,COLOR_RED,"Usage: /setcolor [Decimal color code]");
    
    new 
string[15];
    
format(string,sizeof(string),"%s",decimalColor);
    
strcpy(pStat[playerid][PlayerColour],string,15);
    
ChangePlayerColour(playerid,decimalColor); // SQL stuff, dont worry about it
    
    
new val strval(string);
    
SetPlayerColor(playeridval); 
    return 
true;

Color code example: 3139487
that should be something like greenish type of color according to https://www.mathsisfun.com/hexadecim...al-colors.html

but it turns out blue in game
Reply
#2

Yez, samp has custom color codes my friend.
I'll try to explain it to you.

FF9900 is hexidecimal for orange.

Add 0x before it and AA behind it.

0xFF9900AA here is your samp color.
So just enter 0xFF9900AA ingame, and you have a orange nametag.

cheers
Reply
#3

So for example red would be

Normal: FF0000

SA:MP 0xFF0000AA

Correct?


EDIT: no matter what sort of coding I add/remove, seems that this wont work

PHP код:
stock GetPlayerColour(playerid) {
    new 
string[25];
    
format(string,sizeof(string),"{%s}",pStat[playerid][PlayerColour]);
    return 
string;

OR

PHP код:
stock GetPlayerColour(playerid) {
    new 
string[25];
    
format(string,sizeof(string),"{0x%sAA}",pStat[playerid][PlayerColour]);
    return 
string;

Its still the same In game
PHP код:
format(string,sizeof(string),"%s [%s] %s: %s",GetPlayerColour(playerid),GetPlayerNickname(playerid),GetName(playerid),text);
SendClientMessageToAll(0xFFFFFFFF,string
It will print out the color code not the color. Aka colour of the message will stay the same
Reply
#4

AA is an alpha value about transparency. Set FF instead of AA. Check this : https://sampwiki.blast.hk/wiki/Colors_List
PHP код:
#define red 0xCC0000FF // RR GG BB AA.
#define redU "{CC0000}" 
Reply
#5

Colors are integers so treat them as integers. "i" specifier in sscanf and decimalColor as an integer, then just:
pawn Код:
SetPlayerColor(playerid, (decimalColor << 8) | 0xFF);
I prefer using R G B as parameters though like "/setcolor 255 255 255" which is white. If you are interested in that method, use:
pawn Код:
#define RGB_COLOR(%0,%1,%2,%3) (((%0) << 24) | ((%1) << 16) | ((%2) << 8) | ((%3) << 0))
and set it as (assuming R, G and B are symbols defined and used in sscanf with "iii" specifiers):
pawn Код:
SetPlayerColor(playerid, RGB_COLOR(R, G, B, 255));
As for color embedding, use in arguments: color >>> 8 as shown
pawn Код:
format(..." ... {%06x} ...", GetPlayerColor(playerid) >>> 8, ...);
Reply
#6

Adding to what Konstantinos said, you could also use the 'h' or 'x' specifier in sscanf, which would be hex.
An example of a hex color: RRGGBBAA
https://sampwiki.blast.hk/wiki/Colors_List
Reply
#7

Thanks a bunch guys! It works with the RGB method! +rep
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)