MakoVote: chance of forced ZM round

This commit is contained in:
neon 2019-11-14 11:05:59 +01:00
parent 28a41a57d6
commit 809a89c8ae

View File

@ -20,7 +20,8 @@ public Plugin myinfo =
bool g_bVoteFinished = true; bool g_bVoteFinished = true;
bool g_bIsRevote = false; bool g_bIsRevote = false;
bool bStartVoteNextRound = false; bool g_bStartVoteNextRound = false;
bool g_bPlayedZM = false;
bool g_bOnCooldown[NUMBEROFSTAGES]; bool g_bOnCooldown[NUMBEROFSTAGES];
static char g_sStageName[NUMBEROFSTAGES][32] = {"Extreme 2", "Extreme 2 (Heal + Ultima)", "Extreme 3 (ZED)", "Extreme 3 (Hellz)", "Race Mode", "Zombie Mode"}; static char g_sStageName[NUMBEROFSTAGES][32] = {"Extreme 2", "Extreme 2 (Heal + Ultima)", "Extreme 3 (ZED)", "Extreme 3 (Hellz)", "Race Mode", "Zombie Mode"};
@ -30,22 +31,44 @@ Handle g_VoteMenu = INVALID_HANDLE;
Handle g_StageList = INVALID_HANDLE; Handle g_StageList = INVALID_HANDLE;
Handle g_CountdownTimer = INVALID_HANDLE; Handle g_CountdownTimer = INVALID_HANDLE;
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
name = "MakoVoteSystem",
author = "Neon",
description = "MakoVoteSystem",
version = "1.3",
url = "https://steamcommunity.com/id/n3ontm"
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart() public void OnPluginStart()
{ {
RegServerCmd("sm_makovote", Command_StartVote); RegServerCmd("sm_makovote", Command_StartVote);
HookEvent("round_start", OnRoundStart); HookEvent("round_start", OnRoundStart);
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnMapStart() public void OnMapStart()
{ {
VerifyMap(); VerifyMap();
bStartVoteNextRound = false; g_bStartVoteNextRound = false;
g_bPlayedZM = false;
for (int i = 0; i < NUMBEROFSTAGES; i++) for (int i = 0; i < NUMBEROFSTAGES; i++)
g_bOnCooldown[i] = false; g_bOnCooldown[i] = false;
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action VerifyMap() public Action VerifyMap()
{ {
char currentMap[64]; char currentMap[64];
@ -66,6 +89,9 @@ public Action VerifyMap()
} }
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnEntitySpawned(int iEntity, const char[] sClassname) public void OnEntitySpawned(int iEntity, const char[] sClassname)
{ {
if (!IsValidEntity(iEntity) || g_bVoteFinished) if (!IsValidEntity(iEntity) || g_bVoteFinished)
@ -78,12 +104,34 @@ public void OnEntitySpawned(int iEntity, const char[] sClassname)
AcceptEntityInput(iEntity, "Kill"); AcceptEntityInput(iEntity, "Kill");
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast) public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
{ {
if (bStartVoteNextRound) if (g_bStartVoteNextRound)
{ {
g_bVoteFinished = false;
if (!g_bPlayedZM)
{
CPrintToChatAll("{green}[Mako Vote] {white}ZM has not been played yet. Rolling the dice...");
if (GetRandomInt(1, 100) <= 35)
{
CPrintToChatAll("{green}[Mako Vote] {white}Result: ZM, restarting round.");
ServerCommand("sm_stage zm");
g_bVoteFinished = true;
g_bStartVoteNextRound = false;
g_bPlayedZM = true;
CS_TerminateRound(1.0, CSRoundEnd_GameStart, false);
return;
}
CPrintToChatAll("{green}[Mako Vote] {white}Result: Normal vote");
}
else
CPrintToChatAll("{green}[Mako Vote] {white}ZM already has been played. Starting normal vote.");
g_CountdownTimer = CreateTimer(1.0, StartVote, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); g_CountdownTimer = CreateTimer(1.0, StartVote, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
bStartVoteNextRound = false; g_bStartVoteNextRound = false;
} }
if (!(g_bVoteFinished)) if (!(g_bVoteFinished))
@ -192,6 +240,9 @@ public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
} }
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void GenerateArray() public void GenerateArray()
{ {
int iBlockSize = ByteCountToCells(PLATFORM_MAX_PATH); int iBlockSize = ByteCountToCells(PLATFORM_MAX_PATH);
@ -214,6 +265,9 @@ public void GenerateArray()
} }
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_StartVote(int args) public Action Command_StartVote(int args)
{ {
int iCurrentStage = GetCurrentStage(); int iCurrentStage = GetCurrentStage();
@ -221,6 +275,9 @@ public Action Command_StartVote(int args)
if (iCurrentStage > 0) if (iCurrentStage > 0)
g_bOnCooldown[iCurrentStage] = true; g_bOnCooldown[iCurrentStage] = true;
if (iCurrentStage == 5)
g_bPlayedZM = true;
int iOnCD = 0; int iOnCD = 0;
for (int i = 0; i < NUMBEROFSTAGES; i++) for (int i = 0; i < NUMBEROFSTAGES; i++)
{ {
@ -234,13 +291,15 @@ public Action Command_StartVote(int args)
g_bOnCooldown[i] = false; g_bOnCooldown[i] = false;
} }
g_bVoteFinished = false;
GenerateArray(); GenerateArray();
bStartVoteNextRound = true; g_bStartVoteNextRound = true;
return Plugin_Handled; return Plugin_Handled;
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action StartVote(Handle timer) public Action StartVote(Handle timer)
{ {
static int iCountDown = 5; static int iCountDown = 5;
@ -255,6 +314,9 @@ public Action StartVote(Handle timer)
} }
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void InitiateVote() public void InitiateVote()
{ {
if(IsVoteInProgress()) if(IsVoteInProgress())
@ -291,6 +353,9 @@ public void InitiateVote()
VoteMenuToAll(g_VoteMenu, 20); VoteMenuToAll(g_VoteMenu, 20);
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public int Handler_MakoVoteMenu(Handle menu, MenuAction action, int param1, int param2) public int Handler_MakoVoteMenu(Handle menu, MenuAction action, int param1, int param2)
{ {
switch(action) switch(action)
@ -310,6 +375,9 @@ public int Handler_MakoVoteMenu(Handle menu, MenuAction action, int param1, int
return 0; return 0;
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public int MenuHandler_NotifyPanel(Menu hMenu, MenuAction iAction, int iParam1, int iParam2) public int MenuHandler_NotifyPanel(Menu hMenu, MenuAction iAction, int iParam1, int iParam2)
{ {
switch (iAction) switch (iAction)