updated by adding a timer to check so new clients connecting wont be missed to get blocked

This commit is contained in:
jenz 2022-06-07 21:45:16 +02:00
parent ad3af6e817
commit 9b34b07a00

View File

@ -24,6 +24,7 @@ enum
Handle g_hDatabase = null; Handle g_hDatabase = null;
Handle g_hTraceTimer = null; Handle g_hTraceTimer = null;
Handle g_hHideSpray = null;
Handle g_hRoundEndTimer = null; Handle g_hRoundEndTimer = null;
Handle g_hTopMenu = null; Handle g_hTopMenu = null;
Handle g_hWantsToSeeNSFWCookie = null; Handle g_hWantsToSeeNSFWCookie = null;
@ -157,6 +158,7 @@ public void OnPluginStart()
AutoExecConfig(true, "plugin.SprayManager"); AutoExecConfig(true, "plugin.SprayManager");
g_hTraceTimer = CreateTimer(0.25, Timer_PerformPlayerTraces, _, TIMER_REPEAT); g_hTraceTimer = CreateTimer(0.25, Timer_PerformPlayerTraces, _, TIMER_REPEAT);
g_hHideSpray = CreateTimer(4.0, Timer_UpdateHideSprays, _, TIMER_REPEAT);
if (g_bLoadedLate) if (g_bLoadedLate)
{ {
@ -200,6 +202,9 @@ public void OnPluginEnd()
if (g_hTraceTimer != null) if (g_hTraceTimer != null)
delete g_hTraceTimer; delete g_hTraceTimer;
if (g_hHideSpray != null)
delete g_hHideSpray;
if (g_hRoundEndTimer != null) if (g_hRoundEndTimer != null)
delete g_hRoundEndTimer; delete g_hRoundEndTimer;
@ -256,6 +261,7 @@ public void select_sprays_to_hide(Handle hParent, Handle hChild, const char[] er
LogError("failed selecting hidden sprays (%s)", err); LogError("failed selecting hidden sprays (%s)", err);
return; return;
} }
while (SQL_FetchRow(hChild)) while (SQL_FetchRow(hChild))
{ {
char sAuthID[32]; char sAuthID[32];
@ -266,6 +272,10 @@ public void select_sprays_to_hide(Handle hParent, Handle hChild, const char[] er
continue; continue;
char sAuthID_target[32]; char sAuthID_target[32];
GetClientAuthId(i, AuthId_Steam2, sAuthID_target, sizeof(sAuthID_target), false); GetClientAuthId(i, AuthId_Steam2, sAuthID_target, sizeof(sAuthID_target), false);
if (StrContains(sAuthID_target, "STEAM_0") == -1 && StrContains(sAuthID_target, "STEAM_1") == -1)
{
continue;
}
if (StrEqual(sAuthID, sAuthID_target)) if (StrEqual(sAuthID, sAuthID_target))
{ {
g_bHasSprayHidden[client][i] = true; g_bHasSprayHidden[client][i] = true;
@ -273,6 +283,7 @@ public void select_sprays_to_hide(Handle hParent, Handle hChild, const char[] er
g_bSkipDecalHook = true; g_bSkipDecalHook = true;
SprayClientDecalToOne(i, client, 0, ACTUAL_NULL_VECTOR); SprayClientDecalToOne(i, client, 0, ACTUAL_NULL_VECTOR);
g_bSkipDecalHook = false; g_bSkipDecalHook = false;
break;
} }
} }
} }
@ -287,13 +298,6 @@ public void OnClientPostAdminCheck(int client)
UpdatePlayerInfo(client); UpdatePlayerInfo(client);
UpdateSprayHashInfo(client); UpdateSprayHashInfo(client);
UpdateNSFWInfo(client); UpdateNSFWInfo(client);
char sAuthID[32];
GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false);
char sQuery[512];
Format(sQuery, sizeof(sQuery), "SELECT `steamidtarget` FROM `sprayhidemanage` WHERE `steamidhider` = '%s';", sAuthID);
SQL_TQuery(g_hDatabase, select_sprays_to_hide, sQuery, client, DBPrio_High);
} }
if (g_cvarSendSpraysToConnectingClients.BoolValue) if (g_cvarSendSpraysToConnectingClients.BoolValue)
@ -2251,7 +2255,7 @@ public Action HookDecal(const char[] sTEName, const int[] iClients, int iNumClie
if (CheckCommandAccess(i, "", ADMFLAG_CUSTOM1, true) || CheckCommandAccess(i, "sm_sprayban", ADMFLAG_GENERIC)) if (CheckCommandAccess(i, "", ADMFLAG_CUSTOM1, true) || CheckCommandAccess(i, "sm_sprayban", ADMFLAG_GENERIC))
{ {
PrintToChat(client, "\x01\x04[SprayManager]\x01 Your spray is too close to \x04%N\x01's spray.", i); PrintToChat(client, "\x01\x04[SprayManager]\x01 Your spray is too close to \x04%N\x01's spray.", i); //'
return Plugin_Handled; return Plugin_Handled;
} }
@ -2341,6 +2345,26 @@ public Action HookSprayer(int iClients[MAXPLAYERS], int &iNumClients, char sSoun
return Plugin_Continue; return Plugin_Continue;
} }
public Action Timer_UpdateHideSprays(Handle hTimer)
{
for (int client = 1; client <= MaxClients; client++)
{
if (!IsValidClient(client) || IsFakeClient(client))
continue;
char sAuthID[32];
GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false);
if (StrContains(sAuthID, "STEAM_0") == -1 && StrContains(sAuthID, "STEAM_1") == -1)
{
continue;
}
char sQuery[512];
Format(sQuery, sizeof(sQuery), "SELECT `steamidtarget` FROM `sprayhidemanage` WHERE `steamidhider` = '%s';", sAuthID);
SQL_TQuery(g_hDatabase, select_sprays_to_hide, sQuery, client, DBPrio_High);
}
}
public Action Timer_PerformPlayerTraces(Handle hTimer) public Action Timer_PerformPlayerTraces(Handle hTimer)
{ {
static bool bLookingatSpray[MAXPLAYERS + 1]; static bool bLookingatSpray[MAXPLAYERS + 1];