Cleanup cvar checks in sbar.qc under sbar_drawscoreboard, and add ping refresh interv...
[divverent/nexuiz.git] / data / qcsrc / client / teamplay.qc
1 float teamplay;
2 float myteam;
3
4 float TeamByColor(float color)
5 {
6         switch(color)
7         {
8         case COLOR_TEAM1: return 0;
9         case COLOR_TEAM2: return 1;
10         case COLOR_TEAM3: return 2;
11         case COLOR_TEAM4: return 3;
12         default: return 0;
13         }
14 }
15
16 float GetPlayerColorForce(float i)
17 {
18         if(!teamplay)
19                 return 0;
20         else
21                 return stof(getplayerkey(i, "colors")) & 15;
22 }
23
24 float GetPlayerColor(float i)
25 {
26         if not(playerslots[i].gotscores) // unconnected
27                 return COLOR_SPECTATOR;
28         else if(stof(getplayerkey(i, "frags")) == FRAGS_SPECTATOR)
29                 return COLOR_SPECTATOR;
30         else
31                 return GetPlayerColorForce(i);
32 }
33
34 string GetPlayerName(float i)
35 {
36         return ColorTranslateRGB(getplayerkey(i, "name"));
37 }
38
39 vector GetTeamRGB(float color)
40 {
41         switch(color)
42         {
43         default: return '1 1 1';
44         case COLOR_TEAM1: return '1 0 0'; // red
45         case COLOR_TEAM2: return '0 0 1'; // blue
46         case COLOR_TEAM3: return '1 1 0'; // yellow
47         case COLOR_TEAM4: return '1 0 1'; // pink
48         }
49 }
50
51 string GetTeamName(float color)
52 {
53         switch(color)
54         {
55         default: return "Spectators";
56         case COLOR_TEAM1: return "Red Team";
57         case COLOR_TEAM2: return "Blue Team";
58         case COLOR_TEAM3: return "Yellow Team";
59         case COLOR_TEAM4: return "Pink Team";
60         }
61 }