Raised This Month: $32 Target: $400
 8% 

Solved Countdown hud message.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
4ever16
Veteran Member
Join Date: Apr 2015
Old 04-13-2020 , 20:16   Countdown hud message.
Reply With Quote #1

Simple plugin.

Admin write .smoke in chat.
HUD or DHUD message shows: Bla bla bla [ 120 seconds left ] Bla bla bla [ 119 seconds left ] etc...
And it count downs 120 seconds after 120 seconds HUD message desapears.

Last edited by 4ever16; 04-14-2020 at 19:11.
4ever16 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-13-2020 , 21:48   Re: Countdown hud message.
Reply With Quote #2

No thoroughly tested
PHP Code:

#include <amxmodx>
#include <engine>

new const Version[] = "0.1";

new 
g_Entityg_iNumSmokesMAX_PLAYERS ] , g_Smoking g_pNumSmokes bool:g_bThinking;

public 
plugin_init() 
{
    
register_plugin"Smoke Plugin" Version "bugsy" );
    
    
g_pNumSmokes register_cvar"sp_numsmokes" "120" );
     
    
register_clcmd"say .smoke" "SaySmoke" );
    
    
g_Entity create_entity"info_target" );
    
entity_set_stringg_Entity EV_SZ_classname "smoke_entity" );
    
register_think"smoke_entity" "EntityThink" );
}

public 
client_disconnectid )
{
    
g_Smoking &=  ~( << ( id 31 ) );
    
g_iNumSmokesid ] = 0;
}

public 
SaySmokeid )
{    
    if ( !
is_user_adminid ) )
        return 
PLUGIN_HANDLED;

    if ( !( 
g_Smoking & ( << ( id 31 ) ) ) )
    {
        
g_iNumSmokesid ] = get_pcvar_numg_pNumSmokes );
        
g_Smoking |= ( << ( id 31 ) );
    }
    else
    {
        
client_printid print_chat "* Smoke count-down already running" );
        return 
PLUGIN_HANDLED;
    }

    if ( !
g_bThinking )
        
entity_set_floatg_Entity EV_FL_nextthink , ( get_gametime() + 1.1 ) );
    
    return 
PLUGIN_HANDLED;
}
    
public 
EntityThinkiEntity )
{
    if ( 
iEntity == g_Entity )
    {
        new 
iPlayers32 ] , iNum id;
        
        
get_playersiPlayers iNum "ach" );
        
        for ( new 
iNum i++ )
        {
            
id iPlayers];

            if ( 
g_Smoking & ( << ( id 31 ) ) )
            {
                
set_hudmessage255 255 , -1.0 0.30 0.0 1.0 )
                
show_hudmessageid "[ %d second%s left ]" g_iNumSmokesid ] , g_iNumSmokesid ] > "s" "" );
                
                if ( --
g_iNumSmokesid ] <= )
                {
                    
g_Smoking &= ~( << ( id 31 ) );
                }
            }
        }
        
        if ( 
g_Smoking )
        {
            
entity_set_floatg_Entity EV_FL_nextthink , ( get_gametime() + 1.1 ) );
            
g_bThinking true;
        }
        else
        {
            
g_bThinking false;
        }
    }

__________________

Last edited by Bugsy; 04-14-2020 at 21:35.
Bugsy is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 04-14-2020 , 07:44   Re: Countdown hud message.
Reply With Quote #3

Working good but every user can write that.

I need so only admin can write that.

Last edited by 4ever16; 04-14-2020 at 07:45.
4ever16 is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 04-14-2020 , 07:48   Re: Countdown hud message.
Reply With Quote #4

Quote:
Originally Posted by 4ever16 View Post
Working good but every user can write that.

I need so only admin can write that.
PHP Code:
if(!is_user_admin(id))
        return 
PLUGIN_HANDLED 
after
Code:
public SaySmoke( id )
{
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
4ever16
Veteran Member
Join Date: Apr 2015
Old 04-14-2020 , 19:11   Re: Countdown hud message.
Reply With Quote #5

OK thanks!
4ever16 is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 05-04-2020 , 02:16   Re: Countdown hud message.
Reply With Quote #6

Got some errors but solved it by adding #include <amxmisc> in the top.

Last edited by 4ever16; 05-04-2020 at 02:17.
4ever16 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 23:40.


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