Raised This Month: $ Target: $400
 0% 

Hud msg & timeleft help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BeasT
Senior Member
Join Date: Apr 2007
Location: Lithuania
Old 03-21-2009 , 08:22   Hud msg & timeleft help
Reply With Quote #1

How can I make the hud msg only appear when there are 2 minutes left on the map? And the hud msg counting should stay on the screen till map change.

PHP Code:
public show_timer()

    new 
nextmap[32
    
get_cvar_string("amx_nextmap",nextmap,31
    new 
timeleft get_timeleft()
    
set_hudmessage(255,255,255,0.75,0.05,01.01.00.10.213
    
show_hudmessage(0,"Time remaining: %d:%02d^nNext map: %s",timeleft 60timeleft 60,nextmap
    return 
PLUGIN_CONTINUE 


public 
plugin_init() 

    
register_plugin("TimeProjector","0.1","ST4life"
    
set_task(0.1"show_timer",0,"",0,"b")
    return 
PLUGIN_CONTINUE 

BeasT is offline
Send a message via Skype™ to BeasT
TheRadiance
Senior Member
Join Date: Nov 2007
Location: Kazakhstan
Old 03-21-2009 , 08:24   Re: Hud msg & timeleft help
Reply With Quote #2

PHP Code:
public show_timer()

    if ( 
get_timeleft( ) <= 120 )
    {
        new 
nextmap[32
        
get_cvar_string("amx_nextmap",nextmap,31
        new 
timeleft get_timeleft()
        
set_hudmessage(255,255,255,0.75,0.05,01.01.00.10.213
        
show_hudmessage(0,"Time remaining: %d:%02d^nNext map: %s",timeleft 60timeleft 60,nextmap
    }
    
set_task(1.0"show_timer"0)


public 
plugin_init() 

    
register_plugin("TimeProjector","0.1","ST4life"
    
set_task(0.1"show_timer",0,"",0,"b")
    return 
PLUGIN_CONTINUE 


Last edited by TheRadiance; 03-21-2009 at 08:27.
TheRadiance is offline
Send a message via ICQ to TheRadiance
BeasT
Senior Member
Join Date: Apr 2007
Location: Lithuania
Old 03-22-2009 , 14:33   Re: Hud msg & timeleft help
Reply With Quote #3

I think your edit makes cpu usage go up to 100%.
Note: I'm using soccerjam mod where mp_timelimit gets reseted after every goal. When the games is finished mp_timelimit is set to 2min~ to change the map.

Last edited by BeasT; 03-22-2009 at 15:01.
BeasT is offline
Send a message via Skype™ to BeasT
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-22-2009 , 15:00   Re: Hud msg & timeleft help
Reply With Quote #4

I wrote a similar plugin for a member that will start the countdown when there are 10 seconds left and make any alive players explode at round end. You can modify it for what you need.

http://forums.alliedmods.net/showthread.php?t=85354
__________________
Bugsy is offline
BeasT
Senior Member
Join Date: Apr 2007
Location: Lithuania
Old 03-23-2009 , 10:57   Re: Hud msg & timeleft help
Reply With Quote #5

I'm not that good at coding. I just need a simple plugin as I wrote above. Someone?
BeasT is offline
Send a message via Skype™ to BeasT
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-23-2009 , 11:29   Re: Hud msg & timeleft help
Reply With Quote #6

It seems as if there is a 12 second offset from the start of map to when the actual map-time countdown begins. This is probably caused by the restarting of map when all players connect after a map change and "game commencing" appears. There is probably a calculation method used to determine this number but it is consistently 12 seconds on my server.

PHP Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init() 

    
register_plugin"Map Time Left" "0.1" "bugsy" );
    
set_task( ( get_cvar_float("mp_timelimit") * 60.0 ) - 108.0 "set_timer" );
}

public 
show_timer()

    new 
szNextMap[32];
    
    
get_cvar_string"amx_nextmap" szNextMap 31 );
    new 
iTimeLeft get_timeleft();
    
    
set_hudmessage255 255 255 0.75 0.05 1.0 1.0 0.1 0.2 13 ); 
    
show_hudmessage"Time remaining: %d:%02d^nNext map: %s" iTimeLeft 60 iTimeLeft 60 szNextMap );
    
    return 
PLUGIN_CONTINUE 


public 
set_timer()
{
    
set_task1.0 "show_timer" ___"b" );

__________________

Last edited by Bugsy; 03-23-2009 at 11:31.
Bugsy 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 08:58.


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