I'm trying to hide HUD in L4D2 with this:
PHP Code:
#include <sourcemod>
public OnPluginStart()
{
HookEvent("player_spawn", Event_PlayeSpawn)
}
public Action:Event_PlayeSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
SetEntProp(GetClientOfUserId(GetEventInt(event, "userid")), Prop_Send, "m_iHideHUD", 64);
return Plugin_Continue;
}
It works, but it hides admin menu and shows HUD when you're dead, between map changes and is just unreliable. Is there a way to fix those problems? The goal is to hide HUD all the time.
Working code:
PHP Code:
#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required
#define HIDEFLAG 64
public void OnClientPutInServer(int client)
{
if (!IsFakeClient(client)) CreateTimer(0.7, Timer_Hud, GetClientUserId(client), TIMER_REPEAT);
}
public Action Timer_Hud(Handle hTimer, any iUser)
{
int client = GetClientOfUserId(iUser);
if (0 < client <= MaxClients && IsClientInGame(client))
{
if (GetClientMenu(client) != MenuSource_None)
SetEntProp(client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") & ~HIDEFLAG);
else
SetEntProp(client, Prop_Send, "m_iHideHUD", HIDEFLAG);
return Plugin_Continue;
}
else return Plugin_Stop;
}