Skip to content

Commit

Permalink
Added mp_vote_flags and mp_votemap_min_time cvars (#990)
Browse files Browse the repository at this point in the history
* Added mp_vote_flags cvar
* Added mp_votemap_min_time cvar
* Cvars on README
* game.cfg cvars
* Ensure timers check before new restrictions
  • Loading branch information
dystopm authored Aug 12, 2024
1 parent c7bd4af commit b6c2c62
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 19 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
15 changes: 15 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
20 changes: 19 additions & 1 deletion regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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");

Expand Down
3 changes: 2 additions & 1 deletion regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
45 changes: 28 additions & 17 deletions regamedll/dlls/gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit b6c2c62

Please sign in to comment.