Class limits

1
This was a frequently-requested and long overdue feature. I just got around to implementing it.

Here's how it works on the CLIENT side:
Scenario 1:
Let's say you are on defense. You are assault, and someone else on your team is HW. You press your HW bind.

Your class icon changes to HW on the scoreboard, just like normal. You receive a message saying "Warning: the class you selected is full. You will be switched if there is more than 1." You are not given the ordinary 5-second delay; you can immediately change to something else of your choice.

Now let's say you still don't switch off HW by the time the spawn occurs. You are changed back to your previous class (in this case, assault). You receive a message saying "The class you selected is full. You were automatically switched back to Assault."

Scenario 2:
Let's say you are on defense. You are assault, and someone else is also assault. Your team does not have an HW. The enemy team is attempting to rush the 2nd objective on Hoth. You and the other assault on your team both press HW bind.

Both players' class icons change to HW on the scoreboard, just like normal. The player who switched latest receives a message saying "Warning: the class you selected is full. You will be switched if there is more than 1." That player are not given the ordinary 5-second delay; he can immediately change to something else of his choice. The player who switched first is given the 5-second delay, just like normal.

Now let's say neither one of you switches off HW by the time the spawn occurs. The player who switched latest is changed back to his previous class (in this case, assault). He receives a message saying "The class you selected is full. You were automatically switched back to Assault."

Scenario 3:
Let's say you are on Cargo2 defense. Both Assault and HW have a limit of 1 on this map. You are assault, and someone else on your team is HW. You decide that you want to swap classes, meaning that you go HW and your current HW goes assault.

You press your HW bind. This causes you to see the warning message. Your teammate presses his assault bind.

Since you guys resolved the exceeded limit before the spawn occured, you get to keep your new classes just like normal. Nothing out of the ordinary happens.

Here's how it works on the SERVER side:

These cvars set the limits for each class. They all default to 0 (no limit):
  • OAssaultLimit
  • OHWLimit
  • ODemoLimit
  • OTechLimit
  • OScoutLimit
  • OJediLimit
  • DAssaultLimit
  • DHWLimit
  • DDemoLimit
  • DTechLimit
  • DScoutLimit
  • DJediLimit
The main cvar that governs class limits is g_classLimits. It overrides all the other cvars:
0 = off
1 = (default) on + use automatic overrides from map/server mod
2 = on + DO NOT use automatic overrides

If g_classLimits is set to 1 (the default), the server mod will detect worldspawn keys in the map. This allows mapmakers to specify limits directly in their bsp files. For example, a mapmaker can specify the key "DAssaultLimit" with the value "1" in worldspawn. In addition, the server mod itself has some hardcoded overrides for already-existing maps (e.g. hoth2, nar, cargo).
cron