ExtraCommands: cvar for round restart

This commit is contained in:
dogan 2020-08-03 15:24:52 +02:00
parent 1a0a2dd75d
commit 54f9156d3f

View File

@ -18,6 +18,7 @@ bool g_bInfAmmo[MAXPLAYERS + 1] = {false, ...};
ConVar g_CVar_sv_pausable; ConVar g_CVar_sv_pausable;
ConVar g_CVar_sv_bombanywhere; ConVar g_CVar_sv_bombanywhere;
ConVar g_CVar_sv_restartround;
static char g_sServerCanExecuteCmds[][] = { "cl_soundscape_flush", "r_screenoverlay", "playgamesound", static char g_sServerCanExecuteCmds[][] = { "cl_soundscape_flush", "r_screenoverlay", "playgamesound",
"slot0", "slot1", "slot2", "slot3", "slot4", "slot5", "slot6", "slot0", "slot1", "slot2", "slot3", "slot4", "slot5", "slot6",
@ -30,7 +31,7 @@ public Plugin myinfo =
name = "Advanced Commands", name = "Advanced Commands",
author = "BotoX + Obus", author = "BotoX + Obus",
description = "Adds extra commands for admins.", description = "Adds extra commands for admins.",
version = "2.1.4", version = "2.1.5",
url = "https://github.com/CSSZombieEscape/sm-plugins/tree/master/ExtraCommands/" url = "https://github.com/CSSZombieEscape/sm-plugins/tree/master/ExtraCommands/"
}; };
@ -71,8 +72,9 @@ public void OnPluginStart()
g_CVar_sv_pausable = FindConVar("sv_pausable"); g_CVar_sv_pausable = FindConVar("sv_pausable");
g_CVar_sv_bombanywhere = CreateConVar("sv_bombanywhere", "0", "Allows the bomb to be planted anywhere", FCVAR_NOTIFY); g_CVar_sv_bombanywhere = CreateConVar("sv_bombanywhere", "0", "Allows the bomb to be planted anywhere", FCVAR_NOTIFY);
g_CVar_sv_restartround = CreateConVar("sv_restartround", "1", "1 = restartround without slay, 0 = restartround with slay", FCVAR_NONE, true, 0.0, true, 1.0);
AutoExecConfig(true, "plugin.extracommands"); AutoExecConfig(true, "plugin.ExtraCommands");
if(g_CVar_sv_pausable) if(g_CVar_sv_pausable)
{ {
@ -1127,20 +1129,36 @@ public Action Command_SetTeamScore(int client, int argc)
public Action Command_RestartRound(int client, int argc) public Action Command_RestartRound(int client, int argc)
{ {
if(argc < 1) if(argc < 1 && g_CVar_sv_restartround.BoolValue)
{ {
CS_TerminateRound(3.0, CSRoundEnd_Draw, true); CS_TerminateRound(3.0, CSRoundEnd_Draw, true);
ShowActivity2(client, "\x01[SM] \x04", "\x01Restarted the round (3.0 seconds)"); ShowActivity2(client, "\x01[SM] \x04", "\x01Restarted the round (3.0 seconds)");
LogAction(client, -1, "\"%L\" restarted the round (3.0 seconds)", client); LogAction(client, -1, "\"%L\" restarted the round (3.0 seconds)", client);
return Plugin_Handled; return Plugin_Handled;
} }
else if(argc < 1 && !g_CVar_sv_restartround.BoolValue)
{
int iScoreZombies = GetTeamScore(CS_TEAM_T);
CreateTimer(3.0, RoundRestartSlay, iScoreZombies);
ShowActivity2(client, "\x01[SM] \x04", "\x01Restarted the round (3.0 seconds)");
LogAction(client, -1, "\"%L\" restarted the round (3.0 seconds)", client);
return Plugin_Handled;
}
char sArgs[32]; char sArgs[32];
GetCmdArg(1, sArgs, sizeof(sArgs)); GetCmdArg(1, sArgs, sizeof(sArgs));
float fDelay = StringToFloat(sArgs); float fDelay = StringToFloat(sArgs);
CS_TerminateRound(fDelay, CSRoundEnd_Draw, true); if(g_CVar_sv_restartround.BoolValue)
CS_TerminateRound(fDelay, CSRoundEnd_Draw, true);
else
{
int iScoreZombies = GetTeamScore(CS_TEAM_T);
CreateTimer(fDelay, RoundRestartSlay, iScoreZombies);
}
ShowActivity2(client, "\x01[SM] \x04", "\x01Restarted the round (%f seconds)", fDelay); ShowActivity2(client, "\x01[SM] \x04", "\x01Restarted the round (%f seconds)", fDelay);
LogAction(client, -1, "\"%L\" restarted the round (%f seconds)", client, fDelay); LogAction(client, -1, "\"%L\" restarted the round (%f seconds)", client, fDelay);
@ -1148,6 +1166,35 @@ public Action Command_RestartRound(int client, int argc)
return Plugin_Handled; return Plugin_Handled;
} }
public Action RoundRestartSlay(Handle timer, int iScoreZombies)
{
int iHumanCount;
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == CS_TEAM_CT)
{
iHumanCount++;
ForcePlayerSuicide(i);
}
}
if(iHumanCount < 1) //no humans to slay
{
CS_TerminateRound(0.1, CSRoundEnd_Draw, true);
return Plugin_Handled;
}
RequestFrame(RequestFrameCallback, iScoreZombies);
return Plugin_Handled;
}
public void RequestFrameCallback(int iScoreZombies)
{
SetTeamScore(CS_TEAM_T, iScoreZombies);
}
stock void WAILA(int client, int iEntity) stock void WAILA(int client, int iEntity)
{ {
char sModelPath[PLATFORM_MAX_PATH]; char sModelPath[PLATFORM_MAX_PATH];