Problem Color System - 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: Problem Color System (
/showthread.php?tid=569152)
Problem Color System -
Eddutzu - 28.03.2015
Hi guys!
These days I wanted to start a system for using HEX colors. The code should look like this:
And the command returns:
And my color it`s black. Suggestions?
Re: Problem Color System -
ZiGGi - 28.03.2015
Use search.
Quote:
Originally Posted by paulor
pawn Код:
StrToHex(string[]) //By. DOS { new i, value; if (string[0] == '0' && (string[1] == 'x' || string[1] == 'X')) i = 2;
while (string[i]) { value <<= 4; switch (string[i]) { case '0' .. '9': value |= string[i] - '0';
case 'A' .. 'F': value |= string[i] - 'A' + 10;
case 'a' .. 'f': value |= string[i] - 'a' + 10;
default: return 0; } ++i; } return value; }
|
Re: Problem Color System -
Jefff - 28.03.2015
pawn Код:
CMD:mycolor(playerid, params[])
{
if(sscanf(params,"x",params[0])) SendClientMessage(playerid, -1, "USAGE: {49FFFF}/mycolor { HEX }");
else{
new str[12];
params[0] = (params[0] * 256) + 0xAA;
SetPlayerColor(playerid, params[0]);
format(str,sizeof(str),"0x%06xAA", (params[0] >>> 8));
SendClientMessage(playerid,-1,str);
}
return 1;
}
Re: Problem Color System -
Eddutzu - 28.03.2015
Quote:
Originally Posted by Jefff
pawn Код:
CMD:mycolor(playerid, params[]) { if(sscanf(params,"x",params[0])) SendClientMessage(playerid, -1, "USAGE: {49FFFF}/mycolor { HEX }"); else{ new str[12]; params[0] = (params[0] * 256) + 0xAA; SetPlayerColor(playerid, params[0]); format(str,sizeof(str),"0x%06xAA", (params[0] >>> 8)); SendClientMessage(playerid,-1,str); } return 1; }
|
Ty dude.