The online racing simulator
How to : delayed Command
Hello,

I tried simple commande like:


Event OnResult( $flagConfirm )
DelayedCommand( 15, privMsg( "Test" ) );
EndEvent

But the result is not as expected. I have the display as soon I cross the line.
How does this command should work?

Thanks in advance
Quote from loconstant :Hello,

I tried simple commande like:


Event OnResult( $flagConfirm )
DelayedCommand( 15, privMsg( "Test" ) );
EndEvent

But the result is not as expected. I have the display as soon I cross the line.
How does this command should work?

Thanks in advance

Hi,
You can use the DelayedCommand to call a sub after a delay


Event OnResult( $flagConfirm )
DelayedCommand( [COLOR=red]15[/COLOR], test );
EndEvent

Sub test()
privMsg( "Test" );
EndSub

Or use a priv or a global button to cal a sub after a delay


openGlobalButton ("test1",40,0,28,4,4,[COLOR=red]15[/COLOR],16,"(%cpt%)",test);

Sub test()
privMsg( "Test" );
EndSub

Thanks.
So if i understand the delay only work when using a Sub method, right?

Loco
Quote from loconstant :Thanks.
So if i understand the delay only work when using a Sub method, right?

Loco

Yep, thats right. The DelayCommand wait x seconds and goes to a sub.
Hi Tim,

Ok I tried unsucessfully. This is done with the method onResult (and point system)

do you see somethin completly wrong in my piece of code?

DEFAULT:
BREAK;
ENDSWITCH
SetCurrentPlayerVar( "ps_points_total",ToNum(GetCurrentPlayerVar( "ps_points_total" ))+ GetCurrentPlayerVar( "ps_race_points" ) );
setUserStoredValue( "ps_points_total", GetCurrentPlayerVar( "ps_points_total" ) );

#Loco
DelayedCommand( 15, test1 );

EndEvent

Sub test1()
privMsg( "Test" );
EndSub


Thanks,
Frederic
Hello Loco,

PrivMsg can't be use with delayed command because delayed command it's not an user event.

Gai-Luron


PS : I know, i know i speak very well english tikon
Oki I understand very well
Quote from loconstant :Hi Tim,

Ok I tried unsucessfully. This is done with the method onResult (and point system)

do you see somethin completly wrong in my piece of code?

DEFAULT:
BREAK;
ENDSWITCH
SetCurrentPlayerVar( "ps_points_total",ToNum(GetCurrentPlayerVar( "ps_points_total" ))+ GetCurrentPlayerVar( "ps_race_points" ) );
setUserStoredValue( "ps_points_total", GetCurrentPlayerVar( "ps_points_total" ) );

#Loco
DelayedCommand( 15, test1 );

EndEvent

Sub test1()
privMsg( "Test" );
EndSub


Thanks,
Frederic

Hi,

you can try this to show "Test" after a delay of 15 sec.

openGlobalButton ("test",0,0,3,3,3,[COLOR=red]15[/COLOR],0," ",test);

Sub test()
privMsg( "Test" );
EndSub

Thanks Tim.
I managed to do it with "privdelayedcommand" function

Cheers
Kind of related...

I'm after changing the colour of a message in a button between 2 colour variations.

Here's the initial coding...

Quote :Event OnNewPlayerJoin( $userName ) # Player event
openPrivButton( "drewpitleave01",50,12,100,10,10,1,32,"^1R E M E M B E R !" );
wait (1);
openPrivButton( "drewpitleave02",50,12,100,10,10,1,32,"^7R E M E M B E R !" );
wait (1);
openPrivButton( "drewpitleave03",50,12,100,10,10,1,32,"^1R E M E M B E R !" );
wait (1);
openPrivButton( "drewpitleave04",50,12,100,10,10,1,32,"^7R E M E M B E R !" );
wait (1);
openPrivButton( "drewpitleave05",50,12,100,10,10,1,32,"^1R E M E M B E R !" );
wait (1);
openPrivButton( "drewpitleave06",50,12,100,10,10,1,32,"^7R E M E M B E R !" );
wait (1);
openPrivButton( "drewpitleave07",50,12,100,10,10,1,32,"^1R E M E M B E R !" );
EndEvent

I feel that if I can get the wait (1) (bad paracoding) command right - this might give me a message that flashes for 5 seconds.

I've read this thread - but don't seem to see anything that does what I want
It's impossible to have a wait in an event because if you do that, you stop LFSLapper waiting.
Use blinking button for now
Quote :openPrivButton( "drewpitleave01",50,12,100,10,10,1,ISB_DARK | ISB_BLINK,"^1R E M E M B E R !" );

ISB_BLINK and ISB_DARK are constant defined in const.lpr. Take a look at this file


You can use privdelayed command to do that but is very complicated and no very usefull.
Quote :openPrivButton( "drewpitleave05",50,12,100,10,10,1,32,"^1R E M E M B E R !" );

