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

Enable/Disable


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Artifact
Veteran Member
Join Date: Jul 2010
Old 04-29-2012 , 10:30   Enable/Disable
Reply With Quote #1

What code can I put in this plugin to player enable / disable hud with chat command, I tried with bool but I cant
__________________
Artifact is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 04-29-2012 , 10:36   Re: Enable/Disable
Reply With Quote #2

Show your code.
__________________
<VeCo> is offline
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 04-29-2012 , 10:40   Re: Enable/Disable
Reply With Quote #3

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>

#define PLUGIN "Block hudmessage"
#define VERSION "1.0"
#define AUTHOR "Bilal"

new boolEnabled

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /enable""CmdEnable")
    
register_clcmd("say /disable""CmdDisable")
}

public 
CmdEnable(id)
{
    if (
is_user_connected(id))
    {
        
Enabled true
        show_hudmessage
(0"Hudmessages are now ON!")
        
client_print(idprint_chat"You succesfully enabled the hudmessage!")
    }
    else if (
Enabled == true)
    {
        
client_print(idprint_chat"You already have this enabled!")
    }
}

public 
CmdDisable(id)
{
    if (
is_user_connected(id))
    {
        
Enabled false
        show_hudmessage
(0"Hudmessages are now OFF!")
        
client_print(idprint_chat"You succesfully disabled the hudmessage!")
    }
    else if (
Enabled == false)
    {
        
client_print(idprint_chat"You already have this disabled!")
    }

Example with a bool.
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.

Last edited by Bilal Pro; 04-29-2012 at 10:50.
Bilal Pro is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 04-29-2012 , 10:48   Re: Enable/Disable
Reply With Quote #4

My code with bool:
PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "hud"
#define VERSION "1.0"
#define AUTHOR "good."

new bool:hud

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
set_task(1.0"ShowHud",_,_,_,"b")
    
register_clcmd("say /hide_hud""HideHud")
    
register_clcmd("say /show_hud""Show_Hud")
}

public 
HideHud()
{
    
hud false
    
return PLUGIN_HANDLED
}

public 
Show_Hud()
{
    
hud true
    
return PLUGIN_HANDLED
}

public 
ShowHud(id)
{
    if(
hud == true) {
        new 
currmap[31], NextMap[32];
        
get_mapname(currmap30)
        
get_cvar_string"amx_nextmap" NextMap 31 );
        
set_hudmessage(025500.010.2506.01.0)
        new 
iTimeLeft get_timeleft();
        if(
get_cvar_num("mp_timelimit") == 0)
        {
            
show_hudmessage(0"Server: %s^nTrenutna mapa: %s^nSledeca mapa: %s^nMapa se menja nakon ove runde!",get_cvar_pointer("hostname"), currmapNextMap)
        }
        else
        {
            
show_hudmessage(0"Server: %s^nTrenutna mapa: %s^nSledeca mapa: %s^nVreme do sledece mape: %d:%d",get_cvar_pointer("hostname"), currmapNextMapiTimeLeft 60iTimeLeft 60)
        }
    }
    else
        return 
PLUGIN_HANDLED
    
return PLUGIN_HANDLED

And without bool and without enable/disable plugin..
PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "hud"
#define VERSION "1.0"
#define AUTHOR "good."


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
set_task(1.0"ShowHud",_,_,_,"b")
}

public 
ShowHud(id)
{
    new 
currmap[31], NextMap[32];
    
get_mapname(currmap30)
    
get_cvar_string"amx_nextmap" NextMap 31 );
    
set_hudmessage(025500.010.2506.01.0)
    new 
iTimeLeft get_timeleft();
    if(
get_cvar_num("mp_timelimit") == 0)
    {
        
show_hudmessage(0"Server: %s^nTrenutna mapa: %s^nSledeca mapa: %s^nMapa se menja nakon ove runde!",get_cvar_pointer("hostname"), currmapNextMap)
    }
    else
    {
        
show_hudmessage(0"Server: %s^nTrenutna mapa: %s^nSledeca mapa: %s^nVreme do sledece mape: %d:%d",get_cvar_pointer("hostname"), currmapNextMapiTimeLeft 60iTimeLeft 60)
    }

Here is error with bool
__________________
Artifact is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 04-29-2012 , 10:59   Re: Enable/Disable
Reply With Quote #5

Something like this... You don't even need a variable.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "hud"
#define VERSION "1.0"
#define AUTHOR "good."
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /show_hud","cmd_showhud")
    
register_clcmd("say /hide_hud","cmd_hidehud")
    
    
set_task(1.0"ShowHud",123,.flags "b")
}
public 
cmd_showhud(id)
{
    if(
task_exists(123)) return
    
set_task(1.0"ShowHud",123,.flags "b")
}
public 
cmd_hidehud(id)
{
    if(!
task_exists(123)) return
    
remove_task(123)
}
public 
ShowHud()
{
    new 
currmap[31], NextMap[32];
    
get_mapname(currmap30)
    
get_cvar_string"amx_nextmap" NextMap 31 );
    
set_hudmessage(025500.010.2506.01.0)
    new 
iTimeLeft get_timeleft();
    if(
get_cvar_num("mp_timelimit") == 0)
    {
        
show_hudmessage(0"Server: %s^nTrenutna mapa: %s^nSledeca mapa: %s^nMapa se menja nakon ove runde!",get_cvar_pointer("hostname"), currmapNextMap)
    }
    else
    {
        
show_hudmessage(0"Server: %s^nTrenutna mapa: %s^nSledeca mapa: %s^nVreme do sledece mape: %d:%d",get_cvar_pointer("hostname"), currmapNextMapiTimeLeft 60iTimeLeft 60)
    }

__________________
<VeCo> is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 04-29-2012 , 11:02   Re: Enable/Disable
Reply With Quote #6

PHP Code:
    set_task(1.0"ShowHud",123,.flags "b")
}
public 
cmd_showhud(id)
{
    if(
task_exists(123)) return
    
set_task(1.0"ShowHud",123,.flags "b")

??? O.o description
__________________

Last edited by Artifact; 04-29-2012 at 11:02.
Artifact is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 04-29-2012 , 11:07   Re: Enable/Disable
Reply With Quote #7

Yeah, it's a little bit sucky, but I couldn't think of another good way (i would do it with entity)...
Anyway - I'm setting an index to the task (in this case it's 123) and checking if it exists and then remove it or set it again. I used the ".flags" to set the flags directly without these "_" ...
__________________

Last edited by <VeCo>; 04-29-2012 at 11:08.
<VeCo> is offline
Old 04-29-2012, 11:20
Artifact
This message has been deleted by Artifact.
Artifact
Veteran Member
Join Date: Jul 2010
Old 04-29-2012 , 12:33   Re: Enable/Disable
Reply With Quote #8

Now when I type /hide_hud, hud message was hide for whole server
Can you fix that?
(sorry for bump, I need it realy, sorry)
__________________

Last edited by Artifact; 04-29-2012 at 12:42. Reason: my apologize
Artifact is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 04-29-2012 , 12:52   Re: Enable/Disable
Reply With Quote #9

You want it to hide the message only for the player that typed the command?
__________________
<VeCo> is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 04-29-2012 , 12:53   Re: Enable/Disable
Reply With Quote #10

Yes
__________________
Artifact is offline
Reply



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 03:23.


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