Add nomination pool (Obus)
This commit is contained in:
parent
0a7f08b561
commit
229fb7b8cd
@ -0,0 +1,21 @@
|
||||
#if defined _nominations_extended_included_
|
||||
#endinput
|
||||
#endif
|
||||
#define _nominations_extended_included_
|
||||
|
||||
native int GetNominationPool(ArrayList &pool);
|
||||
native int PushMapIntoNominationPool(char[] map);
|
||||
native int PushMapsIntoNominationPool(ArrayList maps);
|
||||
native int RemoveMapFromNominationPool(char[] map);
|
||||
native int RemoveMapsFromNominationPool(ArrayList maps);
|
||||
|
||||
public SharedPlugin __pl_nominations_extended =
|
||||
{
|
||||
name = "nominations",
|
||||
file = "nominations_extended.smx",
|
||||
#if defined REQUIRE_PLUGIN
|
||||
required = 1,
|
||||
#else
|
||||
required = 0,
|
||||
#endif
|
||||
};
|
@ -110,6 +110,19 @@ public void OnPluginStart()
|
||||
g_mapTrie = CreateTrie();
|
||||
}
|
||||
|
||||
public APLRes AskPluginLoad2(Handle hThis, bool bLate, char[] err, int iErrLen)
|
||||
{
|
||||
RegPluginLibrary("nominations");
|
||||
|
||||
CreateNative("GetNominationPool", Native_GetNominationPool);
|
||||
CreateNative("PushMapIntoNominationPool", Native_PushMapIntoNominationPool);
|
||||
CreateNative("PushMapsIntoNominationPool", Native_PushMapsIntoNominationPool);
|
||||
CreateNative("RemoveMapFromNominationPool", Native_RemoveMapFromNominationPool);
|
||||
CreateNative("RemoveMapsFromNominationPool", Native_RemoveMapsFromNominationPool);
|
||||
|
||||
return APLRes_Success;
|
||||
}
|
||||
|
||||
public void OnAllPluginsLoaded()
|
||||
{
|
||||
// This is an MCE cvar... this plugin requires MCE to be loaded. Granted, this plugin SHOULD have an MCE dependency.
|
||||
@ -156,11 +169,25 @@ public void OnConfigsExecuted()
|
||||
|
||||
g_NominationDelay = GetTime() + GetConVarInt(g_Cvar_InitialDelay);
|
||||
|
||||
UpdateMapTrie();
|
||||
UpdateMapMenus();
|
||||
}
|
||||
|
||||
void UpdateMapMenus()
|
||||
{
|
||||
if(g_MapMenu != INVALID_HANDLE)
|
||||
delete g_MapMenu;
|
||||
|
||||
g_MapMenu = BuildMapMenu("");
|
||||
|
||||
if(g_AdminMapMenu != INVALID_HANDLE)
|
||||
delete g_AdminMapMenu;
|
||||
|
||||
g_AdminMapMenu = BuildAdminMapMenu("");
|
||||
}
|
||||
|
||||
void UpdateMapTrie()
|
||||
{
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
static char currentMap[PLATFORM_MAX_PATH];
|
||||
ArrayList excludeMaps;
|
||||
@ -175,6 +202,7 @@ public void OnConfigsExecuted()
|
||||
GetCurrentMap(currentMap, sizeof(currentMap));
|
||||
|
||||
ClearTrie(g_mapTrie);
|
||||
|
||||
for(int i = 0; i < GetArraySize(g_MapList); i++)
|
||||
{
|
||||
int status = MAPSTATUS_ENABLED;
|
||||
@ -199,11 +227,6 @@ public void OnConfigsExecuted()
|
||||
|
||||
if(excludeMaps)
|
||||
delete excludeMaps;
|
||||
|
||||
if(g_AdminMapMenu != INVALID_HANDLE)
|
||||
delete g_AdminMapMenu;
|
||||
|
||||
g_AdminMapMenu = BuildAdminMapMenu("");
|
||||
}
|
||||
|
||||
public void OnNominationRemoved(const char[] map, int owner)
|
||||
@ -597,7 +620,9 @@ Menu BuildMapMenu(const char[] filter)
|
||||
GetArrayString(g_MapList, i, map, sizeof(map));
|
||||
|
||||
if(!filter[0] || StrContains(map, filter, false) != -1)
|
||||
{
|
||||
AddMenuItem(menu, map, map);
|
||||
}
|
||||
}
|
||||
|
||||
SetMenuExitButton(menu, true);
|
||||
@ -945,3 +970,89 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int Native_GetNominationPool(Handle plugin, int numArgs)
|
||||
{
|
||||
SetNativeCellRef(1, g_MapList);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int Native_PushMapIntoNominationPool(Handle plugin, int numArgs)
|
||||
{
|
||||
char map[PLATFORM_MAX_PATH];
|
||||
|
||||
GetNativeString(1, map, PLATFORM_MAX_PATH);
|
||||
|
||||
ShiftArrayUp(g_MapList, 0);
|
||||
SetArrayString(g_MapList, 0, map);
|
||||
|
||||
UpdateMapTrie();
|
||||
UpdateMapMenus();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int Native_PushMapsIntoNominationPool(Handle plugin, int numArgs)
|
||||
{
|
||||
ArrayList maps = GetNativeCell(1);
|
||||
|
||||
for (int i = 0; i < maps.Length; i++)
|
||||
{
|
||||
char map[PLATFORM_MAX_PATH];
|
||||
maps.GetString(i, map, PLATFORM_MAX_PATH);
|
||||
|
||||
if (FindStringInArray(g_MapList, map) == -1)
|
||||
{
|
||||
ShiftArrayUp(g_MapList, 0);
|
||||
SetArrayString(g_MapList, 0, map);
|
||||
}
|
||||
}
|
||||
|
||||
delete maps;
|
||||
|
||||
UpdateMapTrie();
|
||||
UpdateMapMenus();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int Native_RemoveMapFromNominationPool(Handle plugin, int numArgs)
|
||||
{
|
||||
char map[PLATFORM_MAX_PATH];
|
||||
|
||||
GetNativeString(1, map, PLATFORM_MAX_PATH);
|
||||
|
||||
int idx;
|
||||
|
||||
if ((idx = FindStringInArray(g_MapList, map)) != -1)
|
||||
RemoveFromArray(g_MapList, idx);
|
||||
|
||||
UpdateMapTrie();
|
||||
UpdateMapMenus();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int Native_RemoveMapsFromNominationPool(Handle plugin, int numArgs)
|
||||
{
|
||||
ArrayList maps = GetNativeCell(1);
|
||||
|
||||
for (int i = 0; i < maps.Length; i++)
|
||||
{
|
||||
char map[PLATFORM_MAX_PATH];
|
||||
maps.GetString(i, map, PLATFORM_MAX_PATH);
|
||||
|
||||
int idx = -1;
|
||||
|
||||
if ((idx = FindStringInArray(g_MapList, map)) != -1)
|
||||
RemoveFromArray(g_MapList, idx);
|
||||
}
|
||||
|
||||
delete maps;
|
||||
|
||||
UpdateMapTrie();
|
||||
UpdateMapMenus();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user