From b6c2c62e8beceffa0c18310ceb9c3cc0d2bf0264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mu=C3=B1oz?= Date: Mon, 12 Aug 2024 02:45:54 -0400 Subject: [PATCH] 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 --- README.md | 3 +++ dist/game.cfg | 15 +++++++++++++ regamedll/dlls/client.cpp | 20 ++++++++++++++++- regamedll/dlls/game.cpp | 6 +++++ regamedll/dlls/game.h | 3 ++- regamedll/dlls/gamerules.h | 45 ++++++++++++++++++++++++-------------- 6 files changed, 73 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 0ad6361ae..90f58990d 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,9 @@ This means that plugins that do binary code analysis (Orpheu for example) probab | mp_item_respawn_time | 30 | 0.0 | - | The respawn time for items (such as health packs, armor, etc.). | | mp_weapon_respawn_time | 20 | 0.0 | - | The respawn time for weapons. | | mp_ammo_respawn_time | 20 | 0.0 | - | The respawn time for ammunition. | +| mp_vote_flags | km | 0 | - | Vote systems enabled in server.
`0` voting disabled
`k` votekick enabled via `vote` command
`m` votemap enabled via `votemap` command | +| mp_votemap_min_time | 180 | 0.0 | - | Minimum seconds that must elapse on map before `votemap` command can be used. | + ## How to install zBot for CS 1.6? diff --git a/dist/game.cfg b/dist/game.cfg index 96e313aa4..c5dad01c9 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -605,3 +605,18 @@ mp_weapon_respawn_time "20" // // Default value: "20" mp_ammo_respawn_time "20" + +// Vote systems enabled in server +// +// k - votekick enabled via vote command +// m - votemap enabled via votemap command +// +// Set to "0" to disable voting systems +// +// Default value: "km" +mp_vote_flags "km" + +// Minimum seconds that must elapse on map before votemap command can be used +// +// Default value: "180" +mp_votemap_min_time "180" diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 7d3fb659e..9708fa2c8 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -2627,6 +2627,15 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa return; } +#ifdef REGAMEDLL_ADD + static const int flagKick = UTIL_ReadFlags("k"); + if ((flagKick & UTIL_ReadFlags(vote_flags.string)) == 0) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Command_Not_Available"); + return; + } +#endif + pPlayer->m_flNextVoteTime = gpGlobals->time + 3; if (pPlayer->m_iTeam != UNASSIGNED) @@ -2708,11 +2717,20 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa return; } +#ifdef REGAMEDLL_ADD + static const int flagMap = UTIL_ReadFlags("m"); + if ((flagMap & UTIL_ReadFlags(vote_flags.string)) == 0) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Command_Not_Available"); + return; + } +#endif + pPlayer->m_flNextVoteTime = gpGlobals->time + 3; if (pPlayer->m_iTeam != UNASSIGNED) { - if (gpGlobals->time < 180) + if (gpGlobals->time < CGameRules::GetVotemapMinElapsedTime()) { ClientPrint(pPlayer->pev, HUD_PRINTCONSOLE, "#Cannot_Vote_Map"); return; diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index c4e303c51..789435938 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -185,6 +185,9 @@ cvar_t item_respawn_time = { "mp_item_respawn_time", "30", FCVAR_SERVER, 3 cvar_t weapon_respawn_time = { "mp_weapon_respawn_time", "20", FCVAR_SERVER, 20.0f, nullptr }; cvar_t ammo_respawn_time = { "mp_ammo_respawn_time", "20", FCVAR_SERVER, 20.0f, nullptr }; +cvar_t vote_flags = { "mp_vote_flags", "km", 0, 0.0f, nullptr }; +cvar_t votemap_min_time = { "mp_votemap_min_time", "180", 0, 180.0f, nullptr }; + void GameDLL_Version_f() { if (Q_stricmp(CMD_ARGV(1), "version") != 0) @@ -454,6 +457,9 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&weapon_respawn_time); CVAR_REGISTER(&ammo_respawn_time); + CVAR_REGISTER(&vote_flags); + CVAR_REGISTER(&votemap_min_time); + // print version CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n"); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index d0924d3a3..09da5305a 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -203,10 +203,11 @@ extern cvar_t freezetime_jump; extern cvar_t defuser_allocation; extern cvar_t location_area_info; extern cvar_t chat_loc_fallback; - extern cvar_t item_respawn_time; extern cvar_t weapon_respawn_time; extern cvar_t ammo_respawn_time; +extern cvar_t vote_flags; +extern cvar_t votemap_min_time; #endif diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h index cc6e9ec8f..a4f556ab9 100644 --- a/regamedll/dlls/gamerules.h +++ b/regamedll/dlls/gamerules.h @@ -31,28 +31,29 @@ #include "game_shared/voice_gamemgr.h" #include "cmdhandler.h" -const int MAX_RULE_BUFFER = 1024; -const int MAX_VOTE_MAPS = 100; -const int MAX_VIP_QUEUES = 5; -const int MAX_MONEY_THRESHOLD = 999999; // allowable money limit in the game that can be drawn on the HUD - -const int MAX_MOTD_CHUNK = 60; -const int MAX_MOTD_LENGTH = 1536; // (MAX_MOTD_CHUNK * 4) - -const float ITEM_RESPAWN_TIME = 30.0f; -const float WEAPON_RESPAWN_TIME = 20.0f; -const float AMMO_RESPAWN_TIME = 20.0f; -const float ROUND_RESPAWN_TIME = 20.0f; -const float ROUND_BEGIN_DELAY = 5.0f; // delay before beginning new round -const float ITEM_KILL_DELAY = 300.0f; -const float RADIO_TIMEOUT = 1.5f; +const int MAX_RULE_BUFFER = 1024; +const int MAX_VOTE_MAPS = 100; +const int MAX_VIP_QUEUES = 5; +const int MAX_MONEY_THRESHOLD = 999999; // allowable money limit in the game that can be drawn on the HUD + +const int MAX_MOTD_CHUNK = 60; +const int MAX_MOTD_LENGTH = 1536; // (MAX_MOTD_CHUNK * 4) + +const float ITEM_RESPAWN_TIME = 30.0f; +const float WEAPON_RESPAWN_TIME = 20.0f; +const float AMMO_RESPAWN_TIME = 20.0f; +const float ROUND_RESPAWN_TIME = 20.0f; +const float ROUND_BEGIN_DELAY = 5.0f; // delay before beginning new round +const float ITEM_KILL_DELAY = 300.0f; +const float RADIO_TIMEOUT = 1.5f; const float DEATH_ANIMATION_TIME = 3.0f; +const float VOTEMAP_MIN_TIME = 180.0f; -const int MAX_INTERMISSION_TIME = 120; // longest the intermission can last, in seconds +const int MAX_INTERMISSION_TIME = 120; // longest the intermission can last, in seconds // when we are within this close to running out of entities, items // marked with the ITEM_FLAG_LIMITINWORLD will delay their respawn -const int ENTITY_INTOLERANCE = 100; +const int ENTITY_INTOLERANCE = 100; enum { @@ -381,6 +382,7 @@ class CGameRules static float GetItemKillDelay(); static float GetRadioTimeout(); static float GetDyingTime(); + static float GetVotemapMinElapsedTime(); public: BOOL m_bFreezePeriod; // TRUE at beginning of round, set to FALSE when the period expires @@ -986,6 +988,15 @@ inline float CGameRules::GetDyingTime() #endif } +inline float CGameRules::GetVotemapMinElapsedTime() +{ +#ifdef REGAMEDLL_ADD + return votemap_min_time.value; +#else + return VOTEMAP_MIN_TIME; +#endif +} + bool IsBotSpeaking(); void SV_Continue_f(); void SV_Tutor_Toggle_f();