forked from UNLOZE/sm-plugins
further fixes to queries and timers
This commit is contained in:
@@ -251,8 +251,13 @@ public void CvarQueryFinished_SprayLifeTime(QueryCookie cookie, int client, ConV
|
||||
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))
|
||||
return;
|
||||
|
||||
@@ -2374,7 +2379,7 @@ public Action Timer_UpdateHideSprays(Handle hTimer)
|
||||
|
||||
char sQuery[512];
|
||||
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));
|
||||
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)
|
||||
@@ -2970,7 +2975,7 @@ void UpdateSprayHashInfo(int client)
|
||||
char sSprayQuery[128];
|
||||
|
||||
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)
|
||||
@@ -2984,7 +2989,7 @@ void UpdateNSFWInfo(int client)
|
||||
char sSprayQuery[128];
|
||||
|
||||
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)
|
||||
@@ -2993,85 +2998,114 @@ public void DummyCallback(Handle hOwner, Handle hChild, const char[] err, any da
|
||||
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))
|
||||
return;
|
||||
int client;
|
||||
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!IsValidClient(client))
|
||||
return;
|
||||
|
||||
if (hChild == null)
|
||||
{
|
||||
LogError("An error occurred while querying the database for a user ban, retrying in 10 seconds. (%s)", err);
|
||||
CreateTimer(10.0, RetryPlayerInfoUpdate, client);
|
||||
if (hChild == null)
|
||||
{
|
||||
LogError("An error occurred while querying the database for a user ban, retrying in 10 seconds. (%s)", err);
|
||||
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))
|
||||
{
|
||||
g_bSprayBanned[client] = true;
|
||||
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[]));
|
||||
}
|
||||
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))
|
||||
return;
|
||||
int client;
|
||||
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!IsValidClient(client))
|
||||
return;
|
||||
|
||||
if (hChild == null)
|
||||
{
|
||||
LogError("An error occurred while querying the database for a spray ban, retrying in 10 seconds. (%s)", err);
|
||||
CreateTimer(10.0, RetrySprayHashUpdate, client);
|
||||
if (hChild == null)
|
||||
{
|
||||
LogError("An error occurred while querying the database for a spray ban, retrying in 10 seconds. (%s)", err);
|
||||
CreateTimer(10.0, RetrySprayHashUpdate, GetClientSerial(client));
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (SQL_FetchRow(hChild))
|
||||
g_bSprayHashBanned[client] = true;
|
||||
if (SQL_FetchRow(hChild))
|
||||
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))
|
||||
return;
|
||||
int client;
|
||||
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!IsValidClient(client))
|
||||
return;
|
||||
|
||||
if (hChild == null)
|
||||
{
|
||||
LogError("An error occurred while querying the NSFW database for a spray, retrying in 10 seconds. (%s)", err);
|
||||
CreateTimer(10.0, RetryNSFWSprayLookup, client);
|
||||
if (hChild == null)
|
||||
{
|
||||
LogError("An error occurred while querying the NSFW database for a spray, retrying in 10 seconds. (%s)", err);
|
||||
CreateTimer(10.0, RetryNSFWSprayLookup, GetClientSerial(client));
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (SQL_FetchRow(hChild))
|
||||
{
|
||||
g_bHasNSFWSpray[client] = true;
|
||||
if (SQL_FetchRow(hChild))
|
||||
{
|
||||
g_bHasNSFWSpray[client] = true;
|
||||
|
||||
char sSetByAdmin[8];
|
||||
SQL_FetchString(hChild, 2, sSetByAdmin, sizeof(sSetByAdmin));
|
||||
char sSetByAdmin[8];
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user