Buttons and what your line means
openPrivButton is for only driver to see, as against opening a global button for all to see (such as you'd get when race just about to start, etc)
drewpitleave05 is unique button id
50 left out of 200
12 down from top out of 200
100 is width of button
10 is height of button
10 is spacing in multiline text
1 is time in seconds button will appear (use -1 if you don't want button to disappear - or use sub routine to close it)
32 is the background colour and orientation (clear, light or dark, with text left, centred or right)
^1 is the colour of the text on the button (in this case Red [see LFSlapper.lpr file for info on what colour is which])
! REMEMBER is the text that will appear on button.

So if you want button (or in this case, proper word would be label) to appear for 5 seconds, you would have

Quote :openPrivButton( "drewpitleave05",50,12,100,10,10,5,32,"^1R E M E M B E R !" );

Fairly recently, Gai introduced the option for text to flash, so instead of the 32 after your time, use 40, and so you would now have

Quote :openPrivButton( "drewpitleave05",50,12,100,10,10,5,40,"^1R E M E M B E R !" );

See how you get on with it.
Quote from drew555 :Kind of related...

I'm after changing the colour of a message in a button between 2 colour variations.


For you colored button, this is the code who work, but you need to change to version 5.9.1.6 ( fixed one bug in delayed command )

CatchEvent OnNewPlayerJoin( $userName ) # Player event
GlobalVar $CurrRotation;
$CurrRotation = 0;
Color1( $userName );
EndCatchEvent
Sub color1( $userName )
openPrivButton( "drewpitleave02",50,12,100,10,10,-1,32,"^1R E M E M B E R !" );
privDelayedCommand( 1,color2 );
EndSub
Sub color2($userName)
openPrivButton( "drewpitleave02",50,12,100,10,10,-1,32,"^7R E M E M B E R !" );
$CurrRotation = $CurrRotation + 1;
IF( $CurrRotation < 5 ) THEN
privDelayedCommand( 1,color1 );
ELSE
ClosePrivButton( "drewpitleave02" );
ENDIF
EndSub

You have also this, but is BEUUURRRKKK

Quote : openPrivButton( "drewpitleave02",50,12,100,10,10,6,32,"^1R E M E M B E R !" );
openPrivButton( "drewpitleave03",50,12,100,10,10,5,32,"^7R E M E M B E R !" );
openPrivButton( "drewpitleave04",50,12,100,10,10,4,32,"^1R E M E M B E R !" );
openPrivButton( "drewpitleave05",50,12,100,10,10,3,32,"^7R E M E M B E R !" );
openPrivButton( "drewpitleave06",50,12,100,10,10,2,32,"^1R E M E M B E R !" );
openPrivButton( "drewpitleave07",50,12,100,10,10,1,32,"^7R E M E M B E R !" );

Quote from Gai-Luron :It's impossible to have a wait in an event because if you do that, you stop LFSLapper waiting.
Use blinking button for now


ISB_BLINK and ISB_DARK are constant defined in const.lpr. Take a look at this file


You can use privdelayed command to do that but is very complicated and no very usefull.

Awesome! Thank you

Quote from sinanju :Buttons and what your line means
openPrivButton is for only driver to see, as against opening a global button for all to see (such as you'd get when race just about to start, etc)
drewpitleave05 is unique button id
50 left out of 200
12 down from top out of 200
100 is width of button
10 is height of button
10 is spacing in multiline text
1 is time in seconds button will appear (use -1 if you don't want button to disappear - or use sub routine to close it)
32 is the background colour and orientation (clear, light or dark, with text left, centred or right)
^1 is the colour of the text on the button (in this case Red [see LFSlapper.lpr file for info on what colour is which])
! REMEMBER is the text that will appear on button.

So if you want button (or in this case, proper word would be label) to appear for 5 seconds, you would have

I had that bit sorted - but thank you anyway

Quote from sinanju :Fairly recently, Gai introduced the option for text to flash, so instead of the 32 after your time, use 40, and so you would now have

See how you get on with it.

Experiments are GO!

Quote from Gai-Luron :For you colored button, this is the code who work, but you need to change to version 5.9.1.6 ( fixed one bug in delayed command )

CatchEvent OnNewPlayerJoin( $userName ) # Player event
GlobalVar $CurrRotation;
$CurrRotation = 0;
Color1( $userName );
EndCatchEvent
Sub color1( $userName )
openPrivButton( "drewpitleave02",50,12,100,10,10,-1,32,"^1R E M E M B E R !" );
privDelayedCommand( 1,color2 );
EndSub
Sub color2($userName)
openPrivButton( "drewpitleave02",50,12,100,10,10,-1,32,"^7R E M E M B E R !" );
$CurrRotation = $CurrRotation + 1;
IF( $CurrRotation < 5 ) THEN
privDelayedCommand( 1,color1 );
ELSE
ClosePrivButton( "drewpitleave02" );
ENDIF
EndSub


I'll look into upgrading, thank you

Quote from Gai-Luron :You have also this, but is BEUUURRRKKK

With this new information, that code is going bye byes

Thank you all for your patience
Do you know how to cancel, cancel, close PrivDelayedCommand?


<?php 
openPrivButton
"InsuranceExtended",1,102,27,4,4,-1,16,"^7Insurance Extended",InsuranceExtended);

Sub InsuranceExtended$userName )

ClosePrivDelayedCommand2592000InsuranceClose);
            
EndSub
?>


Discontinue PrivDelayedCommand above, before, before the time runs out, rather (ahead of time). Below time end.


<?php 
closePrivButton
"Button1&Button2&Button3&Button4");
?>


<?php 
closePrivDelayedCommand
"ClosePrivDelayedCommand( 2592000, InsuranceClose)&ClosePrivDelayedCommand( 300,test)");
?>

The command is removeprivdelayedcommand used like this:


<?php 
PrivDelayedCommand
("delcom1"DoThisFunction() );
...
...
RemovePrivDelayedCommand("delcom1");
?>

Quote from Krayy :The command is removeprivdelayedcommand used like this:


<?php 
PrivDelayedCommand
("delcom1"DoThisFunction() );
...
...
RemovePrivDelayedCommand("delcom1");
?>


And why not seconds?


<?php 
PrivDelayedCommand
"delcom1",2592000InsuranceClose);
...
...
RemovePrivDelayedCommand("delcom1");
?>

Is this ok?
Yes, I had omitted the seconds as I writing it freehand as pseudo-code

FGED GREDG RDFGDR GSFDG