Color ; /setcolor
#1

I am trying to replicate a server, They had a command where they can let their player to make their own colors by using the /cc (stands for color change

I have no idea on how to make it though so far I have coded this into my /setcolor command. The format are; /setcolor [0-255] [0-255] [0-255].

PHP код:
CMD:setcolor(playeridparams[])
{
    if(!
pInfo[playerid][pLogged] && !pInfo[playerid][pUser])
        return 
SendError(playerid"You must logged in (register) to your account first.");
    new 
c[3];
    
    if(
sscanf(params"ddd"c[0], c[1], c[2]))
        return 
SendSyntax(playerid"/setcolor [0-255] [0-255] [0-255]");
        
    if(
c[0] < || c[0] > 255)
        return 
SendError(playerid"Invalid color number for #1.");
    if(
c[1] < || c[1] > 255)
        return 
SendError(playerid"Invalid color number for #2.");
    if(
c[2] < || c[2] > 255)
        return 
SendError(playerid"Invalid color number for #3.");
    return 
1;

Reply
#2

pawn Код:
SetPlayerColor(playerid, (c[0] * 16777216) + (c[1] * 65536) + (c[2] * 256) + 255);
// ({RED} * 16777216) + ({GREEN} * 65536) + ({BLUE} * 256) + {ALPHA}
Reply
#3

Will try it out, Thank you. This post will be updated within a few minutes.

Edit;

Is this normal? Because I don't know how RGB works, Can someone tell me how it works specially when converted to integer just like these 0-255 (I would like to guide the players on using /setcolor sooo yeah.)

Reply
#4

Yes, it is normal. As long as you use the command a little bit, you'll memorize most of the colors (I still do remember them since 2010).

People can play around with the 0-255 values and find a color they like or browse a site with basic colors such as: http://cloford.com/resources/colours/500col.htm
You can find the R G B for them at the right side of the page.
Reply
#5

If you know how hex colors work, you'll easily understand how RGB works.

0xFF = 255, so basically the max of a color
0xFFFFFF = 255 255 255 (White)
0x00FFFF = 000 255 255 (Cyan)
0xFFFF00FF = 255 255 000 255 (Yellow with ALPHA[visibility] at max)


Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
SetPlayerColor(playerid, (c[0] * 16777216) + (c[1] * 65536) + (c[2] * 256) + 255);
// ({RED} * 16777216) + ({GREEN} * 65536) + ({BLUE} * 256) + {ALPHA}
This is the exact same one but with hex:
pawn Код:
SetPlayerColor(playerid, (c[0] * 0x1000000) + (c[1] * 0x10000) + (c[2] * 0x100) + 0xFF);
I'm just adding this in so if you ever want to do it again, you don't have to come back here (Those integers are pretty hard to remember)
Reply
#6

Thank you for helping me out, I will be studying more about the R-G-B in the future... Y'all help are appreciated.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)