forked from UNLOZE/sm-plugins
Merge remote-tracking branch 'unloze/master'
and fix like everything
This commit is contained in:
@@ -130,6 +130,15 @@ native int GetMapGroups(const char[] map, int[] groups, int size);
|
||||
// >=0 = Group _max -> Group full
|
||||
native int GetMapGroupRestriction(const char[] map, int client = 0);
|
||||
|
||||
native bool GetMapVIPRestriction(const char[] map, int client = 0);
|
||||
|
||||
/**
|
||||
* Amount of Extends left on the current map
|
||||
*
|
||||
* @return amounts of extends left
|
||||
*/
|
||||
native int GetExtendsLeft();
|
||||
|
||||
public SharedPlugin __pl_mapchooser_extended =
|
||||
{
|
||||
name = "mapchooser",
|
||||
|
||||
@@ -273,6 +273,9 @@ public void OnPluginStart()
|
||||
// Mapchooser Extended Commands
|
||||
RegAdminCmd("mce_reload_maplist", Command_ReloadMaps, ADMFLAG_CHANGEMAP, "mce_reload_maplist - Reload the Official Maplist file.");
|
||||
|
||||
RegConsoleCmd("sm_extends", Command_ExtendsLeft, "sm_extends - Shows how many extends are left on the current map.");
|
||||
RegConsoleCmd("sm_extendsleft", Command_ExtendsLeft, "sm_extendsleft - Shows how many extends are left on the current map.");
|
||||
|
||||
g_Cvar_Winlimit = FindConVar("mp_winlimit");
|
||||
g_Cvar_Maxrounds = FindConVar("mp_maxrounds");
|
||||
g_Cvar_Fraglimit = FindConVar("mp_fraglimit");
|
||||
@@ -411,6 +414,8 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
||||
CreateNative("GetMapPlayerRestriction", Native_GetMapPlayerRestriction);
|
||||
CreateNative("GetMapGroups", Native_GetMapGroups);
|
||||
CreateNative("GetMapGroupRestriction", Native_GetMapGroupRestriction);
|
||||
CreateNative("GetMapVIPRestriction", Native_GetMapVIPRestriction);
|
||||
CreateNative("GetExtendsLeft", Native_GetExtendsLeft);
|
||||
|
||||
return APLRes_Success;
|
||||
}
|
||||
@@ -613,6 +618,12 @@ public Action Command_ReloadMaps(int client, int args)
|
||||
InitializeOfficialMapList();
|
||||
}
|
||||
|
||||
public Action Command_ExtendsLeft(int client, int args)
|
||||
{
|
||||
CReplyToCommand(client, "[MCE] Available Extends: %d", GetConVarInt(g_Cvar_Extend) - g_Extends);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public void OnMapTimeLeftChanged()
|
||||
{
|
||||
if(GetArraySize(g_MapList))
|
||||
@@ -1181,7 +1192,7 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
|
||||
AddMapItem(map);
|
||||
}
|
||||
|
||||
CloseHandle(randomizeList);
|
||||
delete randomizeList;
|
||||
randomizeList = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
@@ -1222,7 +1233,7 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
|
||||
AddMenuItem(g_VoteMenu, VOTE_EXTEND, "Extend Map");
|
||||
}
|
||||
}
|
||||
CloseHandle(inputlist);
|
||||
delete inputlist;
|
||||
}
|
||||
|
||||
int voteDuration = GetConVarInt(g_Cvar_VoteDuration);
|
||||
@@ -1471,7 +1482,7 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
|
||||
if(g_NativeVotes)
|
||||
NativeVotes_Close(menu);
|
||||
else
|
||||
CloseHandle(menu);
|
||||
delete menu;
|
||||
}
|
||||
|
||||
case MenuAction_Display:
|
||||
@@ -1525,6 +1536,10 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
|
||||
{
|
||||
Format(buffer, sizeof(buffer), "%T", "Custom", param1, map);
|
||||
}
|
||||
else if(InternalGetMapVIPRestriction(map))
|
||||
{
|
||||
Format(buffer, sizeof(buffer), "%s (%T)", map, "VIP Nomination", param1);
|
||||
}
|
||||
}
|
||||
|
||||
if(buffer[0] != '\0')
|
||||
@@ -1686,11 +1701,14 @@ void CreateNextVote()
|
||||
for(int i = 0; i < limit; i++)
|
||||
{
|
||||
int b;
|
||||
for(int j = 0; j < 10; j++)
|
||||
for(int j = 0; j < 1000; j++)
|
||||
{
|
||||
b = GetRandomInt(0, GetArraySize(tempMaps) - 1);
|
||||
GetArrayString(tempMaps, b, map, PLATFORM_MAX_PATH);
|
||||
|
||||
if(InternalGetMapVIPRestriction(map))
|
||||
continue;
|
||||
|
||||
if(InternalGetMapTimeRestriction(map) != 0)
|
||||
continue;
|
||||
|
||||
@@ -1730,7 +1748,7 @@ void CreateNextVote()
|
||||
}
|
||||
|
||||
delete groupmap;
|
||||
CloseHandle(tempMaps);
|
||||
delete tempMaps;
|
||||
}
|
||||
|
||||
bool CanVoteStart()
|
||||
@@ -2296,6 +2314,37 @@ public int Native_GetMapGroupRestriction(Handle plugin, int numParams)
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int Native_GetMapVIPRestriction(Handle plugin, int numParams)
|
||||
{
|
||||
int client = GetNativeCell(2);
|
||||
int len;
|
||||
GetNativeStringLength(1, len);
|
||||
|
||||
if(len <= 0)
|
||||
return false;
|
||||
|
||||
char[] map = new char[len+1];
|
||||
GetNativeString(1, map, len+1);
|
||||
|
||||
// Check if client should bypass vip restrictions
|
||||
if(client > 0 && client < MaxClients)
|
||||
{
|
||||
// Client has bypass flag, dont return vip restrictions
|
||||
if(CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_CHEATS))
|
||||
return false;
|
||||
|
||||
// Client has vip flag, dont return vip restrictions
|
||||
if(CheckCommandAccess(client, "sm_nominate_vip", ADMFLAG_CUSTOM1))
|
||||
return false;
|
||||
}
|
||||
|
||||
return InternalGetMapVIPRestriction(map);
|
||||
}
|
||||
|
||||
public int Native_GetExtendsLeft(Handle plugin, int numParams)
|
||||
{
|
||||
return GetConVarInt(g_Cvar_Extend) - g_Extends;
|
||||
}
|
||||
|
||||
stock void AddMapItem(const char[] map)
|
||||
{
|
||||
@@ -2594,6 +2643,18 @@ stock int FindIntInArray(int[] array, int size, int value)
|
||||
return -1;
|
||||
}
|
||||
|
||||
stock bool InternalGetMapVIPRestriction(const char[] map)
|
||||
{
|
||||
int VIP = 0;
|
||||
|
||||
if(g_Config && g_Config.JumpToKey(map))
|
||||
{
|
||||
VIP = g_Config.GetNum("VIP", VIP);
|
||||
g_Config.Rewind();
|
||||
}
|
||||
|
||||
return view_as<bool>(VIP);
|
||||
}
|
||||
|
||||
stock void InternalRestoreMapCooldowns()
|
||||
{
|
||||
|
||||
@@ -75,6 +75,11 @@ Handle g_Cvar_MarkCustomMaps = INVALID_HANDLE;
|
||||
Handle g_Cvar_NominateDelay = INVALID_HANDLE;
|
||||
Handle g_Cvar_InitialDelay = INVALID_HANDLE;
|
||||
|
||||
// VIP Nomination Convars
|
||||
Handle g_Cvar_VIPTimeframe = INVALID_HANDLE;
|
||||
Handle g_Cvar_VIPTimeframeMinTime = INVALID_HANDLE;
|
||||
Handle g_Cvar_VIPTimeframeMaxTime = INVALID_HANDLE;
|
||||
|
||||
int g_Player_NominationDelay[MAXPLAYERS+1];
|
||||
int g_NominationDelay;
|
||||
|
||||
@@ -94,6 +99,10 @@ public void OnPluginStart()
|
||||
g_Cvar_InitialDelay = CreateConVar("sm_nominate_initialdelay", "60.0", "Time in seconds before first Nomination can be made", 0, true, 0.00);
|
||||
g_Cvar_NominateDelay = CreateConVar("sm_nominate_delay", "3.0", "Delay between nominations", 0, true, 0.00, true, 60.00);
|
||||
|
||||
g_Cvar_VIPTimeframe = CreateConVar("sm_nominate_vip_timeframe", "1", "Specifies if the should be a timeframe where only VIPs can nominate maps", 0, true, 0.00, true, 1.0);
|
||||
g_Cvar_VIPTimeframeMinTime = CreateConVar("sm_nominate_vip_timeframe_mintime", "1800", "Start of the timeframe where only VIPs can nominate maps (Format: HHMM)", 0, true, 0000.00, true, 2359.0);
|
||||
g_Cvar_VIPTimeframeMaxTime = CreateConVar("sm_nominate_vip_timeframe_maxtime", "2200", "End of the timeframe where only VIPs can nominate maps (Format: HHMM)", 0, true, 0000.00, true, 2359.0);
|
||||
|
||||
RegConsoleCmd("say", Command_Say);
|
||||
RegConsoleCmd("say_team", Command_Say);
|
||||
|
||||
@@ -501,6 +510,14 @@ public Action Command_Nominate(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
bool VIPRestriction = GetMapVIPRestriction(mapname, client);
|
||||
if(VIPRestriction)
|
||||
{
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate VIP Error");
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
int TimeRestriction = GetMapTimeRestriction(mapname);
|
||||
if(TimeRestriction)
|
||||
{
|
||||
@@ -611,6 +628,22 @@ public int Handler_NominateListMenu(Menu menu, MenuAction action, int param1, in
|
||||
{
|
||||
delete menu;
|
||||
}
|
||||
|
||||
case MenuAction_DisplayItem:
|
||||
{
|
||||
static char display[150];
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
|
||||
bool VIPRestriction = GetMapVIPRestriction(map);
|
||||
if(VIPRestriction)
|
||||
{
|
||||
Format(display, sizeof(display), "%s (%T)", map, "VIP Nomination", param1);
|
||||
return RedrawMenuItem(display);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -716,6 +749,12 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
|
||||
GetClientName(param1, name, MAX_NAME_LENGTH);
|
||||
|
||||
if(GetMapTimeRestriction(map) || GetMapPlayerRestriction(map) || GetMapGroupRestriction(map, param1) >= 0 || GetMapVIPRestriction(map, param1))
|
||||
{
|
||||
PrintToChat(param1, "[NE] You can't nominate this map right now.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
NominateResult result = NominateMap(map, false, param1);
|
||||
|
||||
/* Don't need to check for InvalidMap because the menu did that already */
|
||||
@@ -757,7 +796,7 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
|
||||
return ITEMDRAW_DISABLED;
|
||||
|
||||
if(GetMapTimeRestriction(map) || GetMapPlayerRestriction(map) || GetMapGroupRestriction(map, param1) >= 0)
|
||||
if(GetMapTimeRestriction(map) || GetMapPlayerRestriction(map) || GetMapGroupRestriction(map, param1) >= 0 || GetMapVIPRestriction(map, param1))
|
||||
return ITEMDRAW_DISABLED;
|
||||
|
||||
return ITEMDRAW_DEFAULT;
|
||||
@@ -803,6 +842,12 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
else
|
||||
strcopy(buffer, sizeof(buffer), map);
|
||||
|
||||
bool VIPRestriction = GetMapVIPRestriction(map);
|
||||
if(VIPRestriction)
|
||||
{
|
||||
Format(buffer, sizeof(buffer), "%s (%T)", buffer, "VIP Restriction", param1);
|
||||
}
|
||||
|
||||
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
|
||||
{
|
||||
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
|
||||
@@ -829,7 +874,6 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
if(TimeRestriction)
|
||||
{
|
||||
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "+", RoundToFloor(float(TimeRestriction / 60)), TimeRestriction % 60);
|
||||
|
||||
return RedrawMenuItem(display);
|
||||
}
|
||||
|
||||
@@ -851,6 +895,11 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
return RedrawMenuItem(display);
|
||||
}
|
||||
|
||||
if(VIPRestriction)
|
||||
{
|
||||
return RedrawMenuItem(buffer);
|
||||
}
|
||||
|
||||
if(mark && !official)
|
||||
return RedrawMenuItem(buffer);
|
||||
|
||||
@@ -863,8 +912,21 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
|
||||
stock bool IsNominateAllowed(int client)
|
||||
{
|
||||
if(BaseComm_IsClientGagged(client))
|
||||
if (BaseComm_IsClientGagged(client))
|
||||
{
|
||||
CReplyToCommand(client, "[NE] You are not allowed to nominate maps while you are gagged.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CheckCommandAccess(client, "sm_tag", ADMFLAG_CUSTOM1))
|
||||
{
|
||||
int VIPTimeRestriction = GetVIPTimeRestriction();
|
||||
if(VIPTimeRestriction)
|
||||
{
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
CanNominateResult result = CanNominate();
|
||||
|
||||
@@ -1104,3 +1166,36 @@ public int Native_RemoveMapsFromNominationPool(Handle plugin, int numArgs)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
stock int GetVIPTimeRestriction()
|
||||
{
|
||||
if (!GetConVarBool(g_Cvar_VIPTimeframe))
|
||||
return 0;
|
||||
|
||||
char sTime[8];
|
||||
FormatTime(sTime, sizeof(sTime), "%H%M");
|
||||
|
||||
int CurTime = StringToInt(sTime);
|
||||
int MinTime = GetConVarInt(g_Cvar_VIPTimeframeMinTime);
|
||||
int MaxTime = GetConVarInt(g_Cvar_VIPTimeframeMaxTime);
|
||||
|
||||
//Wrap around.
|
||||
CurTime = (CurTime <= MinTime) ? CurTime + 2400 : CurTime;
|
||||
MaxTime = (MaxTime <= MinTime) ? MaxTime + 2400 : MaxTime;
|
||||
|
||||
if ((MinTime <= CurTime <= MaxTime))
|
||||
{
|
||||
//Wrap around.
|
||||
MinTime = (MinTime <= CurTime) ? MinTime + 2400 : MinTime;
|
||||
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);
|
||||
|
||||
return MaxTime - CurTime;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user