AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [L4D2] Hide HUD (https://forums.alliedmods.net/showthread.php?t=308270)

alcybery 06-13-2018 20:45

[L4D2] Hide HUD
 
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;



LenHard 06-14-2018 01:10

Re: [L4D2] Hide HUD
 
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.

alcybery 06-14-2018 02:30

Re: [L4D2] Hide HUD
 
Quote:

Originally Posted by LenHard (Post 2596858)
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?

LenHard 06-14-2018 03:18

Re: [L4D2] Hide HUD
 
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.

Silvers 06-14-2018 09:52

Re: [L4D2] Hide HUD
 
Also scrolling to change weapons won't work.

alcybery 06-14-2018 11:09

Re: [L4D2] Hide HUD
 
Quote:

Originally Posted by Silvers (Post 2596918)
Also scrolling to change weapons won't work.

Scrolling seems to be working as usual. It's not supposed to work?

Silvers 06-14-2018 12:10

Re: [L4D2] Hide HUD
 
When I was testing years ago trying to hide crosshair/hud that was an issue.

alcybery 06-14-2018 12:11

Re: [L4D2] Hide HUD
 
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.

LenHard 06-14-2018 16:47

Re: [L4D2] Hide HUD
 
Quote:

Originally Posted by alcybery (Post 2596951)
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)

alcybery 06-14-2018 18:43

Re: [L4D2] Hide HUD
 
Quote:

Originally Posted by LenHard (Post 2597004)
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 :up:


All times are GMT -4. The time now is 13:03.

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