SetPlayerName || HextoRGB
#1

Hello,

My first question is regarding SetPlayerName, what kind of parameter is it awaiting at color? i tried to give string, and its giving meh the tag mismatch error, integer cant hold color code...

My second question is... is there a way to convert my hex color code into the rgb format? (or any format that allows you to use in SetPlayerColor color)
Reply
#2

PHP код:
CMD:color(playerid,params[]){
    new 
color
    sscanf
(params,"x",color);
    
SetPlayerColor(playerid,((color << 8) | 0xFF));
    return 
1;

Reply
#3

i am a fucking cunt... i meant setplayercolor and not name... sorry.


I have this & it gives me type mismatch...

PHP код:
new Color[15];
    
format(Colorsizeof(Color), "%s",GetColor(playerid)); 
    if(!
strcmp(Color"0000"true))
    {
        
SetPlayerColor(playeridColor);
    } 
GetColor gets a rgb color.
Reply
#4

Quote:
Originally Posted by AbyssMorgan
Посмотреть сообщение
PHP код:
CMD:color(playerid,params[]){
    new 
color
    sscanf
(params,"x",color);
    
SetPlayerColor(playerid,((color << 8) | 0xFF));
    return 
1;

((color << 8) | 0xFF) - Why? Doesn't SSCANF already return the correct value?

@iLearner - ^
Reply
#5

PHP код:
new Color[15], vcolor
format(Colorsizeof(Color), "%s",GetColor(playerid));  
sscanf(Color,"x",vcolor);
if(!
strcmp(Color"0000"true))

    
SetPlayerColor(playerid,((vcolor << 8) | 0xFF));

Reply
#6

Colors are integers. Just because the hexadecimal representation has letters in it doesn't mean it's a string.
Reply
#7

Abyss, could you explain your library's function HexToRGB ?
Reply
#8

HexToRGB merges 3 values: red, green, blue (0 - 255 or 0x00 - 0xFF)

PHP код:
HexToRGB(&color,red,green,blue); 
PHP код:
new color;
HexToRGB(color,255,0,0);
SetPlayerColor(playerid,RGBToRGBA(color,0xFF)); 
Reply
#9

Okay, lemme explain... you might be able to help me better...

I have a gang system, we store gang colors in hex format in database, but then we want player color is same as gang color... and thus i need this function.

Like for example, how can i set a players color to green (hex: 2fa731)
Reply
#10

Abyss?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)