From ab3b679d51e6ad387e7f83c6ca28726e319f945b Mon Sep 17 00:00:00 2001 From: neon Date: Wed, 28 Apr 2021 14:19:40 +0100 Subject: [PATCH] Hide: optimization --- _Hide/scripting/Hide.sp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/_Hide/scripting/Hide.sp b/_Hide/scripting/Hide.sp index b68a5dee..ca312cfc 100644 --- a/_Hide/scripting/Hide.sp +++ b/_Hide/scripting/Hide.sp @@ -17,9 +17,13 @@ ConVar g_hCVar_HideEnabled; Handle g_hCookie_HideRange; #define DISABLED -1 -#define SHORT 120 -#define MEDIUM 250 -#define LONG 500 +#define SHORT_RANGE 120 +#define MEDIUM_RANGE 250 +#define LONG_RANGE 500 + +int SHORT = SHORT_RANGE * SHORT_RANGE; +int MEDIUM = MEDIUM_RANGE * MEDIUM_RANGE; +int LONG = LONG_RANGE * LONG_RANGE; //---------------------------------------------------------------------------------------------------- // Purpose: @@ -29,7 +33,7 @@ public Plugin myinfo = name = "Hide Teammates", author = "Neon", description = "A plugin that can !hide teammates with individual distances", - version = "2.0.0", + version = "2.0.1", url = "https://steamcommunity.com/id/n3ontm" }; @@ -126,7 +130,11 @@ public void OnClientCookiesCached(int client) GetClientCookie(client, g_hCookie_HideRange, sBuffer, sizeof(sBuffer)); if (sBuffer[0]) + { g_iHideRange[client] = StringToInt(sBuffer); + if (g_iHideRange[client] != SHORT && g_iHideRange[client] != MEDIUM && g_iHideRange[client] != LONG) + g_iHideRange[client] = DISABLED; + } else g_iHideRange[client] = DISABLED; } @@ -169,7 +177,7 @@ public Action UpdateHide(Handle timer) GetClientAbsOrigin(target, fOriginTarget); GetClientAbsOrigin(client, fOriginClient); //PrintToChatAll("%N--%N::::::%f", client, target, GetVectorDistance(fOriginTarget, fOriginClient, false)); - if(GetVectorDistance(fOriginTarget, fOriginClient, false) <= float(g_iHideRange[client])) + if(GetVectorDistance(fOriginTarget, fOriginClient, true) <= float(g_iHideRange[client])) g_bHidePlayers[client][target] = true; else g_bHidePlayers[client][target] = false;