Thread: [Solved] [L4D2] Hide HUD
View Single Post
Author Message
alcybery
Member
Join Date: Apr 2016
Old 06-13-2018 , 20:45   [L4D2] Hide HUD
Reply With Quote #1

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.7Timer_HudGetClientUserId(client), TIMER_REPEAT);    
}

public 
Action Timer_Hud(Handle hTimerany iUser)
{
    
int client GetClientOfUserId(iUser);

    if (
client <= MaxClients && IsClientInGame(client))
    {
        if (
GetClientMenu(client) != MenuSource_None)
            
SetEntProp(clientProp_Send"m_iHideHUD"GetEntProp(clientProp_Send"m_iHideHUD") & ~HIDEFLAG); 
        else
            
SetEntProp(clientProp_Send"m_iHideHUD"HIDEFLAG); 
        return 
Plugin_Continue;
    }
    else return 
Plugin_Stop;


Last edited by alcybery; 06-26-2018 at 13:19.
alcybery is offline