PDA

View Full Version : How to : delayed Command


loconstant
28th October 2009, 06:48
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

Tim NL
28th October 2009, 10:50
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( 15, 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,15,16,"(%cpt%)",test);

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

loconstant
28th October 2009, 13:49
Thanks.
So if i understand the delay only work when using a Sub method, right?

Loco

Tim NL
28th October 2009, 17:04
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.:)

loconstant
29th October 2009, 08:52
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

Gai-Luron
29th October 2009, 16:41
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 :p tikon :tilt:

loconstant
30th October 2009, 06:18
Oki I understand very well :razz:

Tim NL
30th October 2009, 09:15
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,15,0," ",test);

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

loconstant
30th October 2009, 19:14
Thanks Tim.
I managed to do it with "privdelayedcommand" function

Cheers

drew555
23rd December 2009, 16:16
Kind of related...

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

Here's the initial coding...

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 !" );
EndEventI 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 :(

Gai-Luron
23rd December 2009, 17:34
It's impossible to have a wait in an event because if you do that, you stop LFSLapper waiting.
Use blinking button for now
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.

sinanju
23rd December 2009, 17:51
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

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

openPrivButton( "drewpitleave05",50,12,100,10,10,5,40,"^1R E M E M B E R !" );See how you get on with it.

Gai-Luron
23rd December 2009, 20:47
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

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 !" );

drew555
24th December 2009, 10:50
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 :D

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 :D

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!

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 :)

You have also this, but is BEUUURRRKKK

With this new information, that code is going bye byes :D

Thank you all for your patience :D

LFSCruise
31st October 2011, 20:00
Do you know how to cancel, cancel, close PrivDelayedCommand?


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

Sub InsuranceExtended( $userName )

ClosePrivDelayedCommand( 2592000, InsuranceClose);

EndSub


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

closePrivButton( "Button1&Button2&Button3&Button4");
closePrivDelayedCommand( "ClosePrivDelayedCommand( 2592000, InsuranceClose)&ClosePrivDelayedCommand( 300,test)");

Krayy
31st October 2011, 23:38
The command is removeprivdelayedcommand used like this:


PrivDelayedCommand("delcom1", DoThisFunction() );
...
...
RemovePrivDelayedCommand("delcom1");

LFSCruise
1st November 2011, 01:29
The command is removeprivdelayedcommand used like this:


PrivDelayedCommand("delcom1", DoThisFunction() );
...
...
RemovePrivDelayedCommand("delcom1");


And why not seconds?

PrivDelayedCommand( "delcom1",2592000, InsuranceClose);
...
...
RemovePrivDelayedCommand("delcom1");

Is this ok?

Krayy
1st November 2011, 01:44
Yes, I had omitted the seconds as I writing it freehand as pseudo-code