The online racing simulator
How to send/retreive data to/from database
i need to create a database,use Lapper.lpr. it's possible or just only change code and compile?
Quote from Bass-Driver :LFSLapper has his own databases.

There are 3 types of databases.
  • - Driftscoring: PBdrift.dbs
  • - PB laptimes: gripDB.dbs
  • - Lapper scripts to save User variables: storedvalue.dbs
Topics how to save/load user variables to/from the 'storedvalue' database.
https://www.lfs.net/forum/thread/71158
https://www.lfs.net/forum/thread/90475

my English is very bad...i am have trouble whith documentation.please write example for me,how i can save value $total or any. and how read it from base
Here's a quick example.
Don't expect a quick answer after this message, as I'm off to bed now.


This can go in the OnConnect or OnConnectClose event:

### Get UserName and search in storedvalue.dbs for saved values for this user ###
$userName = GetCurrentPlayerVar( "UserName" );

SetCurrentPlayerVar( "total",GetStoredValue( $userName . "total" ) );
### End ###

If the value would be empty (because someone is new on your server, you can check if it is and give it a default value:

### Set default values if no values are loaded ###
IF ( GetCurrentPlayerVar( "config_pb_display_gui" ) == "")
THEN
SetCurrentPlayerVar( "total",0 ); # Set default value to 0
ENDIF
### End ###

This should go in a seperate event to save the value or values back to the database:

$userName = GetCurrentPlayerVar( "UserName" );
SetStoredValue( $userName . "total", GetCurrentPlayerVar( "total" ) );

Have a look in my pitboard or reg_system script to see how I do this.
Quote from Yisc[NL] :Here's a quick example.
Don't expect a quick answer after this message, as I'm off to bed now.


This can go in the OnConnect or OnConnectClose event:

### Get UserName and search in storedvalue.dbs for saved values for this user ###
$userName = GetCurrentPlayerVar( "UserName" );

SetCurrentPlayerVar( "total",GetStoredValue( $userName . "total" ) );
### End ###

If the value would be empty (because someone is new on your server, you can check if it is and give it a default value:

### Set default values if no values are loaded ###
IF ( GetCurrentPlayerVar( "config_pb_display_gui" ) == "")
THEN
SetCurrentPlayerVar( "total",0 ); # Set default value to 0
ENDIF
### End ###

This should go in a seperate event to save the value or values back to the database:

$userName = GetCurrentPlayerVar( "UserName" );
SetStoredValue( $userName . "total", GetCurrentPlayerVar( "total" ) );

Have a look in my pitboard or reg_system script to see how I do this.

I try save values,when i cross the finish

setCurrentPlayerVar( "recomended",GetStoredValue( GetCurrentPlayerVar( "UserName" ) . "recomended" ) );

and i try write it in chart
CASE "!drf":
globalMsg(GetStoredValue( GetCurrentPlayerVar( "UserName" ) . "recomended" ));

what wrong?
With the code you supplied, nothing is saved, so that's what's wrong Smile
In the first line you gave, you are setting the value 'recomended' by retrieving it from the database.
In the second piece of code, you are retrieving it again from the database and display the value as a global message.
When you want to write value 'recomended' to the database, the code should be like this:

$userName = GetCurrentPlayerVar( "UserName" );
SetStoredValue( $userName . "recomended", GetCurrentPlayerVar( "recomended" ) );

In case you are willing to learn something about the English language, recommended has to be written with double M Smile
Quote from Yisc[NL] :With the code you supplied, nothing is saved, so that's what's wrong Smile
In the first line you gave, you are setting the value 'recomended' by retrieving it from the database.
In the second piece of code, you are retrieving it again from the database and display the value as a global message.
When you want to write value 'recomended' to the database, the code should be like this:

$userName = GetCurrentPlayerVar( "UserName" );
SetStoredValue( $userName . "recomended", GetCurrentPlayerVar( "recomended" ) );

In case you are willing to learn something about the English language, recommended has to be written with double M Smile

it's work!thx))) and one stupid questions)how i can write it in another datebase like DriftPB.dbs?
There is no way to write things into DriftPB.dbs or gripDB.dbs
Everything you want to store/retrieve has to go into storedvalue.dbs
Quote from Yisc[NL] :There is no way to write things into DriftPB.dbs or gripDB.dbs
Everything you want to store/retrieve has to go into storedvalue.dbs

thx u)
Quote from Yisc[NL] :There is no way to write things into DriftPB.dbs or gripDB.dbs
Everything you want to store/retrieve has to go into storedvalue.dbs

sorry again! but...
it's possible do timer?
for example if i need automatic startLights whith interval 2sec?
Quote from Bass-Driver :something like this?

look only to the startlights.

https://www.lfs.net/forum/post/1919394#post1919394

YES!!!!
Sub YellowLight()
startlightcontrol(5,149,10,2); #Yellow Startlight, Lightindentifier = 10
HostDelayedCommand( 2, OpenGate); #Go to Open Gate sub after 2 seconds
EndSub

HostDelayedCommand( X, Y);
X-time in second?
Y-function,wich be run?
yes exacly Thumbs up
Quote from Bass-Driver :yes exacly Thumbs up

thanx))it's very well))and last questions today=D
i need cath message from me.somethink like this:


