AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Disable Huds From Plugins (https://forums.alliedmods.net/showthread.php?t=325972)

AlexLopesAltero 07-12-2020 20:28

Disable Huds From Plugins
 
Hello guys ... I am finding a script in which the player can disable the plugins huds on the screen by command ... I really need this help :)

https://ibb.co/1Gm9DZy

Supremache 07-12-2020 21:09

Re: Disable Huds From Plugins
 
Quote:

Originally Posted by AlexLopesAltero (Post 2709907)
Hello guys ... I am finding a script in which the player can disable the plugins huds on the screen by command ... I really need this help :)

https://ibb.co/1Gm9DZy

PHP Code:

#include < amxmodx >
#include < amxmisc >
#include < fun >


// Booleans
new g_bToggleHud33 ] = true;    

public 
plugin_init() {
    
register_pluginPLUGINVERSIONAUTHOR );

    
// Register Client Commands
    
register_clcmd"say /hud""cmdToggleHud" ); //Showing Hud Message On / Off
}



public 
client_putinserverid ) {
    
g_bToggleHudid ] = true;
    
set_task0.9"ShowHud"id__"b" );
}

    
// Toggle Showing Hud Message On / Off
public cmdToggleHudid ) {
    
g_bToggleHudid ] = !g_bToggleHudid ];
    return 
PLUGIN_HANDLED;
}

// Shows The Rank Information Message
public ShowHudid ) {
    if( 
g_bToggleHudid ] ) {
        
set_hudmessage(025500.010.1806.01.00.00.0, -);
        
show_hudmessage(id"Hud Message Enable/Disable" );
    }



chickez 07-13-2020 03:49

Re: Disable Huds From Plugins
 
PHP Code:

// Toggle Showing Hud Message On / Off
public cmdToggleHudid ) {
    
g_bToggleHudid ] = !g_bToggleHudid ];
    return 
PLUGIN_HANDLED;


It will set bool to false one time. When player want back to turn on HUD, he must reconnect ( set bool to true ). I'm right?

I haven't test script but, why not like this?:
PHP Code:

// Toggle Showing Hud Message On / Off
public cmdToggleHudid )
{
    if ( 
g_bToggleHudid ] )
        
g_bToggleHudid ] = false;
    else
        
g_bToggleHudid ] = true;
    return 
PLUGIN_HANDLED;


I'm just asking, if I'm right.

I have hud on/off in my plugin coded like I post, and it's working for me.

Supremache 07-13-2020 06:31

Re: Disable Huds From Plugins
 
Quote:

Originally Posted by chickez (Post 2709925)
PHP Code:

// Toggle Showing Hud Message On / Off
public cmdToggleHudid ) {
    
g_bToggleHudid ] = !g_bToggleHudid ];
    return 
PLUGIN_HANDLED;


It will set bool to false one time. When player want back to turn on HUD, he must reconnect ( set bool to true ). I'm right?

I haven't test script but, why not like this?:
PHP Code:

// Toggle Showing Hud Message On / Off
public cmdToggleHudid )
{
    if ( 
g_bToggleHudid ] )
        
g_bToggleHudid ] = false;
    else
        
g_bToggleHudid ] = true;
    return 
PLUGIN_HANDLED;


I'm just asking, if I'm right.

I have hud on/off in my plugin coded like I post, and it's working for me.


No, he can do it automatically so if he said /hud, hudessage will disable automatic and if said /hud again will enable the hud message

OciXCrom 07-13-2020 07:39

Re: Disable Huds From Plugins
 
Quote:

I haven't test script but, why not like this?
Why 4 lines of code with if-statements instead of 1 line of code without any if-statements? The result is the same.

PS: if you don't remove the task on disconnect, you're gonna end up with tons of overlapping messages.
PS2: use ShowSyncHudMsg.

chickez 07-13-2020 08:27

Re: Disable Huds From Plugins
 
Oh, I see.
Thank you for explanation.


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

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