AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [REQ] Closed Hud Message By the player (https://forums.alliedmods.net/showthread.php?t=322219)

alferd 03-20-2020 04:19

[REQ] Closed Hud Message By the player
 
I want a plugin that allows each player to disable their message

For example, this code is active for up to 40 seconds
PHP Code:

public plugin_init()
{
            
RegisterHam(Ham_Spawn"player""ads"1
}

public 
ads(id)
{
            
set_hudmessage(00255, -1.00.2906.040.0);
        
show_hudmessage(id"Welcom To Public Server^nAds: xxxx^nxxxxxx^nxxxxxx");


Ten seconds until it is deactivated, the player type (say /messagestop) and the message is closed

iceeedr 03-20-2020 07:40

Re: [REQ] Closed Hud Message By the player
 
I wrote by phone, that is, not tested and there may be errors.

PHP Code:

#include <amxmodx>

new bool:UserMsg[33]

new 
AdsCvarAdsHandler
public plugin_init()
{
    
register_clcmd("say /messagestop""MsgHandler")
    
AdsCvar register_cvar("ads_time""40")
}

public 
client_putinserver(id)
{
    if(!
is_user_bot(id))
    {
        
AdsHandler get_pcvar_num(AdsCvar)
        
UserMsg[id] = true
        CountDown
(id)
    }
}

public 
CountDown(id)
{
    if(!
UserMsg[id]) return 
    
    
AdsHandler --
    
    if(
AdsHandler 0)
    {
        
set_hudmessage(00255, -1.00.2906.040.0);
        
show_hudmessage(id"Welcom To Public Server^nAds: xxxx^nxxxxxx^nxxxxxx")
        
set_task(1.0"CountDown"id)
    }
    else
    {
        
remove_task(id)
    }
}

public 
MsgHandler(id)
{
    
UserMsg[id] = false
    
    client_print
(idprint_chat"You %s the ads."UserMsg[id] ? "enable" "disable")
    return 
PLUGIN_HANDLED



Napoleon_be 03-20-2020 07:48

Re: [REQ] Closed Hud Message By the player
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "WelcomeMsg"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

#define MSGID 123479

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd("say /messagestop""DisableMessage");
    
register_clcmd("say /messagestart""EnableMessage");
}

public 
DisableMessage(id)
{
    if(
task_exists(id MSGID))
    {
        
remove_task(id MSGID);
    }
}

public 
EnableMessage(id)
{
    if(!
task_exists(id MSGID))
    {
        
set_task(40.0"ShowMessage"id MSGID__"b");
    }
}

public 
ShowMessage(id)
{
    
id -= MSGID;
    
set_hudmessage(00255, -1.00.2906.040.0);
    
show_hudmessage(id"Welcom To Public Server^nAds: xxxx^nxxxxxx^nxxxxxx"); 
}

public 
client_putinserver(id)
{
    
set_task(40.0"ShowMessage"id MSGID__"b");
}

public 
client_disconnect(id)
{
    if(
task_exists(id MSGID))
    {
        
remove_task(id MSGID)
    }



alferd 03-20-2020 12:14

Re: [REQ] Closed Hud Message By the player
 
Quote:

Originally Posted by Napoleon_be (Post 2687730)
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "WelcomeMsg"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

#define MSGID 123479

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd("say /messagestop""DisableMessage");
    
register_clcmd("say /messagestart""EnableMessage");
}

public 
DisableMessage(id)
{
    if(
task_exists(id MSGID))
    {
        
remove_task(id MSGID);
    }
}

public 
EnableMessage(id)
{
    if(!
task_exists(id MSGID))
    {
        
set_task(40.0"ShowMessage"id MSGID__"b");
    }
}

public 
ShowMessage(id)
{
    
id -= MSGID;
    
set_hudmessage(00255, -1.00.2906.040.0);
    
show_hudmessage(id"Welcom To Public Server^nAds: xxxx^nxxxxxx^nxxxxxx"); 
}

public 
client_putinserver(id)
{
    
set_task(40.0"ShowMessage"id MSGID__"b");
}

public 
client_disconnect(id)
{
    if(
task_exists(id MSGID))
    {
        
remove_task(id MSGID)
    }



this is good, But I type (say /messagestop) the message will not be disabled
Disables after the end of time
I want to disable it immediately when typing (say /messagestop)

iceeedr 03-20-2020 19:59

Re: [REQ] Closed Hud Message By the player
 
Quote:

Originally Posted by alferd (Post 2687757)
this is good, But I type (say /messagestop) the message will not be disabled
Disables after the end of time
I want to disable it immediately when typing (say /messagestop)

Did you test my code?

alferd 03-21-2020 04:14

Re: [REQ] Closed Hud Message By the player
 
Quote:

Originally Posted by iceeedr (Post 2687794)
Did you test my code?

I'm testing now

alferd 03-21-2020 04:34

Re: [REQ] Closed Hud Message By the player
 
Quote:

Originally Posted by iceeedr (Post 2687794)
Did you test my code?

It didn't work, not even the message

iceeedr 03-21-2020 17:09

Re: [REQ] Closed Hud Message By the player
 
Quote:

Originally Posted by alferd (Post 2687811)
It didn't work, not even the message

Code revised and working now, please test.

alferd 03-22-2020 04:38

Re: [REQ] Closed Hud Message By the player
 
Quote:

Originally Posted by iceeedr (Post 2687902)
Code revised and working now, please test.

It still didn't work,not even the message

alferd 03-22-2020 04:40

Re: [REQ] Closed Hud Message By the player
 
Quote:

Originally Posted by iceeedr (Post 2687902)
Code revised and working now, please test.

It still didn't work,not even the message,


All times are GMT -4. The time now is 18:58.

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