Skip to content

Commit b6c2c62

Browse files
authored
Added mp_vote_flags and mp_votemap_min_time cvars (#990)
* Added mp_vote_flags cvar * Added mp_votemap_min_time cvar * Cvars on README * game.cfg cvars * Ensure timers check before new restrictions
1 parent c7bd4af commit b6c2c62

6 files changed

Lines changed: 73 additions & 19 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
120120
| mp_item_respawn_time | 30 | 0.0 | - | The respawn time for items (such as health packs, armor, etc.). |
121121
| mp_weapon_respawn_time | 20 | 0.0 | - | The respawn time for weapons. |
122122
| mp_ammo_respawn_time | 20 | 0.0 | - | The respawn time for ammunition. |
123+
| mp_vote_flags | km | 0 | - | Vote systems enabled in server.<br/>`0` voting disabled<br/>`k` votekick enabled via `vote` command<br/>`m` votemap enabled via `votemap` command |
124+
| mp_votemap_min_time | 180 | 0.0 | - | Minimum seconds that must elapse on map before `votemap` command can be used. |
125+
123126
</details>
124127

125128
## How to install zBot for CS 1.6?

dist/game.cfg

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,3 +605,18 @@ mp_weapon_respawn_time "20"
605605
//
606606
// Default value: "20"
607607
mp_ammo_respawn_time "20"
608+
609+
// Vote systems enabled in server
610+
//
611+
// k - votekick enabled via vote command
612+
// m - votemap enabled via votemap command
613+
//
614+
// Set to "0" to disable voting systems
615+
//
616+
// Default value: "km"
617+
mp_vote_flags "km"
618+
619+
// Minimum seconds that must elapse on map before votemap command can be used
620+
//
621+
// Default value: "180"
622+
mp_votemap_min_time "180"

regamedll/dlls/client.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2627,6 +2627,15 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa
26272627
return;
26282628
}
26292629

2630+
#ifdef REGAMEDLL_ADD
2631+
static const int flagKick = UTIL_ReadFlags("k");
2632+
if ((flagKick & UTIL_ReadFlags(vote_flags.string)) == 0)
2633+
{
2634+
ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Command_Not_Available");
2635+
return;
2636+
}
2637+
#endif
2638+
26302639
pPlayer->m_flNextVoteTime = gpGlobals->time + 3;
26312640

26322641
if (pPlayer->m_iTeam != UNASSIGNED)
@@ -2708,11 +2717,20 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa
27082717
return;
27092718
}
27102719

2720+
#ifdef REGAMEDLL_ADD
2721+
static const int flagMap = UTIL_ReadFlags("m");
2722+
if ((flagMap & UTIL_ReadFlags(vote_flags.string)) == 0)
2723+
{
2724+
ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Command_Not_Available");
2725+
return;
2726+
}
2727+
#endif
2728+
27112729
pPlayer->m_flNextVoteTime = gpGlobals->time + 3;
27122730

