added feature to hide maps that are unavailable
This commit is contained in:
parent
e094ed41aa
commit
d21303488b
@ -83,6 +83,10 @@ Handle g_Cvar_VIPTimeframeMaxTime = INVALID_HANDLE;
|
|||||||
int g_Player_NominationDelay[MAXPLAYERS+1];
|
int g_Player_NominationDelay[MAXPLAYERS+1];
|
||||||
int g_NominationDelay;
|
int g_NominationDelay;
|
||||||
|
|
||||||
|
//clients ignoring maps that are unavailable
|
||||||
|
bool g_bClientsIgnoring[MAXPLAYERS + 1];
|
||||||
|
Database g_dDatabase;
|
||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
LoadTranslations("common.phrases");
|
LoadTranslations("common.phrases");
|
||||||
@ -120,6 +124,112 @@ public void OnPluginStart()
|
|||||||
CreateConVar("ne_version", MCE_VERSION, "Nominations Extended Version", FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);
|
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)
|
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++)
|
for(int i = 0; i < GetArraySize(g_MapList); i++)
|
||||||
{
|
{
|
||||||
GetArrayString(g_MapList, i, map, sizeof(map));
|
GetArrayString(g_MapList, i, map, sizeof(map));
|
||||||
@ -875,6 +997,17 @@ Menu BuildMapMenu(const char[] filter, int client)
|
|||||||
StrCat(map, sizeof(map), " (Nominated)");
|
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);
|
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];
|
char name[MAX_NAME_LENGTH];
|
||||||
GetMenuItem(menu, param2, map, sizeof(map));
|
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);
|
GetClientName(param1, name, MAX_NAME_LENGTH);
|
||||||
|
|
||||||
if(AreRestrictionsActive() && (
|
if(AreRestrictionsActive() && (
|
||||||
|
Loading…
Reference in New Issue
Block a user