The online racing simulator
PublicTest_14: Lapper V7.0.6.4
Hello,

This testversion contains some new functions and some important fixes.
See the summary of changes below.

This does contain fixes for Linux

#Question:
Could you test, if the build-in track rotation works. Because somehow i cant get it working.


+---------------------------------------------------------------+
|Changes from 7.0.6.3 to 7.0.6.4 Public Test_10 |
+---------------------------------------------------------------+
=================================================
New:
=================================================
1: New function: PlayerDelayedcommand(); #Start delayedcommand for a specific player

$UserName = "Bass-Driver";
$NameOfDelay = "CloseButton";
$DelayInSeconds = 3;
$SubCallBack = "ThisSub";

PlayerDelayedcommand($UserName,$NameOfDelay,$DelayInSeconds,$SubCallBack);

2: New function: RemovePlayerDelayedCommand(); #Remove delayedcommand for a specific player

$UserName = "Bass-Driver";
$NameOfDelay = "CloseButton";

RemovePlayerDelayedCommand($UserName,$NameOfDelay);

3: New function: RegisterPlayerDetection(); #Detect player within a fieldofview and distance.

#Example
#$userName = Set Player for the detector
$userName = "Bass-Driver"; #The Detector is now enabled for Bass-Driver

#$FieldOfView = Set range of the view to detect players. (degrees)
$FieldOfView = 30; #view will be 0 to 30 and 0 to -30

#$Distance = Max distance of detection (Meters)
$Distance = 25;

#$NameofSubDetected = Execute Subcallback when 1 or more players are detected.
$NameofSubDetected = "PlayerDetected";

RegisterPlayerDetection($userName,$FieldOfView,$Distance,$NameofSubDetected);

#==========================================
#Sub callback
#==========================================
Sub PlayerDetected($userName,$DetectedPlayer)
OpenButton( $userName, "PlayerName",170,115,30,5,2,5,96, "^3Player: ^7".GetPlayerVar($DetectedPlayer,"NickName"));
OpenButton( $userName, "Speed",170,120,30,5,2,5,96, "^3Speed: ^7".GetPlayerVar($DetectedPlayer,"InstantSpeed")." km/h");
OpenButton( $userName, "Distance",170,125,30,5,2,5,96, "^3Heading: ^7".GetPlayerVar($DetectedPlayer,"Heading"));
EndSub

#########################################
#DISCORDBOT FEATURES
#########################################
4: New Event :

- This event will be executed when someone sends a discord message to LFSLapper.
- A Discordbot must be created to communicate between LFSLapper and Discord.
- In 'bin/default/includes/myInc.LPR' you can enter the 'DiscordToken' and the 'Discordchannel' to receive the messages from.
- Link to create a discordbot: https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token
- Set DeveloperMode in your discordsettings to "ON' to copy the channel ID ( rightclick on the channel)

Event OnReceiveDiscordMessage($DiscordUname,$Text) # Player event
#Your code
EndEvent

#This function sends messages to your selected discordchannel.
#The discordbot must be connected while using this function

5: New Function: sendmessagetodiscord();
$DiscordChannel = "000000000000000000";
$Message = "Hello";
sendmessagetodiscord($DiscordChannel,$Message);

