diff --git a/MakoVote/scripting/MakoVote.sp b/MakoVote/scripting/MakoVote.sp index 15e8cdc..ebbdb9b 100644 --- a/MakoVote/scripting/MakoVote.sp +++ b/MakoVote/scripting/MakoVote.sp @@ -7,16 +7,7 @@ #pragma semicolon 1 #pragma newdecls required -public Plugin myinfo = -{ - name = "MakoVoteSystem", - author = "Neon", - description = "MakoVoteSystem", - version = "1.1", - url = "https://steamcommunity.com/id/n3ontm" -} - -#define NUMBEROFSTAGES 6 +#define NUMBEROFSTAGES 7 bool g_bVoteFinished = true; bool g_bIsRevote = false; @@ -24,13 +15,15 @@ bool g_bStartVoteNextRound = false; bool g_bPlayedZM = false; 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 (Heal + Ultima)", "Extreme 3 (ZED)", "Extreme 3 (Hellz)", "Race Mode", "Zombie Mode", "Extreme 4 RMZS", "Ext2 Special Lasers"}; int g_Winnerstage; Handle g_VoteMenu = INVALID_HANDLE; Handle g_StageList = INVALID_HANDLE; Handle g_CountdownTimer = INVALID_HANDLE; +bool g_bCorrectMap = false; + //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -57,6 +50,7 @@ public void OnPluginStart() //---------------------------------------------------------------------------------------------------- public void OnMapStart() { + g_bCorrectMap = false; VerifyMap(); g_bStartVoteNextRound = false; @@ -76,17 +70,22 @@ public Action VerifyMap() if (!StrEqual(currentMap, "ze_ffvii_mako_reactor_v5_3", false)) { + //plugin unloading can make map switches very slow + /* char sFilename[256]; GetPluginFilename(INVALID_HANDLE, sFilename, sizeof(sFilename)); ServerCommand("sm plugins unload %s", sFilename); + */ } else { + g_bCorrectMap = true; PrecacheSound("#unloze/Pendulum - Witchcraft.mp3", true); AddFileToDownloadsTable("sound/unloze/Pendulum - Witchcraft.mp3"); } + return Plugin_Handled; } //---------------------------------------------------------------------------------------------------- @@ -94,6 +93,10 @@ public Action VerifyMap() //---------------------------------------------------------------------------------------------------- public void OnEntitySpawned(int iEntity, const char[] sClassname) { + if (!g_bCorrectMap) + { + return; + } if (!IsValidEntity(iEntity) || g_bVoteFinished) return; @@ -109,6 +112,10 @@ public void OnEntitySpawned(int iEntity, const char[] sClassname) //---------------------------------------------------------------------------------------------------- public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast) { + if (!g_bCorrectMap) + { + return; + } if (g_bStartVoteNextRound) { g_bVoteFinished = false; @@ -160,9 +167,12 @@ public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast) if (iButton5 != INVALID_ENT_REFERENCE) AcceptEntityInput(iButton5, "Lock"); - int iCounter = FindEntityByTargetname(INVALID_ENT_REFERENCE, "LevelCounter", "math_counter"); + //its now a permanent entity so really dont kill it. + /* + int iCounter = FindEntityByTargetname(INVALID_ENT_REFERENCE, "LevelCounter", "info_target"); if (iCounter != INVALID_ENT_REFERENCE) AcceptEntityInput(iCounter, "Kill"); + */ int iFilter = FindEntityByTargetname(INVALID_ENT_REFERENCE, "humanos", "filter_activator_team"); if (iFilter != INVALID_ENT_REFERENCE) @@ -245,6 +255,10 @@ public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast) //---------------------------------------------------------------------------------------------------- public void GenerateArray() { + if (!g_bCorrectMap) + { + return; + } int iBlockSize = ByteCountToCells(PLATFORM_MAX_PATH); g_StageList = CreateArray(iBlockSize); @@ -270,6 +284,11 @@ public void GenerateArray() //---------------------------------------------------------------------------------------------------- public Action Command_StartVote(int args) { + if (!g_bCorrectMap) + { + return Plugin_Handled; + } + int iCurrentStage = GetCurrentStage(); if (iCurrentStage > 0) @@ -302,6 +321,10 @@ public Action Command_StartVote(int args) //---------------------------------------------------------------------------------------------------- public Action StartVote(Handle timer) { + if (!g_bCorrectMap) + { + return Plugin_Handled; + } static int iCountDown = 5; PrintCenterTextAll("[MakoVote] Starting Vote in %ds", iCountDown); @@ -312,6 +335,7 @@ public Action StartVote(Handle timer) g_CountdownTimer = INVALID_HANDLE; InitiateVote(); } + return Plugin_Handled; } //---------------------------------------------------------------------------------------------------- @@ -319,6 +343,10 @@ public Action StartVote(Handle timer) //---------------------------------------------------------------------------------------------------- public void InitiateVote() { + if (!g_bCorrectMap) + { + return; + } if(IsVoteInProgress()) { CPrintToChatAll("{green}[Mako Vote] {white}Another vote is currently in progress, retrying again in 5s."); @@ -347,7 +375,7 @@ public void InitiateVote() } } - SetMenuOptionFlags(g_VoteMenu, MENUFLAG_BUTTON_NOVOTE); + //SetMenuOptionFlags(g_VoteMenu, MENUFLAG_BUTTON_NOVOTE); SetMenuTitle(g_VoteMenu, "What stage to play next?"); SetVoteResultCallback(g_VoteMenu, Handler_SettingsVoteFinished); VoteMenuToAll(g_VoteMenu, 20); @@ -358,6 +386,10 @@ public void InitiateVote() //---------------------------------------------------------------------------------------------------- public int Handler_MakoVoteMenu(Handle menu, MenuAction action, int param1, int param2) { + if (!g_bCorrectMap) + { + return 0; + } switch(action) { case MenuAction_End: @@ -385,10 +417,15 @@ public int MenuHandler_NotifyPanel(Menu hMenu, MenuAction iAction, int iParam1, case MenuAction_Select, MenuAction_Cancel: delete hMenu; } + return 0; } public void Handler_SettingsVoteFinished(Handle menu, int num_votes, int num_clients, const int[][] client_info, int num_items, const int[][] item_info) { + if (!g_bCorrectMap) + { + return; + } int highest_votes = item_info[0][VOTEINFO_ITEM_VOTES]; int required_percent = 60; int required_votes = RoundToCeil(float(num_votes) * float(required_percent) / 100); @@ -416,6 +453,10 @@ public void Handler_SettingsVoteFinished(Handle menu, int num_votes, int num_cli public void Handler_VoteFinishedGeneric(Handle menu, int num_votes, int num_clients, const int[][] client_info, int num_items, const int[][] item_info) { + if (!g_bCorrectMap) + { + return; + } g_bVoteFinished = true; char sWinner[128]; GetMenuItem(menu, item_info[0][VOTEINFO_ITEM_INDEX], sWinner, sizeof(sWinner)); @@ -429,7 +470,42 @@ public void Handler_VoteFinishedGeneric(Handle menu, int num_votes, int num_clie g_Winnerstage = i; } - ServerCommand("sm_stage %d", (g_Winnerstage + 4)); + //ServerCommand("sm_stage %d", (g_Winnerstage + 4)); + char winner_stage[64]; + if (StrEqual(sWinner, "Extreme 3 (Hellz)")) + { + Format(winner_stage, sizeof(winner_stage), "hellz"); + } + else if (StrEqual(sWinner, "Extreme 2")) + { + Format(winner_stage, sizeof(winner_stage), "extreme2"); + } + else if (StrEqual(sWinner, "Extreme 2 (Heal + Ultima)")) + { + Format(winner_stage, sizeof(winner_stage), "ultiheal"); + } + else if (StrEqual(sWinner, "Extreme 3 (ZED)")) + { + Format(winner_stage, sizeof(winner_stage), "zombieden"); + } + else if (StrEqual(sWinner, "Race Mode")) + { + Format(winner_stage, sizeof(winner_stage), "race"); + } + else if (StrEqual(sWinner, "Zombie Mode")) + { + Format(winner_stage, sizeof(winner_stage), "zm"); + } + else if (StrEqual(sWinner, "Extreme 4 RMZS")) + { + Format(winner_stage, sizeof(winner_stage), "rmzs"); + } + else if (StrEqual(sWinner, "Ext2 Special Lasers")) + { + Format(winner_stage, sizeof(winner_stage), "laser"); + } + + ServerCommand("sm_stage %s", winner_stage); float fDelay = 3.0; CS_TerminateRound(fDelay, CSRoundEnd_GameStart, false); @@ -437,7 +513,13 @@ public void Handler_VoteFinishedGeneric(Handle menu, int num_votes, int num_clie public int GetCurrentStage() { - int iLevelCounterEnt = FindEntityByTargetname(INVALID_ENT_REFERENCE, "LevelCounter", "math_counter"); + if (!g_bCorrectMap) + { + return 0; + } + //int iLevelCounterEnt = FindEntityByTargetname(INVALID_ENT_REFERENCE, "LevelCounter", "math_counter"); + //due to the stripper its now an info_target and not math_counter. + int iLevelCounterEnt = FindEntityByTargetname(INVALID_ENT_REFERENCE, "LevelCounter", "info_target"); int offset = FindDataMapInfo(iLevelCounterEnt, "m_OutValue"); int iCounterVal = RoundFloat(GetEntDataFloat(iLevelCounterEnt, offset)); @@ -463,6 +545,10 @@ public int GetCurrentStage() public int FindEntityByTargetname(int entity, const char[] sTargetname, const char[] sClassname) { + if (!g_bCorrectMap) + { + return 0; + } if(sTargetname[0] == '#') // HammerID { int HammerID = StringToInt(sTargetname[1]); @@ -488,4 +574,4 @@ public int FindEntityByTargetname(int entity, const char[] sTargetname, const ch } } return INVALID_ENT_REFERENCE; -} \ No newline at end of file +}