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

View File

@ -1,77 +0,0 @@
"MapchooserSoundsList"
{
"tf"
{
"counter"
{
"1"
{
"sound" "sourcemod/mapchooser/tf2/announcer_begins_1sec.mp3"
"builtin" "vo/announcer_begins_1sec.wav"
"event" "Announcer.RoundBegins1Seconds"
}
"2"
{
"sound" "sourcemod/mapchooser/tf2/announcer_begins_2sec.mp3"
"builtin" "vo/announcer_begins_2sec.wav"
"event" "Announcer.RoundBegins2Seconds"
}
"3"
{
"sound" "sourcemod/mapchooser/tf2/announcer_begins_3sec.mp3"
"builtin" "vo/announcer_begins_3sec.wav"
"event" "Announcer.RoundBegins3Seconds"
}
"4"
{
"sound" "sourcemod/mapchooser/tf2/announcer_begins_4sec.mp3"
"builtin" "vo/announcer_begins_4sec.wav"
"event" "Announcer.RoundBegins4Seconds"
}
"5"
{
"sound" "sourcemod/mapchooser/tf2/announcer_begins_5sec.mp3"
"builtin" "vo/announcer_begins_5sec.wav"
"event" "Announcer.RoundBegins5Seconds"
}
"10"
{
"sound" "sourcemod/mapchooser/tf2/announcer_dec_missionbegins10s01.mp3"
"builtin" "vo/announcer_dec_missionbegins10s01.wav"
}
"30"
{
"sound" "sourcemod/mapchooser/tf2/announcer_dec_missionbegins30s01.mp3"
"builtin" "vo/announcer_dec_missionbegins30s01.wav"
}
"60"
{
"sound" "sourcemod/mapchooser/tf2/announcer_dec_missionbegins60s06.mp3"
"builtin" "vo/announcer_dec_missionbegins60s06.wav"
}
}
"vote start"
{
"sound" "sourcemod/mapchooser/tf2/vote_started.mp3"
"event" "Vote.Created"
"builtin" "ui/vote_started.wav"
}
"vote end"
{
"sound" "sourcemod/mapchooser/tf2/vote_success.mp3"
"event" "Vote.Passed"
"builtin" "ui/vote_success.wav"
}
"vote warning"
{
"sound" "sourcemod/mapchooser/tf2/announcer_dec_missionbegins60s03.mp3"
"builtin" "vo/announcer_dec_missionbegins60s03.wav"
}
"runoff warning"
{
"sound" "sourcemod/mapchooser/tf2/vote_failure.mp3"
"event" "Vote.Failed"
"builtin" "ui/vote_failure.wav"
}
}
}

View File

@ -106,7 +106,7 @@ native CanNominateResult CanNominate();
* @return true on success
*/
native bool ExcludeMap(const char[] map, int cooldown = 0, int mode = 0);
// Cooldown in minutes
// Cooldown in seconds
native bool ExcludeMapTime(const char[] map, int cooldown = 0, int mode = 0);
native int GetMapCooldown(const char[] map);

View File

