Hide: optimization

This commit is contained in:
neon 2021-04-28 14:19:40 +01:00
parent 11f0999f3f
commit ab3b679d51

View File

@ -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;