The online racing simulator
Searching in All forums
(886 results)
Bass-Driver
S3 licensed
You will receive no errors, because this is a logical programming error created by the user.

Always think, what the insim need to check first.

In your case, why whould you check the player's speed before checking if the player is OnTrack.
Because you can only check the Speed of the player, if the player is OnTrack.
Bass-Driver
S3 licensed
@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.
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
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.
Bass-Driver
S3 licensed
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


Bass-Driver
S3 licensed
i'm curious what you changed.
Can you show us. will be helpfull to other LFSLapper users.
Bass-Driver
S3 licensed
Check all the lines in your script that contains cmdLFS();
I guess the error occurs within the OnConnect event

Why i say that?

at LFSLapper.LFSClient.cmdlfs(unionVal val, ArrayList args) = cmdLFS() function
at LFSLapper.LFSClient.managePacket(NCN newConnection) = Event OnConnect

Also check WHEN the crash is happening. This could lead to the faulty line in your script that cause the crash
I've never seen this error or that email error before.
Last edited by Bass-Driver, . Reason : extra information
Bass-Driver
S3 licensed
Those variables do not exist below 7.0.9.0 and thats why Lapper spit out errors.
Did you change anything in LFSLapper.LPR recently?
Bass-Driver
S3 licensed
Line #14 and #15 in myInc.lpr must be the next variables

$RestAPIClientID = "";
$RestAPIClientSecret = "";

@RealistAdam You are using the incorrect version of LFSLapper.
must be version 7.0.9.0 or higher.

About the email error: read Yisc[NL]'s post above.
Bass-Driver
S3 licensed
oke guys,
My reaction was more of a joke.

And yes i know that these kind of questions/persons exists.
You can tell on how the question is being ask, how much the person has done on their side.
But still i'm trying to be helpfull, but there is a limit.

Anyway lets not go off-topic. You guys made your point.

Thank you.
Bass-Driver
S3 licensed
Can you ask less odd questions, thanks. Big grin

First the SQL databases and now this,
Omg, what did i do to you Big grin
Bass-Driver
S3 licensed
Did you do any debugging at all?

Do some proper tests please.
Create some "debug" messages to see where and what the problem is.
Bass-Driver
S3 licensed
What did you do to test the code?

-Does the event execute?
etc etc

Do that first.
Bass-Driver
S3 licensed
show me the code.
its a LFS command, so it should work.
Bass-Driver
S3 licensed
there are a few post on the LFSLapper developer forum (Search) with a few example about trackuserdistance() and GetAngle(). The rest is up to you to test and write example codes to understand the code and merge/implement it in your own script.
Bass-Driver
S3 licensed
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?
Bass-Driver
S3 licensed
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

Bass-Driver
S3 licensed
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.
Bass-Driver
S3 licensed
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
Bass-Driver
S3 licensed
1st: Warning on Command: 'joinrequest' Cannot spawn spectated players
2nd: i miss an IF statement.
3rd: nicknames doesn't work in privmsg() functions.
Bass-Driver
S3 licensed
@RealistAdam: Please tell us what causes LFSLapper to crash, so we can fix it in the next versions of LFSLapper.

My quick investigation to the crash:

LFSLapper seems to crash when the playername doesn't exist, and is being used in the privmsg() function.
This need to be fixed in the next version of LFSLapper.

I've added a extra check to the command if the playernames are entered correctly.
Be aware that the usernames are capital sensitive.

For example: Bass-Driver is correct and bass-driver isn't.

CASE "!pm":
IF( $argv != "" ) THEN

$idxSpace = indexOf( $argv, " ");
IF( $idxSpace != -1 ) THEN

$User = subStr( $argv,0,$idxSpace );

#Check if Player is online on the server.
$currPly = getPlayerInfo($User);
IF( $currPly != "" ) THEN
$Message = trim( subStr( $argv,$idxSpace ) );

privMsg( $User , "^1[PM] ^7". $userName . " ^0>> ^3" . $Message);
privMsg("^1[Private Message] ^7". $User . " ^0>> ^3" . $Message);
ELSE
privMsg ( "^7Player does not exist");
ENDIF
ELSE
privMsg ( "^7Incomplete command: !pm <username> <Message>" );
ENDIF
ELSE
privMsg ( "^7Incomplete command: !pm <username> <Message>" );
ENDIF
BREAK;

Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
do you see all the privmsg() messages in the chatlog?

What do you mean, you do not have permission to share this?
Is this your code or is someone else coding it?

So many questions are going on in my mind right now.
Bass-Driver
S3 licensed
according to the changelog of 7.0.6.0

Soundoption for globalmsg(); / privmsg();
NOTE: is compatible with older scripts.

0 = No Sound
1 = Message Sound
2 = SystemMessage Sound
3 = InvalidKey Sound
4 = ERROR Sound
5 = NUM Sound

-Possible options for globalmsg() :
globalmsg("BLAHBLAH");
globalmsg("BLAHBLAH",0);
-Possible options for privmsg() :
privmsg("BLAHBLAH");
privmsg("BLAHBLAH",0);
privmsg($userName,"BLAHBLAH");
privmsg($userName,"BLAHBLAH",0);

Bass-Driver
S3 licensed
If you checked and understand the code.you see its only sent to admins.
Bass-Driver
S3 licensed
Should something like this, the code has not been tested.

CASE "!a":
IF($argv != "") THEN

#Getlistofplayers
$ListOfPlayers = GetListOfPlayers();
FOREACH ($Player in $ListOfPlayers)

$User = $Player["value"];
###Send message if a user is an admin
IF( UserisAdmin($User) == 1 )THEN
privmsg($User,"-----------------------------------");
privmsg($User,$userName." send a adminmessage");
privmsg($User,$argv);
privmsg($User,"-----------------------------------");
ENDIF

ENDFOREACH
ELSE
privmsg("Message not detected, correct syntax: !a <message>");
ENDIF
BREAK;

Bass-Driver
S3 licensed
could you give any examples like pictures or videos or whatever.

"system on the TC server" is not a good example.
FGED GREDG RDFGDR GSFDG