@ -53,7 +53,7 @@
#pragma semicolon 1
#pragma newdecls required
#define MCE_VERSION "1.2.0"
#define MCE_VERSION "1.3.0"
enum RoundCounting
{
@ -241,7 +241,7 @@ public void OnPluginStart()
g_Cvar_ExtendRoundStep = CreateConVar("mce_extend_roundstep", "5", "Specifies how many more rounds each extension makes", _, true, 1.0);
g_Cvar_ExtendFragStep = CreateConVar("mce_extend_fragstep", "10", "Specifies how many more frags are allowed when map is extended.", _, true, 5.0);
g_Cvar_ExcludeMaps = CreateConVar("mce_exclude", "5", "Specifies how many past maps to exclude from the vote.", _, true, 0.0);
g_Cvar_ExcludeMapsTime = CreateConVar("mce_exclude_time", "5", "Specifies how long in minutes an old map is excluded from the vote.", _, true, 0.0);
g_Cvar_ExcludeMapsTime = CreateConVar("mce_exclude_time", "5h", "Specifies how long in minutes an old map is excluded from the vote.");
g_Cvar_IncludeMaps = CreateConVar("mce_include", "5", "Specifies how many maps to include in the vote.", _, true, 2.0, true, 7.0);
g_Cvar_IncludeMapsReserved = CreateConVar("mce_include_reserved", "2", "Specifies how many private/random maps to include in the vote.", _, true, 0.0, true, 5.0);
g_Cvar_NoVoteMode = CreateConVar("mce_novote", "1", "Specifies whether or not MapChooser should pick a map if no votes are received.", _, true, 0.0, true, 1.0);
@ -541,7 +541,7 @@ public void OnMapEnd()
Cooldown = InternalGetMapCooldown(map);
g_OldMapList.SetValue(map, Cooldown, true);
Cooldown = InternalGetMapCooldownTime(map);
Cooldown = GetTime() + InternalGetMapCooldownTime(map);
g_TimeMapList.SetValue(map, Cooldown, true);
}
@ -1573,7 +1573,7 @@ void CreateNextVote()
GetCurrentMap(map, PLATFORM_MAX_PATH);
RemoveStringFromArray(tempMaps, map);
if(GetConVarInt(g_Cvar_ExcludeMaps) && GetArraySize(tempMaps) > GetConVarInt(g_Cvar_ExcludeMaps) && InternalAreRestrictionsActive())
if(GetArraySize(tempMaps) > GetConVarInt(g_Cvar_ExcludeMaps) && InternalAreRestrictionsActive())
{
StringMapSnapshot OldMapListSnapshot = g_OldMapList.Snapshot();
for(int i = 0; i < OldMapListSnapshot.Length; i++)
@ -1584,7 +1584,7 @@ void CreateNextVote()
delete OldMapListSnapshot;
}
if(GetConVarInt(g_Cvar_ExcludeMapsTime) && InternalAreRestrictionsActive())
if(InternalAreRestrictionsActive())
{
StringMapSnapshot TimeMapListSnapshot = g_TimeMapList.Snapshot();
for(int i = 0; i < TimeMapListSnapshot.Length; i++)
@ -2090,14 +2090,14 @@ public int Native_ExcludeMapTime(Handle plugin, int numParams)
}
else if(Mode == 1)
{
Cooldown = GetNativeCell(2) * 60;
Cooldown = GetNativeCell(2);
}
else if(Mode == 2)
{
g_TimeMapList.GetValue(map, Cooldown);
int NewCooldown = GetTime() + GetNativeCell(2) * 60;
int NewCooldown = GetTime() + GetNativeCell(2);
if(NewCooldown > Cooldown)
Cooldown = GetNativeCell(2) * 60;
Cooldown = GetNativeCell(2);
}
Cooldown += GetTime();
@ -2405,11 +2405,15 @@ stock int InternalGetMapCooldown(const char[] map)
stock int InternalGetMapCooldownTime(const char[] map)
{
int Cooldown = g_Cvar_ExcludeMapsTime.IntValue;
char time[16];
g_Cvar_ExcludeMapsTime.GetString(time, sizeof(time));
int Cooldown = TimeStrToSeconds(time);
if(g_Config && g_Config.JumpToKey(map))
{
Cooldown = g_Config.GetNum("CooldownTime", Cooldown);
g_Config.GetString("CooldownTime", time, sizeof(time), "");
Cooldown = TimeStrToSeconds(time);
g_Config.Rewind();
}
@ -2790,4 +2794,22 @@ stock void InternalStoreMapCooldowns()
}
delete Cooldowns;
}
}
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;
}

View File

@ -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;
}

View File

@ -40,7 +40,7 @@
#include <mapchooser>
#include <nextmap>
#define MCE_VERSION "1.13.0"
#define MCE_VERSION "1.3.0"
public Plugin myinfo =
{

View File

@ -106,6 +106,12 @@
"en" "*{1}"
}
"Map Cooldown Time Error"
{
"#format" "{1:d},{2:d}"
"en" "This map is on cooldown for the next {1} hours and {2} minutes."
}
"VIP Nomination"
{
"en" "VIP"