mapchooser_extended: make certain maps only available for VIPs

This commit is contained in:
neon
2018-09-22 11:49:43 +02:00
parent c4ada8e92c
commit 95e8bf6475
4 changed files with 263 additions and 3 deletions
@@ -411,6 +411,7 @@ 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);
return APLRes_Success;
}
@@ -1691,6 +1692,9 @@ void CreateNextVote()
b = GetRandomInt(0, GetArraySize(tempMaps) - 1);
GetArrayString(tempMaps, b, map, PLATFORM_MAX_PATH);
if(!InternalGetMapVIPRestriction(map))
continue;
if(InternalGetMapTimeRestriction(map) != 0)
continue;
@@ -2296,6 +2300,19 @@ public int Native_GetMapGroupRestriction(Handle plugin, int numParams)
return -1;
}
public int Native_GetMapVIPRestriction(Handle plugin, int numParams)
{
int len;
GetNativeStringLength(1, len);
if(len <= 0)
return false;
char[] map = new char[len+1];
GetNativeString(1, map, len+1);
return InternalGetMapVIPRestriction(map);
}
stock void AddMapItem(const char[] map)
{
@@ -2594,6 +2611,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()
{