Raised This Month: $ Target: $400
 0% 

Loop delay help (sv_restart for x seconds)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hunter_stth
Junior Member
Join Date: Apr 2009
Location: Serbia
Old 06-28-2009 , 08:58   Loop delay help (sv_restart for x seconds)
Reply With Quote #1

How to make loop delay in this code?
I want to run this loop in a 1 second delay.

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

#define PLUGIN "Restart and live!"
#define VERSION "1.0"
#define AUTHOR "HunTeR"

new roundcount = 0
new i = 60
public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)    
    register_logevent("RoundEnd", 2, "1=Round_End")
    register_logevent("RoundStart", 2, "1=Round_Start")
}
public RoundEnd() {
    if(roundcount == 0) {
     server_cmd("sv_restart 1")
     roundcount++
    }
}
public RoundStart() {
    if(roundcount == 0) {
		for(i=60;i>=0;i--) {
			if(i == 1) {
				set_hudmessage(0, 255, 0, -1.0, -1.0, 0, 6.0, 12.0)
				show_hudmessage(0, "Live for 1 second!")
				console_print(0, "Live for 1 second!")
			}
			else {
				set_hudmessage(0, 255, 0, -1.0, -1.0, 0, 6.0, 12.0)
				show_hudmessage(0, "Live for %d seconds!",i)
				console_print(0, "Live for %d seconds!",i)
			}

		
		}
    }
	else if(roundcount == 1) {
        set_hudmessage(0, 255, 0, -1.0, -1.0, 0, 6.0, 12.0)
        show_hudmessage(0, "Game is now Live!!!")
	}
}
Sorry for my bad english!

Last edited by hunter_stth; 06-28-2009 at 10:15.
hunter_stth is offline
Old 06-28-2009, 09:17
vato loco [GE-S]
This message has been deleted by vato loco [GE-S]. Reason: ...
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-28-2009 , 09:57   Re: Loop delay help (sv_restart for x seconds)
Reply With Quote #2

http://www.amxmodx.org/funcwiki.php?go=func&id=253

set_task ( 1.0 , "loopfunc" , _, _, _, "a" , 60 )

In loopfunc function, use a static variable as your loop index. The above line will call loopfunc once a second 60 times.
__________________
Bugsy is offline
hunter_stth
Junior Member
Join Date: Apr 2009
Location: Serbia
Old 06-28-2009 , 11:21   Re: Loop delay help (sv_restart for x seconds)
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
http://www.amxmodx.org/funcwiki.php?go=func&id=253

set_task ( 1.0 , "loopfunc" , _, _, _, "a" , 60 )

In loopfunc function, use a static variable as your loop index. The above line will call loopfunc once a second 60 times.
I don't understand you
hunter_stth is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-28-2009 , 13:31   Re: Loop delay help (sv_restart for x seconds)
Reply With Quote #4

Not sure exactly what your trying to do but this will print out time in seconds up to 60.

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

#define PLUGIN "Restart and live!"
#define VERSION "1.0"
#define AUTHOR "HunTeR"

new g_iRoundCount;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)    
    
register_logevent("RoundEnd"2"1=Round_End")
    
register_logevent("RoundStart"2"1=Round_Start")
}

public 
RoundEnd() 
{
    if( !
g_iRoundCount 
    {
        
server_cmd("sv_restart 1")
        
g_iRoundCount++
    }
}

public 
RoundStart() 
{
    if ( !
g_iRoundCount  
    {
        
set_task 1.0 "DisplayLive" ___"a" 60 
    }
    else if ( 
g_iRoundCount == 
    {
        
set_hudmessage(02550, -1.0, -1.006.012.0)
        
console_print(0"Game is now Live!!!" )
        
show_hudmessage(0"Game is now Live!!!")
    }
}

public 
DisplayLive()
{
    static 
iSecond;
    static 
szMsg30 ];

    
iSecond++;
    
    
formatexszMsg 29 "Live for %d second%s!" iSecond , ( iSecond == ) ? "" "s" ); 
    
    
set_hudmessage(02550, -1.0, -1.006.012.0)
    
show_hudmessage(0szMsg )

    
console_print(0szMsg )

    if ( 
iSecond == 60 )
        
iSecond 0;

__________________
Bugsy is offline
hunter_stth
Junior Member
Join Date: Apr 2009
Location: Serbia
Old 06-28-2009 , 16:16   Re: Loop delay help (sv_restart for x seconds)
Reply With Quote #5

Thanks a lot!

+karma
hunter_stth 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 15:28.


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