PDA

View Full Version : How to change colors ingame?



Rocky
5th April 2014, 13:56
Hello.. i want use some color like IzNo's plusscore..

Is it possible to add that at white color? i want when i make hud :^7Kills to it have that color like IzNo's plusscore..

Thanks

Jeplaa
5th April 2014, 14:09
You can achive white color with rgb values: rgb(255, 255, 255)

Rocky
5th April 2014, 14:09
where is that rgb?

Omg.. aha.. can i change that color to it stay with script? i need that

YuriJurek
5th April 2014, 14:35
For hud element you can just do "self.hudkills.color = (1,1,1);"

To get the value of the color you need to divide 1 by 255 and then multiply by the rgb values of the color so rgb(255,255,255) equals (1,1,1) in cod.

Rocky
5th April 2014, 14:37
i know.. but how to change for all ingame? to white is changed to other color.

YuriJurek
5th April 2014, 14:40
setCvar("g_TeamColor_Allies", "1 1 1");
setCvar("g_TeamColor_Axis", "1 1 1");

Same rules apply.

Edit: You can not change the default ^7 colour as far as I know, only ^8.

Rocky
5th April 2014, 14:44
put that at start?

Rocky
5th April 2014, 14:47
sec.. how to change ^8?

filthy_freak_
5th April 2014, 15:04
Edit: You can not change the default ^7 colour as far as I know, only ^8.

I managed to accidentally change the color of ^9 with a bug I had in my mod. Not sure how I changed the color, I haven't investigated it, but it had something to do with _scoreboard.gsc.

YuriJurek
5th April 2014, 15:12
Yeah I am not entirely sure about all other colors because I've never played around with it.

filthy_freak_
5th April 2014, 15:22
Yup just did a test.

You can edit _scoreboard.gsc and change both g_TeamColor_Allies & g_TeamName_Axis to custom colors. You will see the changes in colors with both ^8 and ^9.

Mitch
5th April 2014, 15:23
where is that rgb?

Omg.. aha.. can i change that color to it stay with script? i need that

RGB is Red Green Blue. Use this site to find out the value you need:
http://www.rapidtables.com/web/color/RGB_Color.htm

http://www.webriti.com/wp-content/uploads/2012/01/rgb-color-wheel-lg.jpg

DisSle
5th April 2014, 16:10
HTML and Decimal support:

setHtmlColor(code)
{
if(!isDefined(code) || isDefined(code) && (code[0]=="#" && code.size!=7 || code[0]!="#" && code.size!=6))
return (1,1,1);

if(code[0]=="#")
code=getSubStr(code,1,code.size);
hex=[];
for(i=0;i<code.size;i++)
hex[hex.size]=""+code[i];
for(i=0;i<hex.size;i++)
{
switch(toLower(hex[i]))
{
case "a":
hex[i]=10;
break;
case "b":
hex[i]=11;
break;
case "c":
hex[i]=12;
break;
case "d":
hex[i]=13;
break;
case "e":
hex[i]=14;
break;
case "f":
hex[i]=15;
break;
default:
hex[i]=int(hex[i]);
break;
}
}
r=(hex[0]*16)+hex[1];
g=(hex[2]*16)+hex[3];
b=(hex[4]*16)+hex[5];

return setDecimalColor((r,g,b));
}

setDecimalColor(rgb)
{
if(!isDefined(rgb))
return (1,1,1);

if(rgb[0]<0 || rgb[0]>255)
rgb[0]=255;
if(rgb[1]<0 || rgb[1]>255)
rgb[1]=255;
if(rgb[2]<0 || rgb[2]>255)
rgb[2]=255;

return (1/(255/rgb[0]),1/(255/rgb[1]),1/(255/rgb[2]));
}

Examples:

rgb=setHtmlColor("#1A1B1C");
setCvar("g_TeamColor_Allies", rgb[0]+" "+rgb[1]+" "+rgb[2]);


rgb=setHtmlColor("#1A1B1C");

new_hud=newHudElem();
new_hud.horzAlign="center_safearea";
new_hud.vertAlign="center_safearea";
new_hud.alignX="center";
new_hud.alignY="center";
new_hud.x=0;
new_hud.y=0;
new_hud.color=rgb;
new_hud.alpha=1;
new_hud setText(&"HUD Example");

Have fun!^^

Rocky
5th April 2014, 18:06
Thanks.. but how to change color ^8 to it be some other color?

Ni3ls
5th April 2014, 18:09
Dude... Do you even read the comments?

You can edit _scoreboard.gsc and change both g_TeamColor_Allies & g_TeamName_Axis to custom colors. You will see the changes in colors with both ^8 and ^9.

Rocky
5th April 2014, 18:11
OMG.. haven't read this 1 :D


HAHA its working!