27132731
if (pPlayer->m_iTeam != UNASSIGNED)
27142732
{
2715-
if (gpGlobals->time < 180)
2733+
if (gpGlobals->time < CGameRules::GetVotemapMinElapsedTime())
27162734
{
27172735
ClientPrint(pPlayer->pev, HUD_PRINTCONSOLE, "#Cannot_Vote_Map");
27182736
return;

regamedll/dlls/game.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ cvar_t item_respawn_time = { "mp_item_respawn_time", "30", FCVAR_SERVER, 3
185185
cvar_t weapon_respawn_time = { "mp_weapon_respawn_time", "20", FCVAR_SERVER, 20.0f, nullptr };
186186
cvar_t ammo_respawn_time = { "mp_ammo_respawn_time", "20", FCVAR_SERVER, 20.0f, nullptr };
187187

188+
cvar_t vote_flags = { "mp_vote_flags", "km", 0, 0.0f, nullptr };
189+
cvar_t votemap_min_time = { "mp_votemap_min_time", "180", 0, 180.0f, nullptr };
190+
188191
void GameDLL_Version_f()
189192
{
190193
if (Q_stricmp(CMD_ARGV(1), "version") != 0)
@@ -454,6 +457,9 @@ void EXT_FUNC GameDLLInit()
454457
CVAR_REGISTER(&weapon_respawn_time);
455458
CVAR_REGISTER(&ammo_respawn_time);
456459

460+
CVAR_REGISTER(&vote_flags);
461+
CVAR_REGISTER(&votemap_min_time);
462+
457463
// print version
458464
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");
459465

regamedll/dlls/game.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,11 @@ extern cvar_t freezetime_jump;
203203
extern cvar_t defuser_allocation;
204204
extern cvar_t location_area_info;
205205
extern cvar_t chat_loc_fallback;
206-
207206
extern cvar_t item_respawn_time;
208207
extern cvar_t weapon_respawn_time;
209208
extern cvar_t ammo_respawn_time;
209+
extern cvar_t vote_flags;
210+
extern cvar_t votemap_min_time;
210211

211212
#endif
212213

regamedll/dlls/gamerules.h

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,29 @@
3131
#include "game_shared/voice_gamemgr.h"
3232
#include "cmdhandler.h"
3333

34-
const int MAX_RULE_BUFFER = 1024;
35-
const int MAX_VOTE_MAPS = 100;
36-
const int MAX_VIP_QUEUES = 5;
37-
const int MAX_MONEY_THRESHOLD = 999999; // allowable money limit in the game that can be drawn on the HUD
38-
39-
const int MAX_MOTD_CHUNK = 60;
40-
const int MAX_MOTD_LENGTH = 1536; // (MAX_MOTD_CHUNK * 4)
41-
42-
const float ITEM_RESPAWN_TIME = 30.0f;
43-
const float WEAPON_RESPAWN_TIME = 20.0f;
44-
const float AMMO_RESPAWN_TIME = 20.0f;
45-
const float ROUND_RESPAWN_TIME = 20.0f;
46-
const float ROUND_BEGIN_DELAY = 5.0f; // delay before beginning new round
47-
const float ITEM_KILL_DELAY = 300.0f;
48-
const float RADIO_TIMEOUT = 1.5f;
34+
const int MAX_RULE_BUFFER = 1024;
35+
const int MAX_VOTE_MAPS = 100;
36+
const int MAX_VIP_QUEUES = 5;
37+
const int MAX_MONEY_THRESHOLD = 999999; // allowable money limit in the game that can be drawn on the HUD
38+
39+
const int MAX_MOTD_CHUNK = 60;
40+
const int MAX_MOTD_LENGTH = 1536; // (MAX_MOTD_CHUNK * 4)
41+
42+
const float ITEM_RESPAWN_TIME = 30.0f;
43+
const float WEAPON_RESPAWN_TIME = 20.0f;
44+
const float AMMO_RESPAWN_TIME = 20.0f;
45+
const float ROUND_RESPAWN_TIME = 20.0f;
46+
const float ROUND_BEGIN_DELAY = 5.0f; // delay before beginning new round
47+
const float ITEM_KILL_DELAY = 300.0f;
48+
const float RADIO_TIMEOUT = 1.5f;
4949
const float DEATH_ANIMATION_TIME = 3.0f;
50+
const float VOTEMAP_MIN_TIME = 180.0f;
5051

51-
const int MAX_INTERMISSION_TIME = 120; // longest the intermission can last, in seconds
52+
const int MAX_INTERMISSION_TIME = 120; // longest the intermission can last, in seconds
5253

5354
// when we are within this close to running out of entities, items
5455
// marked with the ITEM_FLAG_LIMITINWORLD will delay their respawn
55-
const int ENTITY_INTOLERANCE = 100;
56+
const int ENTITY_INTOLERANCE = 100;
5657

5758
enum
5859
{
@@ -381,6 +382,7 @@ class CGameRules
381382
static float GetItemKillDelay();
382383
static float GetRadioTimeout();
383384
static float GetDyingTime();
385+
static float GetVotemapMinElapsedTime();
384386

385387
public:
386388
BOOL m_bFreezePeriod; // TRUE at beginning of round, set to FALSE when the period expires
@@ -986,6 +988,15 @@ inline float CGameRules::GetDyingTime()
986988
#endif
987989
}
988990

991+
inline float CGameRules::GetVotemapMinElapsedTime()
992+
{
993+
#ifdef REGAMEDLL_ADD
994+
return votemap_min_time.value;
995+
#else
996+
return VOTEMAP_MIN_TIME;
997+
#endif
998+
}
999+
9891000
bool IsBotSpeaking();
9901001
void SV_Continue_f();
9911002
void SV_Tutor_Toggle_f();

0 commit comments

Comments
 (0)