6: New setconfigvar() value: "DiscordBotStatus"
setconfigvar("DiscordBotStatus",$argv); #change the status of the discordbot
EndSub
=================================================
Changed:
=================================================
1:Hostname now visible when lapper succesfully connected to a server.
2:New errormessages to MSS file before Lapper starting (faulty adminpass)
3:Increased the frequence of retreiving info from LFS to every (50 ms) was 100ms (Proper testing needed)
-The MCI (Carinfo) packet will still execute every 100ms
4:Realtime driftscore refreshrate is set to 5 times a second instead of 10.
5:NumtoMSH(); returns values in HH:mm.ss format, was HH.mm.ss before.
6:Event oncrossingchecker: returns now which insim checkpoint you crossed.
7:Event oncrossingchecker: returns time in H:mm:ss format.
8:GetWr(); allows 1 parameter "CAR". Example below
CASE "!getwr":
IF($argv != "")THEN
$GetWRInfo = GetWR($argv);
ELSE
$GetWRInfo = GetWR();
ENDIF
privmsg("^7============================");
privmsg("^3WR Info:");
privmsg("^7============================");
privmsg("^7Car: ^8".$GetWRInfo["CName"]);
privmsg("^7Track: ^8".$GetWRInfo["Track"]);
privmsg("^7Racer: ^8". $GetWRInfo["racerName"]);
privmsg("^7Time: ^8".NumToMSH($GetWRInfo["WRTime"]));
privmsg("^7Sp1: ^8".NumToMSH($GetWRInfo["Split1"]));
privmsg("^7Sp2: ^8".NumToMSH($GetWRInfo["Split2"]));
privmsg("^7Sp3: ^8".NumToMSH($GetWRInfo["Split3"]));
privmsg("^7Last: ^8".NumToMSH($GetWRInfo["SectorLast"]));
BREAK;
9:GetWR(); Added 2 new values: Date & Time. Date/Time of WR
$GetWRInfo["Date"]);
$GetWRInfo["Time"]);
10:Store data for offline players
-New variable: $StoreOfflineData = false; #storedvalue.dbs Store Offline data , even when the player doesnt exist in the database.
-IF $StoreOfflineData = true, a warning message will be displayed on your lapperconsole and in your MSS logfile, after reloading lapper



=================================================
Fix:
=================================================
1: WriteLine() :Lapper crash when try to convert special LFS characters
2: Write() :Lapper crash when try to convert special LFS characters
3: LFSLapper.LPR : one of the debugoption turned on
4: LFSLapper.LPR : debugmessages
5: No returning value when accidently applying NumtoMSH(); twice
6: Changed hardcoded visible records in Toplist/UserTop/Drifttop from 24 to 10000
7: Linux/mono users couldnt start Lapper on theire computer (Testfase)
8: GetWR(); Couldnt get RO11 WRtime

Attached images
Writeline_Write.jpg
Console_Multiple connected.jpg
-
(sinanju) DELETED by sinanju
Was going to try play about with this, but I can't get it to start properly.

As soon as I try to run lapper, I get an illegal character error



The lfslapper.lpr file only has 2183 lines, and there's nothing in the error files to tell me which file error refers to - actually, there's nothing in the error files at all to show any problems.

I don't know what order lapper loads the addon files, so can't tell which file is affected.

Once the command prompt finishes (after hundreds of lines telling me of error), lapper goes into Stand by state, then closes. Then the lapper.exe file disappears! Doesn't make its way into the recycle bin - just self deletes!

Not sure if it makes a difference, but due to small size of my C: drive - using a small capacity SSD - I have LFS and lapper loaded on my D: drive. Works for my copy V6 lapper that I use online.

The only things I've changed from default, is to add my username to both admin.txt and superusers.txt, and added password to default_1.ini file.

Any ideas?
Attached images
LFSLapper Illegal Character line 3299.png
Thx for the first feedback.

The deleting exe file is really strange. Maybe a virusscan protection or something?

I have no idea what that could be.
I will look into it as soon i get home.
I tried 3 times last night to get this working, each time copying original zip file into new directory, renaming to version number, and changed the admin and superuser text files, and the ini passwork file, and each time the error and the self deleting exe file.

Tried it after getting home from work earlier, doing exactly same as last night, and 3 differences.

AVG didn't send the exe file to its server to check if virus - I forgot to mention that in my earlier post. Probably because it recognised it as same exe it already checked.

Didn't get any error messages on the command prompt.



Now works flawlessly!

I didn't change any .lpr files yesterday or today, so don't understand the illegal character error message.

Anyway, now works, so ok now.

Apologies if this caused you any work to check out Frown
Attached images
Lapper no error.png
Good to see that you got it working. Thumbs up

There's no need to apologize. Didnt had the time to work on it.

Smile
Now that I've got it working, and am playing with InSim checkpoints ...

Would it be better rather than having to play about with changing time outputs from numbers, lapper gave you the proper, real time, without having to use NumToMSH?

Using the following event

<?php 
Event OnCrossingChecker
($userName,$Flags,$Time,$Object,$UserSpeed,$CircleIndex)  # Player event
    
privmsg(getplayervar($userName,"NickName"));
    
