added feature to hide maps that are unavailable
This commit is contained in:
parent
e094ed41aa
commit
d21303488b
@ -83,43 +83,153 @@ Handle g_Cvar_VIPTimeframeMaxTime = INVALID_HANDLE;
|
||||
int g_Player_NominationDelay[MAXPLAYERS+1];
|
||||
int g_NominationDelay;
|
||||
|
||||
//clients ignoring maps that are unavailable
|
||||
bool g_bClientsIgnoring[MAXPLAYERS + 1];
|
||||
Database g_dDatabase;
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
LoadTranslations("common.phrases");
|
||||
LoadTranslations("nominations.phrases");
|
||||
LoadTranslations("basetriggers.phrases"); // for Next Map phrase
|
||||
LoadTranslations("mapchooser_extended.phrases");
|
||||
LoadTranslations("common.phrases");
|
||||
LoadTranslations("nominations.phrases");
|
||||
LoadTranslations("basetriggers.phrases"); // for Next Map phrase
|
||||
LoadTranslations("mapchooser_extended.phrases");
|
||||
|
||||
int arraySize = ByteCountToCells(PLATFORM_MAX_PATH);
|
||||
g_MapList = CreateArray(arraySize);
|
||||
g_AdminMapList = CreateArray(arraySize);
|
||||
int arraySize = ByteCountToCells(PLATFORM_MAX_PATH);
|
||||
g_MapList = CreateArray(arraySize);
|
||||
g_AdminMapList = CreateArray(arraySize);
|
||||
|
||||
g_Cvar_ExcludeOld = CreateConVar("sm_nominate_excludeold", "1", "Specifies if the current map should be excluded from the Nominations list", 0, true, 0.00, true, 1.0);
|
||||
g_Cvar_ExcludeCurrent = CreateConVar("sm_nominate_excludecurrent", "1", "Specifies if the MapChooser excluded maps should also be excluded from Nominations", 0, true, 0.00, true, 1.0);
|
||||
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_ExcludeOld = CreateConVar("sm_nominate_excludeold", "1", "Specifies if the current map should be excluded from the Nominations list", 0, true, 0.00, true, 1.0);
|
||||
g_Cvar_ExcludeCurrent = CreateConVar("sm_nominate_excludecurrent", "1", "Specifies if the MapChooser excluded maps should also be excluded from Nominations", 0, true, 0.00, true, 1.0);
|
||||
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);
|
||||
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);
|
||||
RegConsoleCmd("say", Command_Say);
|
||||
RegConsoleCmd("say_team", Command_Say);
|
||||
|
||||
RegConsoleCmd("sm_nominate", Command_Nominate);
|
||||
RegConsoleCmd("sm_nom", Command_Nominate);
|
||||
RegConsoleCmd("sm_nomlist", Command_NominateList);
|
||||
RegConsoleCmd("sm_nominate", Command_Nominate);
|
||||
RegConsoleCmd("sm_nom", Command_Nominate);
|
||||
RegConsoleCmd("sm_nomlist", Command_NominateList);
|
||||
|
||||
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_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] [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.");
|
||||
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);
|
||||
// Nominations Extended cvars
|
||||
CreateConVar("ne_version", MCE_VERSION, "Nominations Extended Version", FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);
|
||||
|
||||
g_mapTrie = CreateTrie();
|
||||
g_mapTrie = CreateTrie();
|
||||
|
||||
//DB
|
||||
if (!g_dDatabase)
|
||||
{
|
||||
//we have too many dbs so i am just re-using racetimercss
|
||||
Database.Connect(SQL_OnDatabaseConnect, "racetimercss");
|
||||
}
|
||||
}
|
||||
|
||||
public void SQL_OnDatabaseConnect(Database db, const char[] error, any data)
|
||||
{
|
||||
if(!db || strlen(error))
|
||||
{
|
||||
LogError("Database error: %s", error);
|
||||
return;
|
||||
}
|
||||
g_dDatabase = db;
|
||||
}
|
||||
|
||||
public void OnClientPostAdminCheck(int client)
|
||||
{
|
||||
g_bClientsIgnoring[client] = false;
|
||||
sql_select_hiding_unavailable_maps(client);
|
||||
}
|
||||
|
||||
public void sql_select_hiding_unavailable_maps(int client)
|
||||
{
|
||||
if (!g_dDatabase)
|
||||
{
|
||||
Database.Connect(SQL_OnDatabaseConnect, "racetimercss");
|
||||
return;
|
||||
}
|
||||
char query[255];
|
||||
char steam_auth[64];
|
||||
GetClientAuthId(client, AuthId_Steam2, steam_auth, sizeof(steam_auth));
|
||||
//we have way too many dbs, just adding this to unloze_race_timer
|
||||
Format(query, sizeof(query), "SELECT is_ignoring FROM `mapchooser_hide_unavailable` where steam_auth = '%s'", steam_auth);
|
||||
g_dDatabase.Query(SQL_OnQueryCompleted_ignoring, query, client);
|
||||
}
|
||||
|
||||
public void SQL_OnQueryCompleted_ignoring(Database db, DBResultSet results, const char[] error, int client)
|
||||
{
|
||||
if (!db)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
|
||||
{
|
||||
int val = 0;
|
||||
if (results.RowCount && results.FetchRow())
|
||||
val = results.FetchInt(0);
|
||||
if (val == 1)
|
||||
{
|
||||
g_bClientsIgnoring[client] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sql_insert_update_hiding_unavailable(int client)
|
||||
{
|
||||
if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
|
||||
{
|
||||
if (g_bClientsIgnoring[client])
|
||||
{
|
||||
g_bClientsIgnoring[client] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_bClientsIgnoring[client] = true;
|
||||
}
|
||||
char sSID[64];
|
||||
char sQuery[256];
|
||||
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
|
||||
if (!g_dDatabase)
|
||||
{
|
||||
Database.Connect(SQL_OnDatabaseConnect, "racetimercss");
|
||||
return;
|
||||
}
|
||||
if (StrEqual(sSID, "STEAM_ID_STOP_IGNORING_RETVALS") || StrEqual(sSID, "STEAM_ID_PENDING"))
|
||||
{
|
||||
PrintToChat(client, "Your steam ID is not working, not updating");
|
||||
return;
|
||||
}
|
||||
Format(sQuery, sizeof(sQuery), "INSERT INTO `mapchooser_hide_unavailable` (`steam_auth`, `is_ignoring`) VALUES ('%s', '%i') ON DUPLICATE KEY UPDATE `is_ignoring` = '%i'", sSID, g_bClientsIgnoring[client], g_bClientsIgnoring[client]);
|
||||
DataPack hDataPack = new DataPack();
|
||||
hDataPack.WriteString(sQuery);
|
||||
g_dDatabase.Query(SQL_FinishedQuery, sQuery, hDataPack, DBPrio_Normal);
|
||||
}
|
||||
}
|
||||
|
||||
public void SQL_FinishedQuery(Database db, DBResultSet results, const char[] error, DataPack data)
|
||||
{
|
||||
if (!db || strlen(error))
|
||||
{
|
||||
char sQuery[256];
|
||||
ResetPack(data);
|
||||
data.ReadString(sQuery, sizeof(sQuery));
|
||||
LogError("Query error 3: %s", error);
|
||||
LogError("actual query: %s", sQuery);
|
||||
}
|
||||
delete data;
|
||||
}
|
||||
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
g_bClientsIgnoring[client] = false;
|
||||
}
|
||||
|
||||
public APLRes AskPluginLoad2(Handle hThis, bool bLate, char[] err, int iErrLen)
|
||||
@ -859,6 +969,18 @@ Menu BuildMapMenu(const char[] filter, int client)
|
||||
}
|
||||
}
|
||||
|
||||
//2023 edit to allow hiding/unhiding unavailable maps
|
||||
char hiding_unavailable_maps[MAX_NAME_LENGTH];
|
||||
if (g_bClientsIgnoring[client])
|
||||
{
|
||||
Format(hiding_unavailable_maps, sizeof(hiding_unavailable_maps), "Show all unavailable maps");
|
||||
}
|
||||
else
|
||||
{
|
||||
Format(hiding_unavailable_maps, sizeof(hiding_unavailable_maps), "Hide all unavailable maps");
|
||||
}
|
||||
AddMenuItem(menu, hiding_unavailable_maps, hiding_unavailable_maps);
|
||||
|
||||
for(int i = 0; i < GetArraySize(g_MapList); i++)
|
||||
{
|
||||
GetArrayString(g_MapList, i, map, sizeof(map));
|
||||
@ -875,6 +997,17 @@ Menu BuildMapMenu(const char[] filter, int client)
|
||||
StrCat(map, sizeof(map), " (Nominated)");
|
||||
}
|
||||
}
|
||||
if (g_bClientsIgnoring[client])
|
||||
{
|
||||
if(AreRestrictionsActive() && (
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetMapVIPRestriction(map, client)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
AddMenuItem(menu, map, map);
|
||||
}
|
||||
}
|
||||
@ -946,6 +1079,19 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
|
||||
if (StrEqual(map, "Hide all unavailable maps"))
|
||||
{
|
||||
PrintToChat(param1, "Hiding all unavailable maps from the nomination list");
|
||||
sql_insert_update_hiding_unavailable(param1);
|
||||
return 0;
|
||||
}
|
||||
if (StrEqual(map, "Show all unavailable maps"))
|
||||
{
|
||||
PrintToChat(param1, "Displaying all unavailable maps from the nomination list");
|
||||
sql_insert_update_hiding_unavailable(param1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GetClientName(param1, name, MAX_NAME_LENGTH);
|
||||
|
||||
if(AreRestrictionsActive() && (
|
||||
|
Loading…
Reference in New Issue
Block a user