Color ; /setcolor - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Color ; /setcolor (
/showthread.php?tid=615584)
Color ; /setcolor -
JaKe Elite - 24.08.2016
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(playerid, params[])
{
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] < 0 || c[0] > 255)
return SendError(playerid, "Invalid color number for #1.");
if(c[1] < 0 || c[1] > 255)
return SendError(playerid, "Invalid color number for #2.");
if(c[2] < 0 || c[2] > 255)
return SendError(playerid, "Invalid color number for #3.");
return 1;
}
Re: Color ; /setcolor -
Konstantinos - 24.08.2016
pawn Код:
SetPlayerColor(playerid, (c[0] * 16777216) + (c[1] * 65536) + (c[2] * 256) + 255);
// ({RED} * 16777216) + ({GREEN} * 65536) + ({BLUE} * 256) + {ALPHA}
Re: Color ; /setcolor -
JaKe Elite - 24.08.2016
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.)
Re: Color ; /setcolor -
Konstantinos - 24.08.2016
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.
Re: Color ; /setcolor -
Stinged - 24.08.2016
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)
Re: Color ; /setcolor -
JaKe Elite - 24.08.2016
Thank you for helping me out, I will be studying more about the R-G-B in the future... Y'all help are appreciated.