privmsg("Action: ".$Flags);
    
privmsg("Time: ".$Time);
    
privmsg("Object: ".$Object);
    
privmsg("CircleIndex: ".$CircleIndex);
    
privmsg("Speed: ".$UserSpeed." ".getplayervar($userName,"UnitSpeed"));
EndEvent
?>




gives me a number such as 70210, which I then have to add code, in proper format, to change into a proper time (ie 1m 10.21s).

Not so bad for people who have some experience of lapper, but its complicated when you don't really know it, (or in my case, forget how to use it) and expect things to work without having to delve into code and change it.

Also.

Would be worth adding comment to the !myconfig line in the lfslapper.lpr file - there's nothing to say what it does, and it seems to be hard wired into lapper, as you can search for the function, and find nothing. Maybe comment such as "#function to change language, unit of speed, etc"?
Attached images
lapper crossing checker.png
Its indeed more usefull for non-experienced lapperusers.
What i could do is to add numtomsh() to the $Time parameter in the sourcecode.

But there is one think i concerned about.
To keep it compatible with the older lapperversion, i need to know what happends when you convert that value twice with numtomsh();

if it returns an error, i have to change the code a littlebit.

Atm i do have not much time, to work on Lapper.
i'm moving to a new house.
Hi

That's fine. Just thought it would make it easier for everyone.

If anyone's interested, the code i'm using is

Event OnCrossingChecker($userName,$Flags,$Time,$Object,$UserSpeed,$CircleIndex) # Player event
privmsg(getplayervar($userName,"NickName"));
privmsg($Object." Sector split: ".(NumToMSH($Time)));
EndEvent

InSim Checkpoint discrepancies
I've made a layout with both normal autox and InSim checkpoints and finish times, and am having a number of problems, especially in regard to the timings.

Not sure if this is a lapper or lfs issue, so I've posted my issues and findings HERE

However, a lapper request:

When you cross an InSim checkpoint, lapper only outputs the word "checkpoint". It doesn't tell you which of the 3 you've crossed. Could lapper be amended to show checkpoint number?

This may be necessary if anyone wants to record times, as lapper may just record as a single sector and keep overwriting sector splits between checkpoints depending on which is fastest, rather than record fastest splits for all sectors.
I made a couple of changes:

Have only attached the .exe in the attachments.

publictest_01 directory is required!! if you dont have it, goto the first post

=================================================
Changed:
=================================================
1:NumtoMSH(); returns values in HH:mm.ss format, was HH.mm.ss before.
2:Event oncrossingchecker: returns now which insim checkpoint you crossed.
3:Event oncrossingchecker: returns time in H:mm:ss format.

=================================================
Fix:
=================================================
1: No returning value when accidently applying NumtoMSH(); twice

Attached images
Objectname.jpg
Attached files
LFSLapper.exe PublicTest_02.zip - 161 KB - 356 views
Thanks for that - much better Thumbs up
About the timedifference between the insim and LFS clocks.

Thy this lapperfunction to retreive the current racetime:

$racetime = GetLapperVar("racetime");

This var will start when the race starts. it retreives information from the insim packet

Here are some other GetLapperVar() vars from the sourcecode.


<?php 
//Get date and time when the race has been started.
//GetLapperVar("dateracestarted");
case "dateracestarted":
      
val.typVal GLScript.typVal.str;
      
val.sval utils.quote(currRace.started.ToString("yyyy-MM-dd-hh-mm-ss"));
return;

//Elapsed racetime (in Minutes) after the race has been started
//GetLapperVar("elapsedmins");
case "elapsedmins":
     
TimeSpan interval DateTime.Now.Subtract(currRace.started);
     
val.typVal GLScript.typVal.num;
     
val.fval = (float)interval.TotalMinutes;
return;

 
//Elapsed racetime (in Seconds) after the race has been started
 //GetLapperVar("elapsedsecs");
case "elapsedsecs":
       
TimeSpan interval2 DateTime.Now.Subtract(currRace.started);
       
val.typVal GLScript.typVal.num;
       
val.fval = (float)interval2.TotalSeconds;
return;

 
//Elapsed racetime (in Milliseconds) after the race has been started
 //GetLapperVar("elapsedms");
