Team ID To RGB

Started by EK.IceFlake, Feb 14, 2015, 04:29 AM

Previous topic - Next topic

EK.IceFlake

Hi guys! Most of you are probably porting your server to 0.4, and now you are thinking that why didnt colors assigned to teamids? The answer: Now they are about to be!
Just copy and paste the code to your script
function TeamidToRGB(teamid)
{
if (teamid == 0) return RGB(119, 136, 152);
if (teamid == 1) return RGB(255, 141, 19);
if (teamid == 2) return RGB(163, 73, 164);
if (teamid == 3) return RGB(32, 177, 170);
if (teamid == 4) return RGB(255, 215, 32);
if (teamid == 5) return RGB(220, 20, 59);
if (teamid == 6) return RGB(99, 139, 236);
if (teamid == 7) return RGB(255, 141, 19);
if (teamid == 8) return RGB(244, 163, 97);
if (teamid == 9) return RGB(238, 130, 239);
if (teamid == 10) return RGB(139, 69, 18);
if (teamid == 11) return RGB(240, 231, 140);
if (teamid == 12) return RGB(20, 138, 138);
if (teamid == 13) return RGB(20, 255, 127);
if (teamid == 14) return RGB(86, 107, 48);
if (teamid == 15) return RGB(25, 25, 113);
return RGB(0, 0, 0);
}
Thanks to VK.Angel.OfDeath for providing me with the RGB values :)

.

This would be a valid case for a switch statement:
function TeamidToRGB(teamid)
{
switch (teamid)
{
case 0: return RGB(119, 136, 152);
case 1: return RGB(255, 141, 19);
case 2: return RGB(163, 73, 164);
case 3: return RGB(32, 177, 170);
case 4: return RGB(255, 215, 32);
case 5: return RGB(220, 20, 59);
case 6: return RGB(99, 139, 236);
case 7: return RGB(255, 141, 19);
case 8: return RGB(244, 163, 97);
case 9: return RGB(238, 130, 239);
case 10: return RGB(139, 69, 18);
case 11: return RGB(240, 231, 140);
case 12: return RGB(20, 138, 138);
case 13: return RGB(20, 255, 127);
case 14: return RGB(86, 107, 48);
case 15: return RGB(25, 25, 113);
default: return RGB(0, 0, 0);
}
}
.

EK.IceFlake

Quote from: S.L.C on Feb 14, 2015, 04:40 AMThis would be a valid case for a switch statement:
function TeamidToRGB(teamid)
{
switch (teamid)
{
case 0: return RGB(119, 136, 152);
case 1: return RGB(255, 141, 19);
case 2: return RGB(163, 73, 164);
case 3: return RGB(32, 177, 170);
case 4: return RGB(255, 215, 32);
case 5: return RGB(220, 20, 59);
case 6: return RGB(99, 139, 236);
case 7: return RGB(255, 141, 19);
case 8: return RGB(244, 163, 97);
case 9: return RGB(238, 130, 239);
case 10: return RGB(139, 69, 18);
case 11: return RGB(240, 231, 140);
case 12: return RGB(20, 138, 138);
case 13: return RGB(20, 255, 127);
case 14: return RGB(86, 107, 48);
case 15: return RGB(25, 25, 113);
default: return RGB(0, 0, 0);
}
}
I tried to use switch but couldn't find any information on it on squirrel refrence manual.

.

#3
Quote from: NE.CrystalBlue on Feb 14, 2015, 04:42 AMI tried to use switch but couldn't find any information on it on squirrel refrence manual.

There is but it's not that pretty for those new to programming. Hell, even I was a bit confused by the official documentation. Because it doesn't provide an example and just the expected syntax. Anyway, there are other sources as I've already mentioned in my other posts:
EDIT: Please note that switch cases are now documented in detail in this post.
.

kokia

how to use it where to paste it which function

[VSS]Shawn


MacTavish

Usage

onScriptLoad
{
  AddClass( 1, TeamidToRGB(1),0, Vector( -378.79, -537.962, 17.2832 ), 140.020, 21, 999 ,1, 1, 25, 255 );
}

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

KAKAN

I'm happy with RGB also :D, but this is better
oh no

kokia

Quote from: Beztone on Jul 25, 2015, 08:57 AMUsage

onScriptLoad
{
  AddClass( 1, TeamidToRGB(1),0, Vector( -378.79, -537.962, 17.2832 ), 140.020, 21, 999 ,1, 1, 25, 255 );
}
i have randspawn in my script so will it work? and do i need to add it for every team?

KAKAN

Yes, and yes
1st. Yes, It'll work 100%
2nd. Yes, u need to add it for every team, better if u have RGB and a lot of skins, don't add this
oh no