more sm_nominate_exclude functionality

This commit is contained in:
BotoX 2016-12-05 18:50:44 +01:00
parent 8c27dfa931
commit 4e804288dc
3 changed files with 48 additions and 4 deletions

View File

@ -94,7 +94,18 @@ native bool IsMapOfficial(const char[] map);
*/ */
native CanNominateResult CanNominate(); native CanNominateResult CanNominate();
native bool ExcludeMap(const char[] map); /**
* Add map to nomination exclude list.
* Known as cooldown.
*
* @param map Name of map
* @param cooldown Cooldown, interpretation depends on mode.
* @param mode 0: Normal, use cooldown value from config/default.
* 1: Set or replace cooldown with cooldown value.
* 2: Set or replace cooldown with cooldown value if greater than current cooldown.
* @return true on success
*/
native bool ExcludeMap(const char[] map, int cooldown = 0, int mode = 0);
native int GetMapCooldown(const char[] map); native int GetMapCooldown(const char[] map);
native int GetMapMinPlayers(const char[] map); native int GetMapMinPlayers(const char[] map);

View File

@ -2019,7 +2019,25 @@ public int Native_ExcludeMap(Handle plugin, int numParams)
char[] map = new char[len+1]; char[] map = new char[len+1];
GetNativeString(1, map, len+1); GetNativeString(1, map, len+1);
int Cooldown = InternalGetMapCooldown(map); int Cooldown;
int Mode = GetNativeCell(3);
if(Mode == 0)
{
Cooldown = InternalGetMapCooldown(map);
}
else if(Mode == 1)
{
Cooldown = GetNativeCell(2);
}
else if(Mode == 2)
{
g_OldMapList.GetValue(map, Cooldown);
int NewCooldown = GetNativeCell(2);
if(NewCooldown > Cooldown)
Cooldown = NewCooldown;
}
g_OldMapList.SetValue(map, Cooldown, true); g_OldMapList.SetValue(map, Cooldown, true);
return true; return true;

View File

@ -102,7 +102,7 @@ public void OnPluginStart()
RegAdminCmd("sm_nominate_addmap", Command_Addmap, ADMFLAG_CHANGEMAP, "sm_nominate_addmap <mapname> - Forces a map to be on the next mapvote."); RegAdminCmd("sm_nominate_addmap", Command_Addmap, ADMFLAG_CHANGEMAP, "sm_nominate_addmap <mapname> - Forces a map to be on the next mapvote.");
RegAdminCmd("sm_nominate_removemap", Command_Removemap, ADMFLAG_CHANGEMAP, "sm_nominate_removemap <mapname> - Removes a map from Nominations."); RegAdminCmd("sm_nominate_removemap", Command_Removemap, ADMFLAG_CHANGEMAP, "sm_nominate_removemap <mapname> - Removes a map from Nominations.");
RegAdminCmd("sm_nominate_exclude", Command_AddExclude, ADMFLAG_CHANGEMAP, "sm_nominate_exclude <mapname> - Forces a map to be inserted into the recently played maps. Effectively blocking the map from being nominated."); RegAdminCmd("sm_nominate_exclude", Command_AddExclude, ADMFLAG_CHANGEMAP, "sm_nominate_exclude <mapname> [cooldown] - Forces a map to be inserted into the recently played maps. Effectively blocking the map from being nominated.");
// Nominations Extended cvars // Nominations Extended cvars
CreateConVar("ne_version", MCE_VERSION, "Nominations Extended Version", FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD); CreateConVar("ne_version", MCE_VERSION, "Nominations Extended Version", FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);
@ -296,6 +296,21 @@ public Action Command_AddExclude(int client, int args)
static char mapname[PLATFORM_MAX_PATH]; static char mapname[PLATFORM_MAX_PATH];
GetCmdArg(1, mapname, sizeof(mapname)); GetCmdArg(1, mapname, sizeof(mapname));
int cooldown = 0;
int mode = 0;
if(args >= 2)
{
static char buffer[8];
GetCmdArg(2, buffer, sizeof(buffer));
cooldown = StringToInt(buffer);
}
if(args >= 3)
{
static char buffer[8];
GetCmdArg(3, buffer, sizeof(buffer));
mode = StringToInt(buffer);
}
int status; int status;
if(!GetTrieValue(g_mapTrie, mapname, status)) if(!GetTrieValue(g_mapTrie, mapname, status))
{ {
@ -309,7 +324,7 @@ public Action Command_AddExclude(int client, int args)
SetTrieValue(g_mapTrie, mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_PREVIOUS); SetTrieValue(g_mapTrie, mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_PREVIOUS);
// native call to mapchooser_extended // native call to mapchooser_extended
ExcludeMap(mapname); ExcludeMap(mapname, cooldown, mode);
return Plugin_Handled; return Plugin_Handled;
} }