case "elapsedms":
    
TimeSpan intervalms DateTime.Now.Subtract(currRace.started);
    
val.typVal GLScript.typVal.num;
    
val.fval = (float)intervalms.TotalMilliseconds;
return;

//Current racetime (in Milliseconds) after the race has been started
//GetLapperVar("racetime");                 
case "racetime":
    
TimeSpan intervalm DateTime.Now.Subtract(currRace.started);
    
double RaceTimer long.Parse(Math.Round(intervalm.TotalMilliseconds).ToString());
    
val.typVal GLScript.typVal.num;
    
val.fval = (float)RaceTimer;
return;
?>

i'm aware that racetime and elapsedms looks the same.
the racetime code was differend, but the cpu usage was rising when many people try to retreive the current racetime (from insimpacket). I use this var in my Timeattack script.

Since i changed it, it looks and (works) the same as 'elapsedms'.
Will convert 'racetime' from Milliseconds to MSH someday, like i did with the 'Oncrosschecker' event.
I'm getting mixed results ...

My code

<?php 
Event OnCrossingChecker
($userName,$Flags,$Time,$Object,$UserSpeed,$CircleIndex)  # Player event

    
$dateracestarted GetLapperVar("dateracestarted"); #Get date and time when the race has been started.
    
privmsg("Race Start: ".$dateracestarted);
     
    
privmsg("Driver: ".getplayervar($userName,"NickName"));

    
privmsg($Object." sector split: ".$Time);
   
    
$racetime GetLapperVar("racetime"); # Elapsed racetime (in Milliseconds) after the race has been started 
    
privmsg("Racetime: ".(NumToMSH($racetime)));
   
    
$elapsedms GetLapperVar("elapsedms"); # Elapsed racetime (in Milliseconds) after the race has been started    
    
privmsg("Elapsed Milliseconds: ".(NumToMSH($elapsedms)));
      
    
$elapsedsecs GetLapperVar("elapsedsecs"); # Elapsed racetime (in Seconds) after the race has been started    
    
privmsg("Elapsed Seconds: ".(NumToMSH($elapsedsecs)));
      
    
$elapsedmins GetLapperVar("elapsedmins"); #Elapsed racetime (in Minutes) after the race has been started    
    
privmsg("Elapsed Minutes: ".(NumToMSH($elapsedmins)));  

EndEvent
?>


My results


I didn't jump start, but from green light, to crossing finish line at start is over half second difference between what's recorded between sector split and racetime. And both InSim times are over 10secs on from LFS recorded time.

Nothing displayed for ms, secs, or minutes.
Attached images
lapper insim timing test.png
Thought I'd add colours to text to make it easier to read, and in one checkpoint, the ms time appeared - 2nd time I went through 2nd checkpoint.



From these times, it can be seen that there's a discrepancy between difference in Racetime / Checkpoint times -

Checkpoint Time Racetime Difference
00:13.74 00:14.33 00:00.59
00:35.53 00:35.93 00:00.40
00:56.97 00:57.43 00:00.46
01:14.88 01:15.40 00:00.52
01:38.91 01:39.32 00:00.41
01:59.70 02:00.32 00:00.62
02:21.63 02:22.33 00:00.70

The smallest time difference is 0.40secs, and largest 0.70secs, but not once do differences match.

As I recorded times from a video, there is likely slight difference in the LFS time shown on screenshots as each frame is 0.12 seconds apart, but the InSim times shown don't rely on me capturing correct frame, as lapper captures the times.

It would also appear that there is a difference in lap time between LFS time and InSim time

LFS Timer Racetime Checkpoint Time
Green Light 00:00.00 00:11.06 00:10.47
Finish Line 01:27.54 01:39.32 01:38.91
Lap Time 01:27.54 01:28.26 01:28.44

Attached images
lapper insim timing test2.png
Attached files
lapper timings.pdf - 398.7 KB - 293 views
oke, thanks for the usefull info.

i came to a conclusion that the timecalculation if wrong for


GetLapperVar("racetime");
GetLapperVar("elapsedms");
GetLapperVar("elapsedsecs");
GetLapperVar("elapsedmins");

