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

Solved Help with turn on / off hud


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nades
Junior Member
Join Date: Oct 2020
Old 11-04-2020 , 02:36   Help with turn on / off hud
Reply With Quote #1

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.

Last edited by nades; 11-05-2020 at 02:46.
nades is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-04-2020 , 14:07   Re: Help with turn on / off hud
Reply With Quote #2

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);     } }
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
r0ma
Senior Member
Join Date: Apr 2012
Location: Great Tomb of Nazarick
Old 11-04-2020 , 14:24   Re: Help with turn on / off hud
Reply With Quote #3

Quote:
Originally Posted by Supremache View Post
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

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 );

__________________
Discord:FluffyDeveloper#4753
Github: https://github.com/francoromaniello
AMX-ES: https://amxmodx-es.com/r0ma'

Last edited by r0ma; 11-04-2020 at 18:17. Reason: show_hudmessage id also get_user_ip on plugin_init
r0ma is offline
Send a message via MSN to r0ma
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-04-2020 , 14:26   Re: Help with turn on / off hud
Reply With Quote #4

What!? is there any problem ?
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
r0ma
Senior Member
Join Date: Apr 2012
Location: Great Tomb of Nazarick
Old 11-04-2020 , 18:00   Re: Help with turn on / off hud
Reply With Quote #5

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
__________________
Discord:FluffyDeveloper#4753
Github: https://github.com/francoromaniello
AMX-ES: https://amxmodx-es.com/r0ma'
r0ma is offline
Send a message via MSN to r0ma
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-04-2020 , 18:11   Re: Help with turn on / off hud
Reply With Quote #6

Quote:
Originally Posted by r0ma View Post
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
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
nades
Junior Member
Join Date: Oct 2020
Old 11-05-2020 , 02:45   Re: Help with turn on / off hud
Reply With Quote #7

Quote:
Originally Posted by r0ma View Post
v 1.1

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
nades 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 01:11.


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