Skip to content

Commit

Permalink
Add a "cvar" to toggle rtv/extends
Browse files Browse the repository at this point in the history
  • Loading branch information
xen-000 committed Dec 3, 2023
1 parent f71136f commit 75f4385
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cfg/cs2fixes/cs2fixes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ cs2f_topdefender_enable 0 // Whether to use TopDefender
cs2f_force_ct 0 // Whether to force everyone to CTs on every new round
cs2f_block_team_messages 0 // Whether to block team join messages
cs2f_movement_unlocker_enable 0 // Whether to enable movement unlocker
cs2f_use_old_push 0 // Whether to use the old CSGO trigger_push behavior
cs2f_use_old_push 0 // Whether to use the old CSGO trigger_push behavior (Necessary for surf and other modes that heavily use ported pushes)
cs2f_hide_enable 0 // Whether to enable hide
cs2f_votemanager_enable 1 // Whether to enable votemanager features such as RTV and extends
zr_ztele_enable 0 // Whether to enable ztele

// Damage block settings
Expand Down
33 changes: 32 additions & 1 deletion src/votemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,20 @@ ERTVState g_RTVState = ERTVState::MAP_START;
EExtendState g_ExtendState = EExtendState::MAP_START;

// CONVAR_TODO
bool g_bVoteManagerEnable = false;
int g_iExtendsLeft = 1;
float g_flExtendSucceedRatio = 0.5f;
int g_iExtendTimeToAdd = 20;
float g_flRTVSucceedRatio = 0.6f;
bool g_bRTVEndRound = false;

CON_COMMAND_F(cs2f_votemanager_enable, "Whether to enable votemanager features such as RTV and extends", FCVAR_SPONLY | FCVAR_LINKED_CONCOMMAND)
{
if (args.ArgC() < 2)
Msg("%s %i\n", args[0], g_bVoteManagerEnable);
else
g_bVoteManagerEnable = V_StringToBool(args[1], false);
}
CON_COMMAND_F(cs2f_extends, "Maximum extends per map", FCVAR_SPONLY | FCVAR_LINKED_CONCOMMAND)
{
if (args.ArgC() < 2)
Expand Down Expand Up @@ -149,6 +157,9 @@ int GetNeededExtendCount()

CON_COMMAND_CHAT(rtv, "Vote to end the current map sooner.")
{
if (!g_bVoteManagerEnable)
return;

if (!player)
{
ClientPrint(player, HUD_PRINTCONSOLE, CHAT_PREFIX "You cannot use this command from the server console.");
Expand Down Expand Up @@ -246,6 +257,9 @@ CON_COMMAND_CHAT(rtv, "Vote to end the current map sooner.")

CON_COMMAND_CHAT(unrtv, "Remove your vote to end the current map sooner.")
{
if (!g_bVoteManagerEnable)
return;

if (!player)
{
ClientPrint(player, HUD_PRINTCONSOLE, CHAT_PREFIX "You cannot use this command from the server console.");
Expand Down Expand Up @@ -273,9 +287,11 @@ CON_COMMAND_CHAT(unrtv, "Remove your vote to end the current map sooner.")
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You no longer want to RTV current map.");
}


CON_COMMAND_CHAT(ve, "Vote to extend the current map.")
{
if (!g_bVoteManagerEnable)
return;

if (!player)
{
ClientPrint(player, HUD_PRINTCONSOLE, CHAT_PREFIX "You cannot use this command from the server console.");
Expand Down Expand Up @@ -393,6 +409,9 @@ CON_COMMAND_CHAT(ve, "Vote to extend the current map.")

CON_COMMAND_CHAT(unve, "Remove your vote to extend current map.")
{
if (!g_bVoteManagerEnable)
return;

if (!player)
{
ClientPrint(player, HUD_PRINTCONSOLE, CHAT_PREFIX "You cannot use this command from the server console.");
Expand Down Expand Up @@ -422,6 +441,9 @@ CON_COMMAND_CHAT(unve, "Remove your vote to extend current map.")

CON_COMMAND_CHAT_FLAGS(blockrtv, "Block the ability for players to vote to end current map sooner.", ADMFLAG_CHANGEMAP)
{
if (!g_bVoteManagerEnable)
return;

if (g_RTVState == ERTVState::BLOCKED_BY_ADMIN)
{
if (player)
Expand All @@ -440,6 +462,9 @@ CON_COMMAND_CHAT_FLAGS(blockrtv, "Block the ability for players to vote to end c

CON_COMMAND_CHAT_FLAGS(unblockrtv, "Restore the ability for players to vote to end current map sooner.", ADMFLAG_CHANGEMAP)
{
if (!g_bVoteManagerEnable)
return;

if (g_RTVState == ERTVState::RTV_ALLOWED)
{
if (player)
Expand All @@ -458,6 +483,9 @@ CON_COMMAND_CHAT_FLAGS(unblockrtv, "Restore the ability for players to vote to e

CON_COMMAND_CHAT_FLAGS(addextend, "Add another extend to the current map for players to vote.", ADMFLAG_CHANGEMAP)
{
if (!g_bVoteManagerEnable)
return;

const char* pszCommandPlayerName = player ? player->GetPlayerName() : "Console";

if (g_ExtendState == EExtendState::POST_EXTEND_NO_EXTENDS_LEFT || g_ExtendState == EExtendState::NO_EXTENDS)
Expand All @@ -470,6 +498,9 @@ CON_COMMAND_CHAT_FLAGS(addextend, "Add another extend to the current map for pla

CON_COMMAND_CHAT(extendsleft, "Display amount of extends left for the current map")
{
if (!g_bVoteManagerEnable)
return;

char message[64];

switch (g_iExtendsLeft)
Expand Down

0 comments on commit 75f4385

Please sign in to comment.