When requesting these values. It will not get the time from LFS, but it does calculate the time between: Startrace and the time when you request the value.

it seems to take some time to:

-send the valuerequest to Lapper. It might take longer when the Lapperserver is hosted on a another computer
-calculating the time.
-convert the value to MSH: NumtoMSH();
-send the value back on screen (privmsg/button)

So basically the solution is trying to retrieving the same value as $time.
I'm gonna look into this asap.

Going to try to retreive the time-insimpacket from LFS.

Going to change GetLapperVar("racetime") in its old state, to see what the difference are.
I have changed the the code of GetLapperVar("RaceTime"); to its old state.
It will now request the current racetime from the LFS Racetimer. LFS will sent a insimpacket back to Lapper.

Do not request it to many times. Your cpu usage will increase.

The rest of the lappervars arent changed:

GetLapperVar("elapsedms");
GetLapperVar("elapsedsecs");
GetLapperVar("elapsedmins");
Attached files
LFSLapper.exe PublicTest_03.zip - 161.1 KB - 400 views
Quote from Bass-Driver : ... Do not request it to many times. Your cpu usage will increase ...

As it's for a 2 player RoC track, that will mean 3 InSim checkpoints and finish line will be triggered by both players even though only 1 player should have times recorded, as 1 player should be using LFS autox checkpoints and the other the InSim checkpoints.

Something I'll need to keep in mind.
sry, what i ment is: do not request it to many times per second.
What you are trying todo is just fine.
Just tried your new exe, and times are lot closer.

Checkpoint Racetime Sector Time
Start/Finish Line 0:00.00 0:13.79
1st Checkpoint 0:43.92 0:43.58
2nd Checkpoint 1:05.93 1:05.93
3rd Checkpoint 1:23.90 1:23.59
Finish Line 1:48.85 1:48.76

However!

From green light in start position 1 to crossing start/finish line should have been about 1.5secs, not zero.

And why is sector time over 13 seconds ahead crossing start/finish line, but then almost matches the Racetime when it hits the other sectors?
The raw UCO info you see in Racons post is basically the info you get from the from the UCO insim packet when someone acrossed a checkpoint/Circle :

Event OnCrossingChecker($userName,$Flags,$Time,$Object,$UserSpeed,$CircleIndex) # Player event

SPX is a insimpacket that gives you information when someone across a checkpoint or drove a lap
These are the events in lapper:

#############################################$#
#Splitting (general action when passing split)#
###############################################

Event OnSplit1( $userName ) # Player event
EndEvent

Event OnSplit2( $userName ) # Player event
EndEvent

Event OnSplit3( $userName ) # Player event
EndEvent

Event OnLap( $userName ) # Player event
EndEvent

This is how the UCO and SPX packet looks like in LFSLapper.

<?php 
===============================
UCO insimpacket
===============================
// OK For Insim 8
        
public class UCO // Size 28 Bytes: report InSim checkpoint / InSim circle
        
{
            public 
CarContOBJ C = new CarContOBJ();
            public 
ObjectInfo OBJInfo = new ObjectInfo();

            public 
readonly int PLID;                           // player's unique id
            
public readonly int Sp0;                            //Spare 0
            
public readonly int UCOAction;
            public 
readonly int Sp2;                            //Spare 2
            
public readonly int Sp3;                            //Spare 3
            
public readonly int Time;                           //hundredths of a second since start (as in SMALL_RTP)

            
public UCO(byte[] packet)
            {
                
//byte    Size of packet;        // 28
                //byte Type of packet;      // ISP_UCO
                //byte ReqI;                // 0

                
PLID pakGetByte(packet3);                   //1 Byte PlayerID
                
Sp0 pakGetByte(packet4);                    //1 Byte Spare
                
UCOAction pakGetByte(packet5);              //1 Byte Flag
                
Sp2 pakGetByte(packet6);                    //1 Byte Spare
                
Sp3 pakGetByte(packet7);                    //1 Byte Spare
                
Time pakGetInt(packet8);                    //4 Bytes [RaceTime hundredths of a second since start (as in SMALL_RTP) GetLapperVar("RaceTime)"]

                //Info of PlayerCar
                
C.Direction pakGetByte(packet12);           //1 Byte
                
C.Heading pakGetByte(packet13);             //1 Byte
                
C.Speed pakGetByte(packet14);               //1 Byte
                
C.PlayerPosZ pakGetByte(packet15);          //1 Byte
                
C.PlayerPosX pakGetShort(packet16);         //2 Bytes
                
C.PlayerPosY pakGetShort(packet18);         //2 Bytes

                //Info of object(Checkpoint/Circle)
                
OBJInfo.pakGetShort(packet20);            //2 Bytes
                
OBJInfo.pakGetShort(packet22);            //2 Bytes
                
OBJInfo.pakGetByte(packet24);             //1 Byte
                
OBJInfo.Flags pakGetByte(packet25);         //1 Byte
                
OBJInfo.Index pakGetByte(packet26);         //1 Byte
                
OBJInfo.Heading pakGetByte(packet27);       //1 Byte
            
}
        }

===============================
SPX insimpacket
===============================

 
/// <summary>
        /// Split X time decoder
        /// </summary>
        // SPX OK for insim 4
        
public class SPX
        
{
            public 
readonly int PLID;
            public 
readonly long STime;
            public 
readonly long ETime;
            public 
readonly int Split;
            public 
readonly int Penalty;
            public 
readonly int NumStop;
            public 
readonly int Sp3;

            public 
SPX(byte[] pak)
            {
                
//byte    Size of packet;            // 28
                //byte Type of packet;          // ISP_SPX
                //byte ReqI;                    // 0
                
PLID pakGetByte(pak3);      //1 Byte Player ID
                
STime pakGetUnsigned(pak4); //4 Bytes Split time (ms)
                
ETime pakGetUnsigned(pak8); //4 Bytes Total time (ms)
                
Split pakGetByte(pak12);    //1 Byte split number 1, 2, 3
                
Penalty pakGetByte(pak13);  //1 Byte current penalty value
                
NumStop pakGetByte(pak14);  //1 Byte number of pit stops
                
Sp3     pakGetByte(pak15);  //1 Byte Spare
            
}
        }
?>

According to Scawen's reply, the issue may be related to needing to control the lights for InSim checkpoints to work.

Been trying this out using the startlights script you made, but doesn't seem to matter what I do, I can't get the timer to start properly when green light goes on.

While I was doing that, I was thinking about the saving of the InSim sector and lap times (using Set and Get). Likely that these could be saved, but I think I'm right in saying that these would be saved in the storedvalue database rather than in the GripPB database, in which case, you couldn't list the top times from both databases in the same table. Maybe unless you also saved (Set and Get) the AutoX checkpoints too?

Anyway, decided as I can't get things to work, I am abandoning the project now.

Thanks for the help during my attempts to get it working.
Ill look into that later, when i finally moved to my new house.
Maybe its an idea to set a racetimer in Lapper that starts when the lights go green. But i need to know how.
New publictest version: (Thx Yisc[NL] for testing)

This contains a fix for displaying the visible results within a list in one of the TOP lists : User/Drift/Race
It had to be implemented since 7.0.4.10, but for some reason i havent changed the parameter in the final version.

01: Changed hardcoded visible records in Toplist/UserTop/Drifttop from 24 to 10000

$list = GetListTop( getConfigVar( DefaultTopCar ), 0, 0 );
Note: Users must edit theire script to see the max visible Records. This can be done with a FOR loop:


<?php 
FOR( $i=0;$i<25;$i=$i+1)
ENDFOR
?>

Attached files
LFSLapper.exe PublicTest_04.zip - 161.1 KB - 308 views
If I'm understanding it correctly, Scawen is saying you need to control the lights yourself if you want to know when they're green. The actual moment the standard lights change to green is hidden from insim (I think for foiling scripted launches) when it happens. You can work out the exact start time as soon as the first car hits the first split, but not until then.

The insim-controlled lights do lag the control packet being sent a little though, so you wouldn't have an exact time doing it through insim.

You could use an insim checkpoint on the start line to get a reference, but it wouldn't quite be on green, it'd be green + reaction time + inertia.

Maybe use both methods and tune a ratio between them Smile
1
This thread is closed

FGED GREDG RDFGDR GSFDG