AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Solved Help with turn on / off hud (https://forums.alliedmods.net/showthread.php?t=328311)

nades 11-04-2020 02:36

Help with turn on / off hud
 
Code:

#include <amxmodx>


public plugin_init() {
    set_task(1.0, "show_hud",_,_,_, "b")
}

public show_hud() {
   
    new ip [ 60 ], hostname[ 64 ]
    get_user_ip ( 0, ip, sizeof ( ip ) - 1 )
    get_cvar_string("hostname", hostname, 63)
    set_hudmessage(6, 70, 199, 0.0, 0.21, 0, 6.0, 1.1)
    show_hudmessage(0, "Server: %s^nIP: %s", hostname, ip);
}

I want a cmd /hud for on/off hud message.

Supremache 11-04-2020 14:07

Re: Help with turn on / off hud
 
Try this:
Code:
#include <amxmodx> new g_ShowHud[ 33 ] = true; public plugin_init() {     register_clcmd( "say /hud", "cmdShowHud" ); } // Toggle Showing Hud Message On / Off public cmdShowHud( id ) {     g_ShowHud[ id ] = !g_ShowHud[ id ];     return PLUGIN_HANDLED; } public client_putinserver( id ) {     g_ShowHud[ id ] = true;     set_task( 0.9, "ShowHud", id, _, _, "b" ); } public ShowHud( id ) {     if( g_ShowHud[ id ] ) {                 new szServerIP[ 64 ], szHostName[ 64 ]         get_user_ip(0, szServerIP, charsmax(szServerIP))         get_cvar_string("hostname", szHostName, charsmax(szHostName))             set_hudmessage(6, 70, 199, 0.0, 0.21, 0, 6.0, 1.1)         show_hudmessage(0, "Server: %s^nIP: %s", szHostName, szServerIP);     } }

r0ma 11-04-2020 14:24

Re: Help with turn on / off hud
 
Quote:

Originally Posted by Supremache (Post 2723724)
Try this:
Code:
#include <amxmodx> new g_ShowHud[ 33 ] = true; new g_szSeverIp[ 33 ]; public plugin_init() {     register_clcmd( "say /hud", "cmdShowHud" );         get_user_ip( 0, g_szSeverIp, charsmax( g_szSeverIp ) ); } // Toggle Showing Hud Message On / Off public cmdShowHud( id ) {     g_ShowHud[ id ] = !g_ShowHud[ id ];     return PLUGIN_HANDLED; } public client_putinserver( id ) {     g_ShowHud[ id ] = true;     set_task( 0.9, "ShowHud", id, _, _, "b" ); } public client_disconnect( id ) {     remove_task( id ); } public ShowHud( id ) {     if( g_ShowHud[ id ] ) {         static szHostName[ 64 ];         get_cvar_string( "hostname", szHostName, charsmax( szHostName ) );         set_hudmessage( 6, 70, 199, 0.0, 0.21, 0, 6.0, 1.1 )         show_hudmessage( id, "Server: %s^nIP: %s", szHostName, g_szSeverIp );     } }

v 1.1 :crab:

PHP Code:

#include <amxmodx>

const TASK_HUD 12435;

new 
g_szSeverIp33 ];

public 
plugin_init() {
    
register_clcmd"say /hud""cmdShowHud" );
    
    
get_user_ip0g_szSeverIpcharsmaxg_szSeverIp ) );
}

// Toggle Showing Hud Message On / Off
public cmdShowHudid ) {
    if( 
task_existsid TASK_HUD ) )
        
remove_taskid TASK_HUD );
    else
        
set_task0.9"ShowHud"id TASK_HUD__"b" );
    
    
client_printidprint_chat"[AMXX] Hud %s"task_existsid TASK_HUD ) ? "ON" "OFF" );
    
    return 
PLUGIN_HANDLED;
}

public 
client_putinserverid ) {
    
set_task0.9"ShowHud"id TASK_HUD__"b" );
}

public 
client_disconnectid ) {
    if( 
task_existsid TASK_HUD ) )
        
remove_taskid TASK_HUD );
}

public 
ShowHudid ) {
    
id -= TASK_HUD;
    
    static 
szHostName64 ];
    
get_cvar_string"hostname"szHostNamecharsmaxszHostName ) );

    
set_hudmessage6701990.00.2106.01.1 )
    
show_hudmessageid"Server: %s^nIP: %s"szHostNameg_szSeverIp );



Supremache 11-04-2020 14:26

Re: Help with turn on / off hud
 
What!? is there any problem ?

r0ma 11-04-2020 18:00

Re: Help with turn on / off hud
 
when one player disconnect and other player connect in that id that player have two or more tasks for display the hud.
also another edit: show_hudmessage set id

Supremache 11-04-2020 18:11

Re: Help with turn on / off hud
 
Quote:

Originally Posted by r0ma (Post 2723749)
when one player disconnect and other player connect in that id that player have two or more tasks for display the hud.
also another edit: show_hudmessage set id

Oops, you aright :)

nades 11-05-2020 02:45

Re: Help with turn on / off hud
 
Quote:

Originally Posted by r0ma (Post 2723727)
v 1.1 :crab:

PHP Code:

#include <amxmodx>

const TASK_HUD 12435;

new 
g_szSeverIp33 ];

public 
plugin_init() {
    
register_clcmd"say /hud""cmdShowHud" );
    
    
get_user_ip0g_szSeverIpcharsmaxg_szSeverIp ) );
}

// Toggle Showing Hud Message On / Off
public cmdShowHudid ) {
    if( 
task_existsid TASK_HUD ) )
        
remove_taskid TASK_HUD );
    else
        
set_task0.9"ShowHud"id TASK_HUD__"b" );
    
    
client_printidprint_chat"[AMXX] Hud %s"task_existsid TASK_HUD ) ? "ON" "OFF" );
    
    return 
PLUGIN_HANDLED;
}

public 
client_putinserverid ) {
    
set_task0.9"ShowHud"id TASK_HUD__"b" );
}

public 
client_disconnectid ) {
    if( 
task_existsid TASK_HUD ) )
        
remove_taskid TASK_HUD );
}

public 
ShowHudid ) {
    
id -= TASK_HUD;
    
    static 
szHostName64 ];
    
get_cvar_string"hostname"szHostNamecharsmaxszHostName ) );

    
set_hudmessage6701990.00.2106.01.1 )
    
show_hudmessageid"Server: %s^nIP: %s"szHostNameg_szSeverIp );



Thanks its working


All times are GMT -4. The time now is 05:21.

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