further fixes to queries and timers
This commit is contained in:
parent
004889f308
commit
275245d6ab
@ -251,8 +251,13 @@ public void CvarQueryFinished_SprayLifeTime(QueryCookie cookie, int client, ConV
|
|||||||
g_iClientSprayLifetime[client] = iVal <= 0 ? 1 : iVal > 1000 ? 1000 : iVal;
|
g_iClientSprayLifetime[client] = iVal <= 0 ? 1 : iVal > 1000 ? 1000 : iVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void select_sprays_to_hide(Handle hParent, Handle hChild, const char[] err, any client)
|
public void select_sprays_to_hide(Handle hParent, Handle hChild, const char[] err, int Serial)
|
||||||
{
|
{
|
||||||
|
int client;
|
||||||
|
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!IsValidClient(client))
|
if (!IsValidClient(client))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -2374,7 +2379,7 @@ public Action Timer_UpdateHideSprays(Handle hTimer)
|
|||||||
|
|
||||||
char sQuery[512];
|
char sQuery[512];
|
||||||
Format(sQuery, sizeof(sQuery), "SELECT `steamidtarget` FROM `sprayhidemanage` WHERE `steamidhider` = '%s' and `is_online` = 1;", sAuthID);
|
Format(sQuery, sizeof(sQuery), "SELECT `steamidtarget` FROM `sprayhidemanage` WHERE `steamidhider` = '%s' and `is_online` = 1;", sAuthID);
|
||||||
SQL_TQuery(g_hDatabase, select_sprays_to_hide, sQuery, client, DBPrio_Normal);
|
SQL_TQuery(g_hDatabase, select_sprays_to_hide, sQuery, GetClientSerial(client), DBPrio_Normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2956,7 +2961,7 @@ void UpdatePlayerInfo(int client)
|
|||||||
GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID));
|
GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID));
|
||||||
Format(sQuery, sizeof(sQuery), "SELECT * FROM `spraymanager` WHERE `steamid` = '%s';", sSteamID);
|
Format(sQuery, sizeof(sQuery), "SELECT * FROM `spraymanager` WHERE `steamid` = '%s';", sSteamID);
|
||||||
|
|
||||||
SQL_TQuery(g_hDatabase, OnSQLCheckBanQuery, sQuery, client, DBPrio_Normal);
|
SQL_TQuery(g_hDatabase, OnSQLCheckBanQuery, sQuery, GetClientSerial(client), DBPrio_Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateSprayHashInfo(int client)
|
void UpdateSprayHashInfo(int client)
|
||||||
@ -2970,7 +2975,7 @@ void UpdateSprayHashInfo(int client)
|
|||||||
char sSprayQuery[128];
|
char sSprayQuery[128];
|
||||||
|
|
||||||
Format(sSprayQuery, sizeof(sSprayQuery), "SELECT * FROM `sprayblacklist` WHERE `sprayhash` = '%s';", g_sSprayHash[client]);
|
Format(sSprayQuery, sizeof(sSprayQuery), "SELECT * FROM `sprayblacklist` WHERE `sprayhash` = '%s';", g_sSprayHash[client]);
|
||||||
SQL_TQuery(g_hDatabase, OnSQLCheckSprayHashBanQuery, sSprayQuery, client, DBPrio_Normal);
|
SQL_TQuery(g_hDatabase, OnSQLCheckSprayHashBanQuery, sSprayQuery, GetClientSerial(client), DBPrio_Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateNSFWInfo(int client)
|
void UpdateNSFWInfo(int client)
|
||||||
@ -2984,7 +2989,7 @@ void UpdateNSFWInfo(int client)
|
|||||||
char sSprayQuery[128];
|
char sSprayQuery[128];
|
||||||
|
|
||||||
Format(sSprayQuery, sizeof(sSprayQuery), "SELECT * FROM `spraynsfwlist` WHERE `sprayhash` = '%s';", g_sSprayHash[client]);
|
Format(sSprayQuery, sizeof(sSprayQuery), "SELECT * FROM `spraynsfwlist` WHERE `sprayhash` = '%s';", g_sSprayHash[client]);
|
||||||
SQL_TQuery(g_hDatabase, OnSQLCheckNSFWSprayHashQuery, sSprayQuery, client);
|
SQL_TQuery(g_hDatabase, OnSQLCheckNSFWSprayHashQuery, sSprayQuery, GetClientSerial(client));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DummyCallback(Handle hOwner, Handle hChild, const char[] err, any data)
|
public void DummyCallback(Handle hOwner, Handle hChild, const char[] err, any data)
|
||||||
@ -2993,85 +2998,114 @@ public void DummyCallback(Handle hOwner, Handle hChild, const char[] err, any da
|
|||||||
LogError("Query error. (%s)", err);
|
LogError("Query error. (%s)", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSQLCheckBanQuery(Handle hParent, Handle hChild, const char[] err, any client)
|
public void OnSQLCheckBanQuery(Handle hParent, Handle hChild, const char[] err, int Serial)
|
||||||
{
|
{
|
||||||
if (!IsValidClient(client))
|
int client;
|
||||||
return;
|
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!IsValidClient(client))
|
||||||
|
return;
|
||||||
|
|
||||||
if (hChild == null)
|
if (hChild == null)
|
||||||
{
|
{
|
||||||
LogError("An error occurred while querying the database for a user ban, retrying in 10 seconds. (%s)", err);
|
LogError("An error occurred while querying the database for a user ban, retrying in 10 seconds. (%s)", err);
|
||||||
CreateTimer(10.0, RetryPlayerInfoUpdate, client);
|
CreateTimer(10.0, RetryPlayerInfoUpdate, GetClientSerial(client));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
if (SQL_FetchRow(hChild))
|
||||||
}
|
{
|
||||||
|
g_bSprayBanned[client] = true;
|
||||||
|
g_iSprayUnbanTimestamp[client] = SQL_FetchInt(hChild, 2);
|
||||||
|
g_iSprayBanTimestamp[client] = SQL_FetchInt(hChild, 5);
|
||||||
|
|
||||||
if (SQL_FetchRow(hChild))
|
SQL_FetchString(hChild, 3, g_sBanIssuerSID[client], sizeof(g_sBanIssuerSID[]));
|
||||||
{
|
SQL_FetchString(hChild, 4, g_sBanIssuer[client], sizeof(g_sBanIssuer[]));
|
||||||
g_bSprayBanned[client] = true;
|
SQL_FetchString(hChild, 6, g_sBanReason[client], sizeof(g_sBanReason[]));
|
||||||
g_iSprayUnbanTimestamp[client] = SQL_FetchInt(hChild, 2);
|
}
|
||||||
g_iSprayBanTimestamp[client] = SQL_FetchInt(hChild, 5);
|
|
||||||
|
|
||||||
SQL_FetchString(hChild, 3, g_sBanIssuerSID[client], sizeof(g_sBanIssuerSID[]));
|
|
||||||
SQL_FetchString(hChild, 4, g_sBanIssuer[client], sizeof(g_sBanIssuer[]));
|
|
||||||
SQL_FetchString(hChild, 6, g_sBanReason[client], sizeof(g_sBanReason[]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSQLCheckSprayHashBanQuery(Handle hParent, Handle hChild, const char[] err, any client)
|
public void OnSQLCheckSprayHashBanQuery(Handle hParent, Handle hChild, const char[] err, int Serial)
|
||||||
{
|
{
|
||||||
if (!IsValidClient(client))
|
int client;
|
||||||
return;
|
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!IsValidClient(client))
|
||||||
|
return;
|
||||||
|
|
||||||
if (hChild == null)
|
if (hChild == null)
|
||||||
{
|
{
|
||||||
LogError("An error occurred while querying the database for a spray ban, retrying in 10 seconds. (%s)", err);
|
LogError("An error occurred while querying the database for a spray ban, retrying in 10 seconds. (%s)", err);
|
||||||
CreateTimer(10.0, RetrySprayHashUpdate, client);
|
CreateTimer(10.0, RetrySprayHashUpdate, GetClientSerial(client));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SQL_FetchRow(hChild))
|
if (SQL_FetchRow(hChild))
|
||||||
g_bSprayHashBanned[client] = true;
|
g_bSprayHashBanned[client] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSQLCheckNSFWSprayHashQuery(Handle hParent, Handle hChild, const char[] err, any client)
|
public void OnSQLCheckNSFWSprayHashQuery(Handle hParent, Handle hChild, const char[] err, int Serial)
|
||||||
{
|
{
|
||||||
if (!IsValidClient(client))
|
int client;
|
||||||
return;
|
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!IsValidClient(client))
|
||||||
|
return;
|
||||||
|
|
||||||
if (hChild == null)
|
if (hChild == null)
|
||||||
{
|
{
|
||||||
LogError("An error occurred while querying the NSFW database for a spray, retrying in 10 seconds. (%s)", err);
|
LogError("An error occurred while querying the NSFW database for a spray, retrying in 10 seconds. (%s)", err);
|
||||||
CreateTimer(10.0, RetryNSFWSprayLookup, client);
|
CreateTimer(10.0, RetryNSFWSprayLookup, GetClientSerial(client));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SQL_FetchRow(hChild))
|
if (SQL_FetchRow(hChild))
|
||||||
{
|
{
|
||||||
g_bHasNSFWSpray[client] = true;
|
g_bHasNSFWSpray[client] = true;
|
||||||
|
|
||||||
char sSetByAdmin[8];
|
char sSetByAdmin[8];
|
||||||
SQL_FetchString(hChild, 2, sSetByAdmin, sizeof(sSetByAdmin));
|
SQL_FetchString(hChild, 2, sSetByAdmin, sizeof(sSetByAdmin));
|
||||||
|
|
||||||
g_bMarkedNSFWByAdmin[client] = view_as<bool>(StringToInt(sSetByAdmin));
|
g_bMarkedNSFWByAdmin[client] = view_as<bool>(StringToInt(sSetByAdmin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action RetryPlayerInfoUpdate(Handle hTimer, any client)
|
public Action RetryPlayerInfoUpdate(Handle hTimer, int Serial)
|
||||||
{
|
{
|
||||||
UpdatePlayerInfo(client);
|
int client;
|
||||||
|
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UpdatePlayerInfo(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action RetrySprayHashUpdate(Handle hTimer, any client)
|
public Action RetrySprayHashUpdate(Handle hTimer, int Serial)
|
||||||
{
|
{
|
||||||
UpdateSprayHashInfo(client);
|
int client;
|
||||||
|
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UpdateSprayHashInfo(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action RetryNSFWSprayLookup(Handle hTimer, any client)
|
public Action RetryNSFWSprayLookup(Handle hTimer, int Serial)
|
||||||
{
|
{
|
||||||
UpdateNSFWInfo(client);
|
int client;
|
||||||
|
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UpdateNSFWInfo(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
stock bool ForceSpray(int client, int target, bool bPlaySound=true)
|
stock bool ForceSpray(int client, int target, bool bPlaySound=true)
|
||||||
|
@ -161,13 +161,20 @@ public void sql_select_hiding_unavailable_maps(int client)
|
|||||||
GetClientAuthId(client, AuthId_Steam2, steam_auth, sizeof(steam_auth));
|
GetClientAuthId(client, AuthId_Steam2, steam_auth, sizeof(steam_auth));
|
||||||
//we have way too many dbs, just adding this to unloze_race_timer
|
//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);
|
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);
|
g_dDatabase.Query(SQL_OnQueryCompleted_ignoring, query, GetClientSerial(client));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SQL_OnQueryCompleted_ignoring(Database db, DBResultSet results, const char[] error, int client)
|
public void SQL_OnQueryCompleted_ignoring(Database db, DBResultSet results, const char[] error, int Serial)
|
||||||
{
|
{
|
||||||
if (!db)
|
if (!db)
|
||||||
{
|
{
|
||||||
|
delete results;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int client;
|
||||||
|
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||||
|
{
|
||||||
|
delete results;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
|
if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
|
||||||
@ -180,6 +187,7 @@ public void SQL_OnQueryCompleted_ignoring(Database db, DBResultSet results, cons
|
|||||||
g_bClientsIgnoring[client] = true;
|
g_bClientsIgnoring[client] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
delete results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sql_insert_update_hiding_unavailable(int client)
|
public void sql_insert_update_hiding_unavailable(int client)
|
||||||
@ -216,15 +224,16 @@ public void sql_insert_update_hiding_unavailable(int client)
|
|||||||
|
|
||||||
public void SQL_FinishedQuery(Database db, DBResultSet results, const char[] error, DataPack data)
|
public void SQL_FinishedQuery(Database db, DBResultSet results, const char[] error, DataPack data)
|
||||||
{
|
{
|
||||||
if (!db || strlen(error))
|
if (!db || strlen(error))
|
||||||
{
|
{
|
||||||
char sQuery[256];
|
char sQuery[256];
|
||||||
ResetPack(data);
|
ResetPack(data);
|
||||||
data.ReadString(sQuery, sizeof(sQuery));
|
data.ReadString(sQuery, sizeof(sQuery));
|
||||||
LogError("Query error 3: %s", error);
|
LogError("Query error 3: %s", error);
|
||||||
LogError("actual query: %s", sQuery);
|
LogError("actual query: %s", sQuery);
|
||||||
}
|
}
|
||||||
delete data;
|
delete results;
|
||||||
|
delete data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClientDisconnect(int client)
|
public void OnClientDisconnect(int client)
|
||||||
|
@ -238,7 +238,10 @@ public void OnMapStart()
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void OnConfigsExecuted()
|
public void OnConfigsExecuted()
|
||||||
{
|
{
|
||||||
Database.Connect(SQL_OnDatabaseConnect, "season");
|
if (!g_hDatabase)
|
||||||
|
{
|
||||||
|
Database.Connect(SQL_OnDatabaseConnect, "season");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user