SetObjectMaterial Color problem..
#1

Hello,

I just cannot get it working, I tried many different converts but everything fails.
Right now I have the following;

I wan't players to enter a Hex color, and my script should convert it to a ARGB format for SetObjectMaterial.
So this is what I do,
I have this functions:
Код:
stock ARGB( alpha, red, green, blue)
{
	return alpha + (red * 16777216) + (green * 65536) + (blue * 256);
}
stock HexToInt(string[]) {
  if (string[0]==0) return 0;
  new i;
  new cur=1;
  new res=0;
  for (i=strlen(string);i>0;i--) {
    if (string[i-1]<58) res=res+cur*(string[i-1]-48); else res=res+cur*(string[i-1]-65+10);
    cur=cur*16;
  }
  return res;
}
Then i use the following line to convert the color to this ARGB format:
Код:
ARGB(HexToInt(alpha), HexToInt(red), HexToInt(green), HexToInt(blue))
I will show you some print lines;
The users input is: 0xFF0000FF (which is red)
The following code give me this result: FFFF0000
Код:
printf("%s%s%s%s",alpha,red,green,blue);
Now the ARGB converter gives me the following result: -16776961
And the material becomes blue instead of red.
So it seems i have to switch blue as red.
I tried that on different ways but it always becomes blue for some reason.
Someone know how to deal with this?
Reply


Messages In This Thread
SetObjectMaterial Color problem.. - by Roel - 08.10.2013, 10:32
Re: SetObjectMaterial Color problem.. - by Vince - 08.10.2013, 11:09
Re: SetObjectMaterial Color problem.. - by Roel - 08.10.2013, 12:19
Re: SetObjectMaterial Color problem.. - by Konstantinos - 08.10.2013, 12:39
Re: SetObjectMaterial Color problem.. - by Roel - 08.10.2013, 13:00
Re: SetObjectMaterial Color problem.. - by Konstantinos - 08.10.2013, 13:04

Forum Jump:


Users browsing this thread: 1 Guest(s)