-Fixed MapChooser translating the last map in a vote without extend to "Extend Map"

-Added convar sm_mapvote_novote to MapChooser. Default is 1. Set to 0 and MapChooser will not set the map when no one votes
-Added convar sm_mapvote_extend. Default is 1, set to 0 and Extend option will not appear, even if the other extend cvars would allow it.
-MapChooser now sets sm_nextmap to "Vote Pending" when the map starts. (Note: If using RandomCycle as well, it will be changed to RandomCycle's choice.)
-Nextmap changed to reset sm_nextmap if it is invalid at end of map intermission

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401537
This commit is contained in:
Michael McKoy 2007-10-05 22:38:22 +00:00
parent de496cc583
commit 2173773f35
2 changed files with 41 additions and 27 deletions

View File

@ -62,6 +62,8 @@ new Handle:g_Cvar_ExtendFragStep = INVALID_HANDLE;
new Handle:g_Cvar_Mapfile = INVALID_HANDLE;
new Handle:g_Cvar_ExcludeMaps = INVALID_HANDLE;
new Handle:g_Cvar_IncludeMaps = INVALID_HANDLE;
new Handle:g_Cvar_NoVoteMode = INVALID_HANDLE;
new Handle:g_Cvar_Extend = INVALID_HANDLE;
new Handle:g_VoteTimer = INVALID_HANDLE;
new Handle:g_RetryTimer = INVALID_HANDLE;
@ -75,6 +77,8 @@ new Handle:g_TeamScores = INVALID_HANDLE;
new bool:g_HasVoteStarted;
new g_mapFileTime;
#define VOTE_EXTEND "##extend##"
public OnPluginStart()
{
LoadTranslations("mapchooser.phrases");
@ -96,6 +100,8 @@ public OnPluginStart()
g_Cvar_Mapfile = CreateConVar("sm_mapvote_file", "configs/maps.ini", "Map file to use. (Def sourcemod/configs/maps.ini)");
g_Cvar_ExcludeMaps = CreateConVar("sm_mapvote_exclude", "5", "Specifies how many past maps to exclude from the vote.", _, true, 0.0);
g_Cvar_IncludeMaps = CreateConVar("sm_mapvote_include", "5", "Specifies how many maps to include in the vote.", _, true, 2.0, true, 6.0);
g_Cvar_NoVoteMode = CreateConVar("sm_mapvote_novote", "1", "Specifies whether or not MapChooser should pick a map if no votes are received.", _, true, 0.0, true, 1.0);
g_Cvar_Extend = CreateConVar("sm_mapvote_extend", "1", "Specifies whether or not MapChooser will allow the map to be extended.", _, true, 0.0, true, 1.0);
RegAdminCmd("sm_mapvote", Command_Mapvote, ADMFLAG_CHANGEMAP, "sm_mapvote - Forces MapChooser to attempt to run a map vote now.");
@ -130,6 +136,7 @@ public OnMapStart()
{
CreateNextVote();
SetupTimeleftTimer();
SetConVarString(g_Cvar_Nextmap, "Pending Vote");
}
}
@ -309,30 +316,33 @@ InitiateVote()
AddMenuItem(g_VoteMenu, map, map);
}
new bool:allowExtend, time;
if (GetMapTimeLimit(time) && time > 0 && time < GetConVarInt(g_Cvar_ExtendTimeMax))
if (GetConVarBool(g_Cvar_Extend))
{
allowExtend = true;
}
if (g_Cvar_Winlimit != INVALID_HANDLE && GetConVarInt(g_Cvar_Winlimit) < GetConVarInt(g_Cvar_ExtendRoundMax))
{
allowExtend = true;
}
if (g_Cvar_Maxrounds != INVALID_HANDLE && GetConVarInt(g_Cvar_Maxrounds) < GetConVarInt(g_Cvar_ExtendRoundMax))
{
allowExtend = true;
}
if (g_Cvar_Fraglimit != INVALID_HANDLE && GetConVarInt(g_Cvar_Fraglimit) < GetConVarInt(g_Cvar_ExtendFragMax))
{
allowExtend = true;
}
new bool:allowExtend, time;
if (GetMapTimeLimit(time) && time > 0 && time < GetConVarInt(g_Cvar_ExtendTimeMax))
{
allowExtend = true;
}
if (allowExtend)
{
AddMenuItem(g_VoteMenu, "##extend##", "Extend Map");
if (g_Cvar_Winlimit != INVALID_HANDLE && GetConVarInt(g_Cvar_Winlimit) < GetConVarInt(g_Cvar_ExtendRoundMax))
{
allowExtend = true;
}
if (g_Cvar_Maxrounds != INVALID_HANDLE && GetConVarInt(g_Cvar_Maxrounds) < GetConVarInt(g_Cvar_ExtendRoundMax))
{
allowExtend = true;
}
if (g_Cvar_Fraglimit != INVALID_HANDLE && GetConVarInt(g_Cvar_Fraglimit) < GetConVarInt(g_Cvar_ExtendFragMax))
{
allowExtend = true;
}
if (allowExtend)
{
AddMenuItem(g_VoteMenu, VOTE_EXTEND, "Extend Map");
}
}
SetMenuExitButton(g_VoteMenu, false);
@ -367,7 +377,7 @@ public Handler_MapVoteMenu(Handle:menu, MenuAction:action, param1, param2)
{
decl String:map[64], String:buffer[255];
GetMenuItem(menu, param2, map, sizeof(map));
if (strcmp(map, "##extend##", false))
if (strcmp(map, VOTE_EXTEND, false) == 0)
{
Format(buffer, sizeof(buffer), "%T", "Extend Map", param1);
return RedrawMenuItem(buffer);
@ -389,14 +399,14 @@ public Handler_MapVoteMenu(Handle:menu, MenuAction:action, param1, param2)
case MenuAction_VoteCancel:
{
// If we receive 0 votes, pick at random.
if (param1 == VoteCancel_NoVotes)
if (param1 == VoteCancel_NoVotes && GetConVarBool(g_Cvar_NoVoteMode))
{
new count = GetMenuItemCount(menu);
new item = GetRandomInt(0, count - 1);
decl String:map[32];
GetMenuItem(menu, item, map, sizeof(map));
while (strcmp(map, "##extend##", false) == 0)
while (strcmp(map, VOTE_EXTEND, false) == 0)
{
item = GetRandomInt(0, count - 1);
GetMenuItem(menu, item, map, sizeof(map));
@ -415,7 +425,7 @@ public Handler_MapVoteMenu(Handle:menu, MenuAction:action, param1, param2)
decl String:map[32];
GetMenuItem(menu, param1, map, sizeof(map));
if (strcmp(map, "##extend##", false) == 0)
if (strcmp(map, VOTE_EXTEND, false) == 0)
{
new time;
if (GetMapTimeLimit(time))

View File

@ -223,6 +223,11 @@ public Action:UserMsg_VGUIMenu(UserMsg:msg_id, Handle:bf, const players[], playe
GetConVarString(g_Cvar_Nextmap, map, sizeof(map));
if (!IsMapValid(map))
{
GetArrayString(g_MapList, g_MapPos, map, sizeof(map));
}
if (fChatTime < 2.0)
SetConVarFloat(g_Cvar_Chattime, 2.0);
@ -311,7 +316,6 @@ FindAndSetNextMap()
{
decl String:current[64];
GetCurrentMap(current, 64);
for (new i = 0; i < mapCount; i++)
{