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
This commit is contained in:
Francisco Muñoz 2024-08-12 02:45:54 -04:00 committed by GitHub
parent c7bd4af9b6
commit b6c2c62e8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 71 additions and 17 deletions

View File

@ -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.<br/>`0` voting disabled<br/>`k` votekick enabled via `vote` command<br/>`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. |
</details>
## How to install zBot for CS 1.6?

15
dist/game.cfg vendored
View File

@ -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"

View File

@ -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;

View File

@ -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");

View File

@ -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

View File

@ -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_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 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 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 @@ public:
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();