diff --git a/Extend/scripting/Extend.sp b/Extend/scripting/Extend.sp index 5b08f7bc..d83173e3 100644 --- a/Extend/scripting/Extend.sp +++ b/Extend/scripting/Extend.sp @@ -59,9 +59,9 @@ public void OnPluginStart() { RegAdminCmd("sm_extend", Command_Extend, ADMFLAG_GENERIC, "Add more time to mp_timelimit"); RegAdminCmd("sm_extend_time", Command_Extend, ADMFLAG_GENERIC, "Add more time to mp_timelimit"); - RegAdminCmd("sm_extendvote", Command_ExtendVote, ADMFLAG_GENERIC, "Creates a vote that will increase the value of mp_timelimit by the value of sm_extendvote_time if successful"); - RegAdminCmd("sm_voteextend", Command_ExtendVote, ADMFLAG_GENERIC, "Creates a vote that will increase the value of mp_timelimit by the value of sm_extendvote_time if successful"); - RegAdminCmd("sm_extend_vote", Command_ExtendVote, ADMFLAG_GENERIC, "Creates a vote that will increase the value of mp_timelimit by the value of sm_extendvote_time if successful"); + RegAdminCmd("sm_extendvote", Command_ExtendVote, ADMFLAG_GENERIC, "sm_extendvote [time] - Start an extendvote"); + RegAdminCmd("sm_voteextend", Command_ExtendVote, ADMFLAG_GENERIC, "sm_voteextend [time] - Start an extendvote"); + RegAdminCmd("sm_extend_vote", Command_ExtendVote, ADMFLAG_GENERIC, "sm_extend_vote [time] - Start an extendvote"); } else { @@ -264,6 +264,7 @@ public Action Command_Extend(int client, int argc) return Plugin_Handled; } +int g_ExtendTime = 0; public Action Command_ExtendVote(int client, int argc) { if (IsVoteInProgress()) @@ -272,12 +273,23 @@ public Action Command_ExtendVote(int client, int argc) return Plugin_Handled; } - Menu hVoteMenu = new Menu(Handler_VoteCallback, MENU_ACTIONS_ALL); - hVoteMenu.SetTitle("Extend the current map (%d minutes)?", g_cvarExtendVoteTime.IntValue); + g_ExtendTime = g_cvarExtendVoteTime.IntValue; + if(argc == 1) + { + char sArg[64]; + GetCmdArg(1, sArg, sizeof(sArg)); + int Tmp = StringToInt(sArg); + if(Tmp > 0) + g_ExtendTime = Tmp > 30 ? 30 : Tmp; + } + + Menu hVoteMenu = new Menu(Handler_VoteCallback, MenuAction_End|MenuAction_DisplayItem|MenuAction_VoteCancel|MenuAction_VoteEnd); + hVoteMenu.SetTitle("Extend the current map (%d minutes)?", g_ExtendTime); hVoteMenu.AddItem(VOTE_YES, "Yes"); hVoteMenu.AddItem(VOTE_NO, "No"); + hVoteMenu.OptionFlags = MENUFLAG_BUTTON_NOVOTE; hVoteMenu.ExitButton = false; hVoteMenu.DisplayVoteToAll(20); @@ -319,7 +331,7 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa GetMenuVoteInfo(param2, votes, totalVotes); menu.GetItem(param1, item, sizeof(item), _, display, sizeof(display)); - if (strcmp(item, VOTE_NO) == 0 && param1 == 1) + if (strcmp(item, VOTE_NO) == 0) { votes = totalVotes - votes; } @@ -327,17 +339,17 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa limit = g_cvarExtendVotePercent.FloatValue; percent = FloatDiv(float(votes),float(totalVotes)); - if ((strcmp(item, VOTE_YES) == 0 && FloatCompare(percent, limit) < 0 && param1 == 0) || (strcmp(item, VOTE_NO) == 0 && param1 == 1)) + if ((strcmp(item, VOTE_YES) == 0 && FloatCompare(percent, limit) < 0) || strcmp(item, VOTE_NO) == 0) { LogAction(-1, -1, "Extend vote failed."); PrintToChatAll("[SM] %t", "Vote Failed", RoundToNearest(100.0 * limit), RoundToNearest(100.0 * percent), totalVotes); } else { - LogAction(-1, -1, "Extend vote successful, extending current map by \"%d\" minutes", g_cvarExtendVoteTime.IntValue); + LogAction(-1, -1, "Extend vote successful, extending current map by \"%d\" minutes", g_ExtendTime); PrintToChatAll("[SM] %t", "Vote Successful", RoundToNearest(100.0 * percent), totalVotes); - g_cvarMpTimeLimit.IntValue += g_cvarExtendVoteTime.IntValue; + g_cvarMpTimeLimit.IntValue += g_ExtendTime; CancelGameOver(); if (strcmp(item, VOTE_NO) == 0 || strcmp(item, VOTE_YES) == 0)