Raised This Month: $12 Target: $400
 3% 

Solved [L4D2] Hide HUD


Post New Thread Reply   
 
Thread Tools Display Modes
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
LenHard
Senior Member
Join Date: Jan 2016
Old 06-14-2018 , 01:10   Re: [L4D2] Hide HUD
Reply With Quote #2

The hides admin menu problem is probably because of the flag you're using.
For the display hud when dead, you could try hooking player_death and resetting their m_iHideHud flags.
If that didn't work you could attempt to make a repeating timer.
__________________
LenHard is offline
alcybery
Member
Join Date: Apr 2016
Old 06-14-2018 , 02:30   Re: [L4D2] Hide HUD
Reply With Quote #3

Quote:
Originally Posted by LenHard View Post
The hides admin menu problem is probably because of the flag you're using.
For the display hud when dead, you could try hooking player_death and resetting their m_iHideHud flags.
If that didn't work you could attempt to make a repeating timer.
Thanks, hooking player_death worked. But HUD still shows up after campaign change, so I did a repeating timer:
PHP Code:
#pragma semicolon 1
#include <sourcemod>

public OnClientPutInServer(client)
{
    
CreateTimer(0.5Timer_HUDGetClientUserId(client), TIMER_REPEAT);
}

public 
Action:Timer_HUD(Handle:timerany:data)
{
    new 
client GetClientOfUserId(data);
    if (
client == 0)
    {
        return 
Plugin_Stop;
    }
    
SetEntProp(clientProp_Send"m_iHideHUD"64);
    return 
Plugin_Continue;

It works, but I still have the problem with it hiding the admin menu. What flag I should be using to not hide the admin menu?

Last edited by alcybery; 06-14-2018 at 02:32. Reason: typo
alcybery is offline
LenHard
Senior Member
Join Date: Jan 2016
Old 06-14-2018 , 03:18   Re: [L4D2] Hide HUD
Reply With Quote #4

You're going to have to play around with the flags, but if you can't find it you could always make exceptions of the hide hud.

Turn off the hidehud when a menu is active. You could use GetClientMenu to check if the player is viewing a menu.
__________________
LenHard is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-14-2018 , 09:52   Re: [L4D2] Hide HUD
Reply With Quote #5

Also scrolling to change weapons won't work.
__________________
Silvers is offline
alcybery
Member
Join Date: Apr 2016
Old 06-14-2018 , 11:09   Re: [L4D2] Hide HUD
Reply With Quote #6

Quote:
Originally Posted by Silvers View Post
Also scrolling to change weapons won't work.
Scrolling seems to be working as usual. It's not supposed to work?
alcybery is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-14-2018 , 12:10   Re: [L4D2] Hide HUD
Reply With Quote #7

When I was testing years ago trying to hide crosshair/hud that was an issue.
__________________
Silvers is offline
alcybery
Member
Join Date: Apr 2016
Old 06-14-2018 , 12:11   Re: [L4D2] Hide HUD
Reply With Quote #8

With this code:
PHP Code:
#pragma semicolon 1
#include <sourcemod>

public OnClientPutInServer(client)
{
    
CreateTimer(0.5Timer_HUDGetClientUserId(client), TIMER_REPEAT);
}

public 
Action:Timer_HUD(Handle:timerany:data)
{
    new 
client GetClientOfUserId(data);
    if (
client == 0)
    {
        return 
Plugin_Stop;
    }
    if (
GetClientMenu(client) != MenuSource_None)
    {
        return 
Plugin_Stop;
    }
    
SetEntProp(clientProp_Send"m_iHideHUD"64);
    return 
Plugin_Continue

It shows admin menu and HUD only when I'm dead, but also even if I close admin menu, HUD is still showing.
alcybery is offline
LenHard
Senior Member
Join Date: Jan 2016
Old 06-14-2018 , 16:47   Re: [L4D2] Hide HUD
Reply With Quote #9

Quote:
Originally Posted by alcybery View Post
It shows admin menu and HUD only when I'm dead, but also even if I close admin menu, HUD is still showing.
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;

That's because you killed the timer by returning Plugin_Stop after you checked if the client is viewing a menu. Try this (untested)
__________________
LenHard is offline
alcybery
Member
Join Date: Apr 2016
Old 06-14-2018 , 18:43   Re: [L4D2] Hide HUD
Reply With Quote #10

Quote:
Originally Posted by LenHard View Post
That's because you killed the timer by returning Plugin_Stop after you checked if the client is viewing a menu. Try this (untested)
Thank you very much, it works great
alcybery is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:46.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode