The online racing simulator
Vehicle refresh error in tracker
Hello, it's me again. When I use the tool refresh command in the viewer it works. Actually, I can't use this. The error in the ERR log is as follows: 1/26/2024 11:06:39 PM -> Syntax error: in file ".\default\LFSLapper.lpr" at line #1509
Warning on Command: 'joinrequest' Cannot spawn spectated players
Function 'onmso' script aborted //////// 1/26/2024 11:10:08 PM -> Syntax error: in file ".\default\LFSLapper.lpr" at line #1508
Token not catched
Function 'onmso' script aborted




CASE "!jrr":
globalMsg( GetCurrentPlayerVar("NickName") . " ^7Aracini yeniledi, ^1!jrr ^7yazarak sende yenileyebilirsin.");
$X_Axis = getcurrentplayervar("X"); #X axis SpawnPoint
$Y_Axis = getcurrentplayervar("Y"); #Y axis SpawnPoint
$Z_Axis = getcurrentplayervar("Z"); #Z axis SpawnPoint
$Flags = 128; #Move/Reset car (128) else (0)
$Heading = 0; #Heading of the players car at Spawnpoint
$UCID = 0; #Connection's unique id (0 = host)
$PLID = getcurrentplayervar("PLID"); #Player's unique id
$JRRAction = 4;

joinrequest($X_Axis , $Y_Axis , $Z_Axis , $Flags ,$Heading , $UCID , $PLID ,$JRRAction); #Send Data to LFS
ELSE
privmsg($NickName,"^1Bu komutu kullanamazsınız!");
ENDIF
BREAK;

(Lapper Version 7.0.9.0)
1st: Warning on Command: 'joinrequest' Cannot spawn spectated players
2nd: i miss an IF statement.
3rd: nicknames doesn't work in privmsg() functions.
CASE "!rp":
IF ( ToNum(GetPlayerVar( $userName, "Z" )) >= 0)
THEN
privmsg("^T^7Araç Yenileme ^2Başarılı");
$X_Axis = getcurrentplayervar("X"); #X axis SpawnPoint
$Y_Axis = getcurrentplayervar("Y"); #Y axis SpawnPoint
$Z_Axis = getcurrentplayervar("Z"); #Z axis SpawnPoint
$Flags = 128; #Move/Reset car (128) else (0)
$Heading = getcurrentplayervar("Heading"); #Heading of the players car at Spawnpoint
$UCID = 0; #Connection's unique id (0 = host)
$PLID = getcurrentplayervar("PLID"); #Player's unique id
$JRRAction = 4;

joinrequest($X_Axis , $Y_Axis , $Z_Axis , $Flags ,$Heading , $UCID , $PLID ,$JRRAction); #Send Data to LFS
ELSE
privmsg("^T^7Şuan bu komutu kullanamazsın!");
ENDIF
BREAK;

Quote from Bass-Driver :1st: Warning on Command: 'joinrequest' Cannot spawn spectated players
2nd: i miss an IF statement.
3rd: nicknames doesn't work in privmsg() functions.

I got the same error with this command. https://www.lfs.net/forum/post/2052808#post2052808 I tried a different code with the edits you mentioned. Again the problem is the same.
which error message did you get.

Warning on Command: 'joinrequest' Cannot spawn spectated players

or

Syntax error: in file ".\default\LFSLapper.lpr" at line #xxxx
Token not catched
Function 'onmso' script aborted
Quote from Bass-Driver :which error message did you get.

Warning on Command: 'joinrequest' Cannot spawn spectated players

or

Syntax error: in file ".\default\LFSLapper.lpr" at line #xxxx
Token not catched
Function 'onmso' script aborted

1/27/2024 12:15:16 AM -> Syntax error: in file ".\default\LFSLapper.lpr" at line #1509
Warning on Command: 'joinrequest' Cannot spawn spectated players
Function 'onmso' script aborted
Thats not a error but a warning.

You cannot respawn spectated players.
The player MUST be on track to execute the joinrequest() function.

LFSLapper literally tells you this as you can see.
Quote from Bass-Driver :Thats not a error but a warning.

