AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   More effective timer than this? (https://forums.alliedmods.net/showthread.php?t=128819)

GXLZPGX 06-05-2010 19:51

More effective timer than this?
 
PHP Code:

public thirtyoneid )
{
    
set_hudmessage(25500, -1.00.006.01.0)
    
show_hudmessage(id"NightCrawlers: 0:31")
    
set_task(1.0"thirty")
}

public 
thirtyid )
{
    
set_hudmessage(25500, -1.00.006.01.0)
    
show_hudmessage(id"NightCrawlers: 0:30")
    
set_task(1.0"thirty")


Any more effect timer than doing this 130 times?

wrecked_ 06-05-2010 20:00

Re: More effective timer than this?
 
Code:
#define TASKID  1996 new iTimer = 90 public plugin_init() {     set_task( 1.0, "TaskCount", TASKID, _, _, "b" ) } public TaskCount() {     set_hudmessage(255, 0, 0, -1.0, 0.0, 0, 6.0, 1.0)     show_hudmessage(id, "NightCrawlers: %i", iTimer--)         if( iTimer <= 0 )     {         remove_task( TASKID )     } }

GXLZPGX 06-05-2010 20:02

Re: More effective timer than this?
 
Quote:

Originally Posted by wrecked_ (Post 1200853)
Code:
#define TASKID  1996 new iTimer = 90 public plugin_init() {     set_task( 1.0, "TaskCount", TASKID, _, _, "b" ) } public TaskCount() {     set_hudmessage(255, 0, 0, -1.0, 0.0, 0, 6.0, 1.0)     show_hudmessage(id, "NightCrawlers: %i", iTimer--)         if( iTimer <= 0 )     {         remove_task( TASKID )     } }

I should kill myself. I sat there for 30 minutes redoing what I posted about 130 times. Thanks.. do you have a fuckin rope?

wrecked_ 06-05-2010 20:04

Re: More effective timer than this?
 
Quote:

Originally Posted by GXLZPGX (Post 1200857)
I should kill myself. I sat there for 30 minutes redoing what I posted about 130 times. Thanks.. do you have a fuckin rope?

Haha no problem. If you have any questions on things you should ask before just winging it, because while you may learn from fixing it yourself, you're also killing hours for each issue and you're also learning by being corrected.

Feel free to add me on Steam if you have any more issues like this.

wrecked_ 06-05-2010 20:23

Re: More effective timer than this?
 
Oops, sorry. This is fixed the fixed version.

Code:
#define TASKID  1996 new iTimer = 90 set_task( 1.0, "TaskCount", id + TASKID, _, _, "b" ) public TaskCount( TASK ) {     new id = TASK - TASKID         set_hudmessage(255, 0, 0, -1.0, 0.0, 0, 6.0, 1.0)     show_hudmessage(id, "NightCrawlers: %i", --iTimer)         if( iTimer <= 0 )     {         remove_task( TASK )     } }

Bugsy 06-05-2010 20:32

Re: More effective timer than this?
 
If you use flag a you can specify the number of times it repeats. The optimal way for this is with a thinking entity but no need to confuse you with that.

set_task( 1.0 , "function" , id + TASKID , _, _, "a" , 90 );

wrecked_ 06-05-2010 20:33

Re: More effective timer than this?
 
Fixed with a certain extra request via Steam and Bugsy's advice.

Code:
new iTimer = 90 yourfunc() {     iTimer = 90     set_task( 1.0, "TaskCount", _, _, _, "a", 90 ) } public TaskCount() {     set_hudmessage( 255, 0, 0, -1.0, 0.0, 0, 6.0, 1.0 )     show_hudmessage( 0, "NightCrawlers: %i:%i", floatround( ( iTimer / 60.0 ), floatround_floor ), ( iTimer-- % 60 ) ) }

Bugsy 06-05-2010 20:41

Re: More effective timer than this?
 
Just make sure to set iTimer to 90 each time you call that set_task line.

wrecked_ 06-05-2010 20:43

Re: More effective timer than this?
 
Quote:

Originally Posted by Bugsy (Post 1200890)
Just make sure to set iTimer to 90 each time you call that set_task line.

Done.

EDIT: Fixed with the timer numbers proper.

Code:
new iTimer = 90 yourfunc() {     iTimer = 90     set_task( 1.0, "TaskCount", _, _, _, "a", 90 ) } public TaskCount() {     set_hudmessage( 255, 0, 0, -1.0, 0.0, 0, 6.0, 1.0 )     new iNum =  floatround( float( iTimer % 60 ) ) // floats are not compatible with the modulo operator     show_hudmessage( 0, "NightCrawlers: %i:%s%i", floatround( ( iTimer / 60.0 ), floatround_floor ), ( 0 <= iNum < 10 ) ? "0" : "", iNum )     iTimer-- }


All times are GMT -4. The time now is 05:26.

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