SprayManager: band aid fix against spray exploit

This commit is contained in:
hubdom 2020-09-17 15:14:00 +02:00
parent b50c8b56af
commit db3d81dc68

View File

@ -2088,13 +2088,28 @@ public Action Command_SprayManager_UpdateInfo(int client, int argc)
ReplyToCommand(client, "[SprayManager] Refreshed database.");
}
public bool isGoodSpray(int client)
{
char sTemp[PLATFORM_MAX_PATH - 10];
GetPlayerDecalFile(client, sTemp, sizeof(sTemp));
Format(sTemp, sizeof(sTemp), "%s.dat", sTemp);
Format(sTemp, sizeof(sTemp), "download/user_custom/%c%c/%s", sTemp[0], sTemp[1], sTemp);
if(!FileExists(sTemp))
return false;
return true;
}
public Action HookDecal(const char[] sTEName, const int[] iClients, int iNumClients, float fSendDelay)
{
int client = TE_ReadNum("m_nPlayer");
if (!isGoodSpray(client))
return Plugin_Handled;
if (g_bSkipDecalHook)
return Plugin_Continue;
int client = TE_ReadNum("m_nPlayer");
if (!IsValidClient(client))
{
if (g_iAllowSpray == client)
@ -2941,6 +2956,9 @@ stock bool ForceSpray(int client, int target, bool bPlaySound=true)
if (!IsValidClient(target))
return false;
if (!isGoodSpray(client))
return false;
float vecEndPos[3];
if (TracePlayerAngles(client, vecEndPos))
@ -2963,6 +2981,9 @@ stock bool SprayClientDecalToAll(int client, int iEntity, const float vecOrigin[
if (!IsValidClient(client))
return false;
if (!isGoodSpray(client))
return false;
TE_Start("Player Decal");
TE_WriteVector("m_vecOrigin", vecOrigin);
TE_WriteNum("m_nEntity", iEntity);
@ -2977,6 +2998,9 @@ stock bool SprayClientDecalToSelected(int client, int iEntity, const float vecOr
if (!IsValidClient(client))
return false;
if (!isGoodSpray(client))
return false;
TE_Start("Player Decal");
TE_WriteVector("m_vecOrigin", vecOrigin);
TE_WriteNum("m_nEntity", iEntity);
@ -2991,6 +3015,9 @@ stock bool SprayClientDecalToOne(int client, int target, int iEntity, const floa
if (!IsValidClient(client))
return false;
if (!isGoodSpray(client))
return false;
TE_Start("Player Decal");
TE_WriteVector("m_vecOrigin", vecOrigin);
TE_WriteNum("m_nEntity", iEntity);
@ -3040,6 +3067,8 @@ stock bool TracePlayerAngles(int client, float vecResult[3])
if ((iEntity = TR_GetEntityIndex(hTraceRay)) >= 0)
g_iDecalEntity[client] = iEntity;
PrintToServer("ent: %d", iEntity);
delete hTraceRay;
return true;
@ -3214,4 +3243,4 @@ stock bool IsValidClient(int client)
return false;
return IsClientAuthorized(client);
}
}