Looks good.

This commit is contained in:
BotoX
2019-09-18 16:58:30 +02:00
parent add15450df
commit 04eb96b0e2
6 changed files with 156 additions and 105 deletions
@@ -41,7 +41,7 @@
#include <multicolors>
#include <basecomm>
#define MCE_VERSION "1.13.0"
#define MCE_VERSION "1.3.0"
public Plugin myinfo =
{
@@ -112,7 +112,8 @@ 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_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> [cooldown] - 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] [mode]- Forces a map to be inserted into the recently played maps. Effectively blocking the map from being nominated.");
RegAdminCmd("sm_nominate_exclude_time", Command_AddExcludeTime, ADMFLAG_CHANGEMAP, "sm_nominate_exclude_time <mapname> [cooldown] [mode] - Forces a map to be inserted into the recently played maps. Effectively blocking the map from being nominated.");
// Nominations Extended cvars
CreateConVar("ne_version", MCE_VERSION, "Nominations Extended Version", FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);
@@ -303,10 +304,19 @@ public Action Command_Addmap(int client, int args)
}
}
int Cooldown = GetMapCooldownTime(mapname);
if(RestrictionsActive && Cooldown > GetTime())
{
int Seconds = Cooldown - GetTime();
CPrintToChat(client, "[NE] %t", "Map Cooldown Time Error", Seconds / 3600, (Seconds % 3600) / 60);
return Plugin_Handled;
}
int TimeRestriction = GetMapTimeRestriction(mapname);
if(RestrictionsActive && TimeRestriction)
{
CPrintToChat(client, "[NE] %t", "Map Nominate Time Error", RoundToFloor(float(TimeRestriction / 60)), TimeRestriction % 60);
CPrintToChat(client, "[NE] %t", "Map Nominate Time Error", TimeRestriction / 60, TimeRestriction % 60);
return Plugin_Handled;
}
@@ -387,7 +397,7 @@ public Action Command_AddExclude(int client, int args)
{
if(args < 1)
{
CReplyToCommand(client, "[NE] Usage: sm_nominate_exclude <mapname>");
CReplyToCommand(client, "[NE] Usage: sm_nominate_exclude <mapname> [cooldown] [mode]");
return Plugin_Handled;
}
@@ -427,6 +437,49 @@ public Action Command_AddExclude(int client, int args)
return Plugin_Handled;
}
public Action Command_AddExcludeTime(int client, int args)
{
if(args < 1)
{
CReplyToCommand(client, "[NE] Usage: sm_nominate_exclude_time <mapname> [cooldown] [mode]");
return Plugin_Handled;
}
static char mapname[PLATFORM_MAX_PATH];
GetCmdArg(1, mapname, sizeof(mapname));
int cooldown = 0;
int mode = 0;
if(args >= 2)
{
static char buffer[16];
GetCmdArg(2, buffer, sizeof(buffer));
cooldown = TimeStrToSeconds(buffer);
PrintToChatAll("%s -> %d", buffer, cooldown);
}
if(args >= 3)
{
static char buffer[8];
GetCmdArg(3, buffer, sizeof(buffer));
mode = StringToInt(buffer);
}
int status;
if(!GetTrieValue(g_mapTrie, mapname, status))
{
ReplyToCommand(client, "[NE] %t", "Map was not found", mapname);
return Plugin_Handled;
}
ShowActivity(client, "ExcludedTime map \"%s\" from nomination", mapname);
LogAction(client, -1, "\"%L\" excludedTime map \"%s\" from nomination", client, mapname);
// native call to mapchooser_extended
ExcludeMapTime(mapname, cooldown, mode);
return Plugin_Handled;
}
public Action Command_Say(int client, int args)
{
if(!client)
@@ -515,6 +568,15 @@ public Action Command_Nominate(int client, int args)
return Plugin_Handled;
}
int Cooldown = GetMapCooldownTime(mapname);
if(RestrictionsActive && Cooldown > GetTime())
{
int Seconds = Cooldown - GetTime();
CPrintToChat(client, "[NE] %t", "Map Cooldown Time Error", Seconds / 3600, (Seconds % 3600) / 60);
return Plugin_Handled;
}
bool VIPRestriction = GetMapVIPRestriction(mapname, client);
if(RestrictionsActive && VIPRestriction)
{
@@ -526,7 +588,7 @@ public Action Command_Nominate(int client, int args)
int TimeRestriction = GetMapTimeRestriction(mapname);
if(RestrictionsActive && TimeRestriction)
{
CPrintToChat(client, "[NE] %t", "Map Nominate Time Error", RoundToFloor(float(TimeRestriction / 60)), TimeRestriction % 60);
CPrintToChat(client, "[NE] %t", "Map Nominate Time Error", TimeRestriction / 60, TimeRestriction % 60);
return Plugin_Handled;
}
@@ -904,10 +966,20 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
}
}
int Cooldown = GetMapCooldownTime(map);
if(RestrictionsActive && Cooldown > GetTime())
{
int Seconds = Cooldown - GetTime();
char time[16];
CustomFormatTime(Seconds, time, sizeof(time));
Format(display, sizeof(display), "%s (%T %s)", buffer, "Recently Played", param1, time);
return RedrawMenuItem(display);
}
int TimeRestriction = GetMapTimeRestriction(map);
if(RestrictionsActive && TimeRestriction)
{
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "+", RoundToFloor(float(TimeRestriction / 60)), TimeRestriction % 60);
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "+", TimeRestriction / 60, TimeRestriction % 60);
return RedrawMenuItem(display);
}
@@ -957,7 +1029,7 @@ stock bool IsNominateAllowed(int client)
int VIPTimeRestriction = GetVIPTimeRestriction();
if((VIPTimeRestriction) && AreRestrictionsActive())
{
CReplyToCommand(client, "[NE] During peak hours only VIPs are allowed to nominate maps. Wait for %d hours and %d minutes or buy VIP at Unloze.com to nominate maps again.", RoundToFloor(float(VIPTimeRestriction / 60)), VIPTimeRestriction % 60);
CReplyToCommand(client, "[NE] During peak hours only VIPs are allowed to nominate maps. Wait for %d hours and %d minutes or buy VIP at Unloze.com to nominate maps again.", VIPTimeRestriction / 60, VIPTimeRestriction % 60);
return false;
}
}
@@ -1083,10 +1155,20 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
}
}
int Cooldown = GetMapCooldownTime(map);
if(RestrictionsActive && Cooldown > GetTime())
{
int Seconds = Cooldown - GetTime();
char time[16];
CustomFormatTime(Seconds, time, sizeof(time));
Format(display, sizeof(display), "%s (%T %s)", buffer, "Recently Played", param1, time);
return RedrawMenuItem(display);
}
int TimeRestriction = GetMapTimeRestriction(map);
if(RestrictionsActive && TimeRestriction)
{
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "+", RoundToFloor(float(TimeRestriction / 60)), TimeRestriction % 60);
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "+", TimeRestriction / 60, TimeRestriction % 60);
return RedrawMenuItem(display);
}
@@ -1226,9 +1308,9 @@ stock int GetVIPTimeRestriction()
MinTime = (MinTime <= MaxTime) ? MinTime + 2400 : MinTime;
// Convert our 'time' to minutes.
CurTime = (RoundToFloor(float(CurTime / 100)) * 60) + (CurTime % 100);
MinTime = (RoundToFloor(float(MinTime / 100)) * 60) + (MinTime % 100);
MaxTime = (RoundToFloor(float(MaxTime / 100)) * 60) + (MaxTime % 100);
CurTime = ((CurTime / 100) * 60) + (CurTime % 100);
MinTime = ((MinTime / 100) * 60) + (MinTime % 100);
MaxTime = ((MaxTime / 100) * 60) + (MaxTime % 100);
return MaxTime - CurTime;
}
@@ -1241,9 +1323,27 @@ stock void CustomFormatTime(int seconds, char[] buffer, int maxlen)
if(seconds <= 60)
Format(buffer, maxlen, "%ds", seconds);
else if(seconds <= 3600)
Format(buffer, maxlen, "%dm", RoundToNearest(seconds / 60));
else if(seconds <= 10*3600)
Format(buffer, maxlen, "%dh%dm", RoundToFloor(seconds / 3600), RoundToNearest((seconds % 3600) / 60));
Format(buffer, maxlen, "%dm", seconds / 60);
else if(seconds < 10*3600)
Format(buffer, maxlen, "%dh%dm", seconds / 3600, (seconds % 3600) / 60);
else
Format(buffer, maxlen, "%dh", RoundToNearest(seconds / 3600));
Format(buffer, maxlen, "%dh", seconds / 3600);
}
stock int TimeStrToSeconds(const char[] str)
{
int seconds = 0;
int maxlen = strlen(str);
for(int i = 0; i < maxlen; i++)
{
int val = 0;
i += StringToIntEx(str[i], val);
if(str[i] == 'h')
{
val *= 60;
i++;
}
seconds += val * 60;
}
return seconds;
}