From 2fde5f3061cf1340c7a6d3104d137a7daa215f9b Mon Sep 17 00:00:00 2001 From: christian Date: Mon, 12 Apr 2021 21:02:40 +0200 Subject: [PATCH] now disables properly and added semi support for specs --- _Hide/scripting/Hide.sp | 42 +++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/_Hide/scripting/Hide.sp b/_Hide/scripting/Hide.sp index 17f11b07..d6156351 100644 --- a/_Hide/scripting/Hide.sp +++ b/_Hide/scripting/Hide.sp @@ -42,7 +42,7 @@ public void OnPluginStart() g_hCVar_HideEnabled.AddChangeHook(OnConVarChanged); - RegAdminCmd("sm_hide", Command_Hide, ADMFLAG_RCON); + RegConsoleCmd("sm_hide", Command_Hide, "Hiding humans away"); for(int client = 1; client <= MaxClients; client++) { @@ -91,9 +91,6 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n //---------------------------------------------------------------------------------------------------- public void OnClientPutInServer(int client) { - if(!g_bHideEnabled) - return; - SDKHook(client, SDKHook_SetTransmit, Hook_SetTransmit); } @@ -139,14 +136,21 @@ public Action Command_Hide(int client, int args) GetCmdArg(1, sArgs, sizeof(sArgs)); iDistance = StringToInt(sArgs); } + if (IsPlayerAlive(client) && ZR_IsClientZombie(client)) + { + ReplyToCommand(client, "You are a zombie and therefore need to see the humans."); + return Plugin_Handled; + } if((iDistance == 0) || (iDistance < g_hCVar_HideMinimumDistance.IntValue) || (iDistance > g_hCVar_HideMaximumDistance.IntValue)) { ReplyToCommand(client, "[Hide] Wrong input! Allowed range: %d-%d", g_hCVar_HideMinimumDistance.IntValue, g_hCVar_HideMaximumDistance.IntValue); return Plugin_Handled; } - - ReplyToCommand(client, "[Hide] Humans within range %d are now hidden.", iDistance); + if (!IsPlayerAlive(client)) + ReplyToCommand(client, "[Hide] All Humans are now hidden."); + else + ReplyToCommand(client, "[Hide] Humans within range %d are now hidden.", iDistance); g_iHideDistance[client] = iDistance * iDistance; return Plugin_Handled; } @@ -161,12 +165,30 @@ public Action UpdateHide(Handle timer) for(int client = 1; client <= MaxClients; client++) { + if(!IsClientInGame(client)) + continue; if(!g_iHideDistance[client]) + { + for(int target = 1; target <= MaxClients; target++) + { + if(target != client && IsClientInGame(target) && IsPlayerAlive(target) && ZR_IsClientHuman(target)) + g_bHidePlayers[client][target] = false; + } + continue; + } + if (!IsPlayerAlive(client)) + { + for(int target = 1; target <= MaxClients; target++) + { + if(target != client && IsClientInGame(target) && IsPlayerAlive(target) && ZR_IsClientHuman(target)) + { + g_bHidePlayers[client][target] = true + } + } continue; - - if(!IsClientInGame(client) || !IsPlayerAlive(client) || !ZR_IsClientHuman(client)) + } + if (!ZR_IsClientHuman(client)) continue; - float fOriginClient[3]; float fOriginTarget[3]; @@ -200,4 +222,4 @@ public Action Hook_SetTransmit(int target, int client) return Plugin_Handled; return Plugin_Continue; -} \ No newline at end of file +}