You cannot respawn spectated players.
The player MUST be on track to execute the joinrequest() function.

LFSLapper literally tells you this as you can see.

I understand now. Then there is nothing you can do to prevent this warning from coming. Thanks.
I've added that warning, just to notify the user why joinrequest() doesnt work.

But you can prevent it by adding a check, if the player is on track or not.


IF(GetPlayerVar($userName,OnTrack) == 1)
THEN
#Player on track
ELSE
#Player NOT on Track
ENDIF

Quote from Bass-Driver :I've added that warning, just to notify the user why joinrequest() doesnt work.

But you can prevent it by adding a check, if the player is on track or not.


IF(GetPlayerVar($userName,OnTrack) == 1)
THEN
#Player on track
ELSE
#Player NOT on Track
ENDIF


Thanks. It happened now. It might be better if you update this in the new version of Lapper.No one like me creates an error post on the forum. Big grin
There is nothing that need to be updated.

You do not need to post each and every error on the forum. Its a common practise to read the error and debug your code, before panicing and spamming the forum with your own created errors Did I Say That?
It's a very accurate observation, I agree with you 100%, I think he needs to be left alone with his problems now.
Quote from Bass-Driver :I've added that warning, just to notify the user why joinrequest() doesnt work.

But you can prevent it by adding a check, if the player is on track or not.


IF(GetPlayerVar($userName,OnTrack) == 1)
THEN
#Player on track
ELSE
#Player NOT on Track
ENDIF