!1-st XXXXXXXXXXX//it's message in chart
!2-nd YYYYYYYYYYY//it's message in chart

where XXXXXXX and YYYYYYYY -nickname

result:

openGlobalButton( "Lead",50,70,90,50,1,4,0,XXXXXXXXX);
openGlobalButton( "2-nd",50,70,90,50,1,4,0,YYYYYYYYY);
I think you are looking for this:

https://www.lfs.net/forum/thread/64558

If so , this addon is already added in LFSLapper.

EDIT: @num13er

Please create a for each question a new topic.
But before you create a new topic , Use the search function on this forum first.
Why? There are many examples/scripts that can help you with lapper.
Quote from Bass-Driver :I think you are looking for this:

https://www.lfs.net/forum/thread/64558

If so , this addon is already added in LFSLapper.

EDIT: @num13er

Please create a for each question a new topic.
But before you create a new topic , Use the search function on this forum first.
Why? There are many examples/scripts that can help you with lapper.

thx.but it's very dificult to formulate trouble to use search)))
Quote from Bass-Driver :yes exacly Thumbs up

its not working(((((

CASE "!1":
IF ( UserIsAdmin( $userName ) == 1 )
THEN
startlightcontrol (5,149,1,1);
HostDelayedCommand( 3,cl);
ENDIF
BREAK;
Sub cl()
openGlobalButton( "winner_title",78,137,63,19,4,3,3,"READY ");
startlightcontrol (5,149,1,2);
HostDelayedCommand( 3,cl2);
EndSub

Sub cl2()
openGlobalButton( "winner_title2",78,137,63,19,4,3,3,"GO ");
startlightcontrol (5,149,1,8);
EndSub
You must add the case command in the OnMSO( $userName, $text ) event

Should look like this:

Event OnMSO( $userName, $text ) # Player event

$idxOfFirtsSpace = indexOf( $text, " ");


IF( $idxOfFirtsSpace == -1 ) THEN
$command = $text;
$argv = "";
ELSE
$command = subStr( $text,0,$idxOfFirtsSpace );
$argv = trim( subStr( $text,$idxOfFirtsSpace ) );
ENDIF

SWITCH( $command )

CASE "!1":
IF ( UserIsAdmin( $userName ) == 1 )
THEN
startlightcontrol (5,149,1,1);
HostDelayedCommand( 3,cl);
ENDIF
BREAK;

ENDSWITCH
EndEvent


Sub cl()
openGlobalButton( "winner_title",78,137,63,19,4,3,3,"READY ");
startlightcontrol (5,149,1,2);
HostDelayedCommand( 3,cl2);
EndSub

Sub cl2()
openGlobalButton( "winner_title2",78,137,63,19,4,3,3,"GO ");
startlightcontrol(5,149,1,8);
EndSub

Quote from Bass-Driver :You must add the case command in the OnMSO( $userName, $text ) event

Should look like this:

Event OnMSO( $userName, $text ) # Player event

$idxOfFirtsSpace = indexOf( $text, " ");


IF( $idxOfFirtsSpace == -1 ) THEN
$command = $text;
$argv = "";
ELSE
$command = subStr( $text,0,$idxOfFirtsSpace );
$argv = trim( subStr( $text,$idxOfFirtsSpace ) );
ENDIF

SWITCH( $command )

CASE "!1":
IF ( UserIsAdmin( $userName ) == 1 )
THEN
startlightcontrol (5,149,1,1);
HostDelayedCommand( 3,cl);
ENDIF
BREAK;

ENDSWITCH
EndEvent


Sub cl()
openGlobalButton( "winner_title",78,137,63,19,4,3,3,"READY ");
startlightcontrol (5,149,1,2);
HostDelayedCommand( 3,cl2);
EndSub

Sub cl2()
openGlobalButton( "winner_title2",78,137,63,19,4,3,3,"GO ");
startlightcontrol(5,149,1,8);
EndSub


I did once, but it does not work, and therefore wrote
in LFSLapper V7.0.4.3
this feature is available?
The startlightcontrol() function exist since version 7.0.4.0


-Be sure you have optimised all objects in autocross editor
-Check the ERR files for any errors.(Bin/Default/Logs/XXX.XXX.XXX.XXX-YYYYY-ERR.txt)

try this instead:

PrivDelayedCommand();

Sub cl($keyflags)
Endsub
Sub cl2($keyflags)
EndSub

Quote from Bass-Driver :The startlightcontrol() function exist since version 7.0.4.0


-Be sure you have optimised all objects in autocross editor
-Check the ERR files for any errors.(Bin/Default/Logs/XXX.XXX.XXX.XXX-YYYYY-ERR.txt)

try this instead:

PrivDelayedCommand();

Sub cl($keyflags)
Endsub
Sub cl2($keyflags)
EndSub


YES!!))NOW it's work!ths

FGED GREDG RDFGDR GSFDG