Commits

mickael9 committed c28463f

Add two cvars : sv_minTeamChangeHealth and sv_minKillHealth that define the minimum health
a player needs to kill himself or change his team (0 - 100)

Comments (0)

Files changed (4)

code/server/server.h

 extern cvar_t *sv_disallowitemdrop; // MaJ - Don't allow players to drop items.
 extern cvar_t *sv_disallowweapdrop; // MaJ - Don't allow players to drop weapons.
 extern cvar_t *sv_regainStamina;
+extern cvar_t *sv_minTeamChangeHealth;
+extern cvar_t *sv_minKillHealth;
 
 extern serverBan_t serverBans[SERVER_MAXBANS];
 extern int serverBansCount;

code/server/sv_client.c

         // pass unknown strings to the game
         if (!u->name && sv.state == SS_GAME)
         {
+            playerState_t *ps = SV_GameClientNum(cl - svs.clients);
+            int health = ps->stats[STAT_HEALTH];
+
+            if ((!Q_stricmp("kill", Cmd_Argv(0)) && health && health < sv_minKillHealth->integer) ||
+                (!Q_stricmp("team", Cmd_Argv(0)) && health && health < sv_minTeamChangeHealth->integer))
+                return;
+
             Cmd_Args_Sanitize();
 
             argsFromOneMaxlen = -1;

code/server/sv_init.c

     sv_disallowitemdrop = Cvar_Get("sv_disallowitemdrop", "0", CVAR_ARCHIVE);
     sv_disallowweapdrop = Cvar_Get("sv_disallowweapdrop", "0", CVAR_ARCHIVE);
     sv_regainStamina = Cvar_Get("sv_regainStamina", "0", CVAR_ARCHIVE);
+    sv_minTeamChangeHealth = Cvar_Get("sv_minTeamChangeHealth", "0", CVAR_ARCHIVE);
+    sv_minKillHealth = Cvar_Get("sv_minKillHealth", "0", CVAR_ARCHIVE);
 
     // initialize bot cvars so they are listed and can be set before loading the botlib
     SV_BotInitCvars();

code/server/sv_main.c

 cvar_t *sv_disallowitemdrop;    // MaJ - Don't allow players to drop items.
 cvar_t *sv_disallowweapdrop;    // MaJ - Don't allow players to drop weapons.
 cvar_t *sv_regainStamina;
+cvar_t *sv_minTeamChangeHealth;
+cvar_t *sv_minKillHealth;
 
 serverBan_t serverBans[SERVER_MAXBANS];
 int serverBansCount = 0;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.