https://www.lfs.net/forum/post/1905751#post1905751
When I want to prevent the use of commands on the move, the IF value I linked does not work. Actually the value is correct but there is no response. There is no debug message either. How can I prevent the use of commands when the vehicle moves?I use the event in the link, but when I want to prevent the use of commands, the IF value does not work Frown
There always is a response, wether it's an error because of faulty code or the IF-statement being excuted.
What have you tried to debug the issue and what was the outcome of that?
I think Bass-Driver was very clear a few posts ago, to not post every issue you have, without making any efforts your self.
This is not a Lapper Helpdesk you can 'call' for all your needs.
Quote from Yisc[NL :;2080126"]There always is a response, wether it's an error because of faulty code or the IF-statement being excuted.
What have you tried to debug the issue and what was the outcome of that?
I think Bass-Driver was very clear a few posts ago, to not post every issue you have, without making any efforts your self.
This is not a Lapper Helpdesk you can 'call' for all your needs.

You keep telling me that I don't make any effort. I just started playing the game 8 months ago and I'm trying to learn everything about lapper. I see that you have always received help from someone in the past. It's strange how you behave towards me when I want to get help from you. You claim that I made no effort. It's a big mistake to think this. I already gave an answer when stating my problem. I do not encounter any errors in the ERR log channel. I also share with you the values ​​I use. If you don't want to help someone, you don't have to say so. Because I'll start thinking different things about you...
I see that those who know about Lapper were getting help from others just a few years ago. I don't understand why it seems strange to you that I also get help. It's not nice to treat people trying to do something in the legal version of LFS like this. I recommend you to research which version of LFS the people you are helping are developing. If you're still going to reject people's help, there's no need to use this forum.
I am always willing to help people (search this forum and you will see that's true) but what I don't like is people coming in here, asking questions all the time and not showing what they did to troubleshoot there issue.

Same with this.
You post a piece of code that Bass-Driver has given you and claim it doesn't work.
Okay, there is no error, but errors only come if the code is faulty and/or when Lapper runs into an issue that isn't properly handled by it.
Since there are no errors, we can rule both of those out.
Next step would be to put in some debug-code in the IF-statement to see what is or isn't executed.
Once you know where in the IF-loop you are (or maybe the outcome is that the IF-loop is never entered, so then you have to see what the last step was before that loop), you can start checking the next step.

Debugging can always be done by adding a Privmsg within the loop or by writing something to the Lapper console.

Maybe you did all of this, but you haven't shared any of it and have not told us the outcome of the debugging.
Quote from Yisc[NL :;2080145"]I am always willing to help people (search this forum and you will see that's true) but what I don't like is people coming in here, asking questions all the time and not showing what they did to troubleshoot there issue.

Same with this.
You post a piece of code that Bass-Driver has given you and claim it doesn't work.
Okay, there is no error, but errors only come if the code is faulty and/or when Lapper runs into an issue that isn't properly handled by it.
Since there are no errors, we can rule both of those out.
Next step would be to put in some debug-code in the IF-statement to see what is or isn't executed.
Once you know where in the IF-loop you are (or maybe the outcome is that the IF-loop is never entered, so then you have to see what the last step was before that loop), you can start checking the next step.

Debugging can always be done by adding a Privmsg within the loop or by writing something to the Lapper console.

Maybe you did all of this, but you haven't shared any of it and have not told us the outcome of the debugging.

For some reason, some codes in lapper do not work and you do not receive any errors. If I give an example of this, the idle system. Since this system did not work, we made an afk system ourselves using the event that detects that the vehicle is not moving. Coming to our topic, I removed the IF value of the bass driver, which detects the vehicles on the track, and replaced it with the coding I shared with you, but I did not receive any error message. I will share the coding with you. I'm currently working on a different problem.
If code doesn't work, but there is no error either, it means the code is written and handled correctly. But if for instance a comparison is written wrongly causing it to never be true, nothing will happen, while the actual code is correctly written and handled.
That's why the capability of being able to debug it properly, is so important and that can go as far as micro details by putting a debug message (with a number to know which one you are seeing (or not)) after every line.
This will tell you what step the code has gone through.
I know that, thank you.
this post is really unnecessary(You can delete this post if needed), but want to show an example how i debug my code.
Last week some random errors occur on my timeattack script, when it tries to save the local saved stagetimes to the textfiles. The Timeattack server is down due to this bug. Testing during development went fine BTW.

Looking into the ERR log file it tells me this, and sometimes other errors related to this.
2/13/2024 7:30:00 PM -> Syntax error: in file ".\default\.\includes\.\RallySystem\Scripts\NewTimes.LPR" at line #212
ERROR on Function: 'EditFile', ERROR on Function: 'EditFile', File is empty: [0] lines detected, you cant edit any lines.
Function 'writetofile' script aborted

These error came on very random moments and i couldn't pinpoint the problem. So that means i have to debug my code.

Let me show you my example of debugging. Warning, its a large piece of code
Do not copy the code, it simply doesnt work!!

As you can see i've created alot of debug messages, even on lines that do not need a debug message.



Sub WriteToFile()
$SaveStageCount = arrayCount($SaveStageTimesStage);

Globalmsg("^4DEBUG: ^8Start WriteToFile() With ^3".$SaveStageCount." ^8Veh/Stage Combo's");
IF($SaveStageCount > 0) THEN

FOR ( $x = 0; $x < ToNum($SaveStageCount) ; $x = $x + 1)
$SaveTimeStage = $SaveStageTimesStage[ToNum($x)];
$SaveTimeVeh = $SaveStageTimesVeh[ToNum($x)];
Globalmsg("^2DEBUG: ^8[".$x."] ^8Vehicle: ".$SaveTimeVeh." / Stage: ". $SaveTimeStage);

IF(($SaveTimeStage != "") && ($SaveTimeVeh != "")) THEN
#Globalmsg("^3DEBUG: ^8WriteToFile() Loop ".$SaveTimeStage." / ".$SaveTimeVeh." || ^3".$CountTimesOfCar[ToNum($SaveTimeStage),$SaveTimeVeh]);

$StageDir = $StageTimes_Dir . "/Stage_" . $SaveTimeStage; #RallySystem\StageData\TrackConfig\NameOfTimeTable\Stage_X

#Verify if vehiclefile for current stage exist
IF (FileExist($StageDir,$SaveTimeVeh,".txt") == 1) THEN
#Get information about the vehicle file.
$TimeInfoFromFile = ReadFile($SaveTimeVeh,$StageDir,".txt");
$MaxFileRecords = $TimeInfoFromFile["NumberOfLines"];

$ArrayCount = ToNum($CountTimesOfCar[ToNum($SaveTimeStage),$SaveTimeVeh]);

globalmsg("^3DEBUG: Records in File [Stage ".$SaveTimeStage."/".$SaveTimeVeh."]: ^3".$MaxFileRecords." ^0/ ^6".$ArrayCount);

$RecordsWritten = 0;
$Deletedlines = 0;
FOR ( $Pos = 0; $Pos < ToNum($ArrayCount); $Pos = $Pos + 1)

$GetRecordInfo = $TimeOfCar[ToNum($Pos),ToNum($SaveTimeStage),$SaveTimeVeh,"Info"]."";

#Ignore if $getRecordInfo is empty. This line wont be saved to the timefile

IF($GetRecordInfo != "") THEN
$RecordsWritten = $RecordsWritten + 1;
globalmsg("^3DEBUG: WriteToFile() Write/Array ".$RecordsWritten." <> ".$MaxFileRecords);

IF(ToNum($RecordsWritten) > ToNum($MaxFileRecords))THEN
#If current list of records is larger than the list of records from current timefile, create a new line.
EditFile($SaveTimeVeh,$StageDir,$GetRecordInfo,-1,".txt"); #NewLine
globalmsg("^3DEBUG: ^8New Record ");
ELSE
#Overwrite every record.
EditFile($SaveTimeVeh,$StageDir,$GetRecordInfo,$RecordsWritten,".txt"); #NewLine
globalmsg("^3DEBUG: ^8Record Overwritten");
ENDIF
ELSE
globalmsg("^3DEBUG: Warning >> ^8NO DATA: ".$SaveTimeVeh." / ".$SaveTimeStage." / ".$Pos);
ENDIF
ENDFOR

IF( $RecordsWritten > 0) THEN
#Delete Records that exceed the maximum records for the current vehicle/stage combo (Records can be deleted by player in !times)
IF(ToNum($RecordsWritten) < ToNum($ArrayCount)) THEN
FOR ( $Line = $ArrayCount-1; $Line >= ToNum($TotalRecordsWritten) ; $Line = $Line - 1)
EditFile($SaveTimeVeh,$StageDir,-1,$Line,".txt"); #NewLine
$Deletedlines = $Deletedlines + 1;
ENDFOR
ENDIF
ENDIF

Globalmsg("^3DEBUG: ^8Total Lines Written/Deleted [Stage ".$SaveTimeStage."/".$SaveTimeVeh."]: ^2".$RecordsWritten."^0/^1".$Deletedlines);
ELSE
Globalmsg("^3ERROR: ^8Cannot save stagetime: ^3[Stage ".$SaveTimeStage."/".$SaveTimeVeh."], ^7Contact admin!");
ENDIF
ENDIF
ENDFOR

Globalmsg("^3DEBUG: ^8Clear/Reset $SaveStageTimesStage & $SaveStageTimesVeh Array + Counter");
UnSet($SaveStageTimesStage);
UnSet($SaveStageTimesVeh);
$SaveStageTimesCounter = 0;

#LogSystem
$ConvertShortDate = Replace(GetLapperVar( "ShortDate" ),"/","-");
$NewLine = StripLFSColor("".GetLapperVar( "ShortDate" )."-".GetLapperVar( "ShortTime" ) ."|TIMES| Scheduled task to save stagetimes to file");
EditFile($ConvertShortDate,$Insim_Log_Dir,$NewLine,-1,".txt"); #NewLine

#Globalmsg("^3DEBUG: ^8WriteToFile() Finished");
ENDIF
EndSub


** Best answer **
CASE "!jrr":

$X_Axis = getcurrentplayervar("X"); #X axis SpawnPoint
$Y_Axis = getcurrentplayervar("Y"); #Y axis SpawnPoint
$Z_Axis = getcurrentplayervar("Z"); #Z axis SpawnPoint
$Flags = 128; #Move/Reset car (128) else (0)
$Heading = 0; #Heading of the players car at Spawnpoint
$UCID = 0; #Connection's unique id (0 = host)
$PLID = getcurrentplayervar("PLID"); #Player's unique id
$JRRAction = 4;
IF ( GetCurrentPlayerVar( "InstantSpeed" ) < 1 )
THEN
IF(GetPlayerVar($userName,OnTrack) == 1)
THEN
$Message = " ```fix\n (". GetCurrentPlayerVar("UserName").") aracını yeniledi. >> (". GetLapperVar ( "LongTime" ) .") ``` "; $DiscordChannel = "1206604043112157214"; sendmessagetodiscord($DiscordChannel,$Message);
privMsg( GetCurrentPlayerVar("NickName") . " ^7Araç yenileme başarılı.");
joinrequest($X_Axis , $Y_Axis , $Z_Axis , $Flags ,$Heading , $UCID , $PLID ,$JRRAction); #Send Data to LFS
ELSE
privmsg("^1Bu komutu kullanamazsınız!");
ENDIF
ELSE
privmsg("^1Hareket halinde bu komutu kullanamazsınız!");
ENDIF
BREAK;

Quote from Bass-Driver :this post is really unnecessary(You can delete this post if needed), but want to show an example how i debug my code.
Last week some random errors occur on my timeattack script, when it tries to save the local saved stagetimes to the textfiles. The Timeattack server is down due to this bug. Testing during development went fine BTW

In case this isn't fixed, I would start to dump every action into a logfile.
The error is clear as it states that at some point the textfile that you want to edit, is empty.
Now you need to find why it is empty and at what point it is or becomes empty.
Maybe the name (that is made from variables) gets funky and when it then tries to open it, the code 'think' it is empty because it cannot find that particular file.
Things like this causes huge headaches, but once you figured it out and was able to fix it, you will get a boost.
This was just an example how i'm debugging my code.

I've rewriting alot of old code lately. Changing the file/folder structure to make saving times less laggy. I haven't changed multiple lines in WriteToFile(), because it was working fine with the old and new filestructure during developing.

But since many people were driving on our server, many new WR's and PB were set. But at some point, it didn't save the times to the new filestructure i've created.

During testing i've reproduced the errors somehow. Restarted Lapper and did the same thing, but now it was working fine. So i was really confused.

After some more testing the same errors occured, but not at the same point from earlier testing.

So i decided to rewrite the the code that rewrites existing lines and creates new lines to the target file.

I'm testing that piece of code now as we speak with multiple people.
The results are looking good so far.
@RealistAdam.

Made few small changes and tested it. The code below is working.
I've changed the 2 IF statements in a different order.

CASE "!jrr":

$X_Axis = getcurrentplayervar("X"); #X axis SpawnPoint
$Y_Axis = getcurrentplayervar("Y"); #Y axis SpawnPoint
$Z_Axis = getcurrentplayervar("Z"); #Z axis SpawnPoint
$Flags = 128; #Move/Reset car (128) else (0)
$Heading = 0; #Heading of the players car at Spawnpoint
$UCID = 0; #Connection's unique id (0 = host)
$PLID = getcurrentplayervar("PLID"); #Player's unique id
$JRRAction = 4;

IF(GetPlayerVar($userName,"OnTrack") == 1)
THEN
IF ( GetCurrentPlayerVar( "InstantSpeed" ) < 1 )
THEN
$Message = " ```fix\n (". GetCurrentPlayerVar("UserName").") aracını yeniledi. >> (". GetLapperVar ( "LongTime" ) .") ``` ";
$DiscordChannel = "1206604043112157214";
sendmessagetodiscord($DiscordChannel,$Message);
privMsg( GetCurrentPlayerVar("NickName") . " ^7Araç yenileme başarılı.");
joinrequest($X_Axis , $Y_Axis , $Z_Axis , $Flags ,$Heading , $UCID , $PLID ,$JRRAction); #Send Data to LFS
ELSE
privmsg("^3Command abort: Stop the car!");
ENDIF
ELSE
privmsg("^1You cannot use this command in spectatormode");
ENDIF
BREAK;

The incorrect order of IF statements can cause headaches.
Quote from Bass-Driver :@RealistAdam.

Made a new small changes and tested it. The code below is working.
I've changed the 2 IF statements in a different order.


If it were like what I shared, what kind of error would I get for the "IF" value? I am currently using it as I first shared and I have no problems. The reason I'm asking is to find out if this is a mistake.
1
This thread is closed

FGED GREDG RDFGDR GSFDG