The online racing simulator
Searching in All forums
(879 results)
LFSLapper Adding ISP_CSC (Car's State Changed) packet
Bass-Driver
S3 licensed
hi,

I've added a another small event.
This event shows when the Car's State is changed.

For now it only reports when the car is driving or has been stopped.

##########################################################
#Actions to do when Car's State is changed#
##########################################################
#When $StateOfCar(bits) returns a value
#CSC_STOP, //0 Car stopped
#CSC_START, //1 Car started moving

Event OnCarStateChanged($userName,$StateOfCar)
/*
IF($StateOfCar == 0)THEN
globalmsg(getplayervar($userName,"NickName")."^7 Stopped the car!");
ENDIF
IF($StateOfCar == 1)THEN
globalmsg(getplayervar($userName,"NickName")."^7 Start driving!");
ENDIF
*/
EndEvent

Other value's that i could add in the Event Header.

-Time (current racetimer)
-Direction of the car
-Heading of the car
-Current Speed of the car (speed always be 0 or 1)
-X/Y/Z Coordinates


THIS IS A TEST VERSION
Any feedback whould be nice
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
There are a few steps to measure the distance between "The location" and "The Driver".

First: You have to set the Coordinates of the location.


CatchEvent OnLapperStart()
RegisterzoneAction( "BL1" , -60,106,4, CarShop, "");

#-60 = X-Coordinate
#106 = Y-Coordinate
#4 = width of your location
EndCatchEvent

You can check your coordinates with the !zone command.

When someone drives throught that location a sub is called named: CarShop

Sub CarShop($userName)
IF (BLABLA) THEN
#Write your code here
ENDIF
EndSub

Now you know the coordinates of the location (CarShop) and yourself !zone.

To measure the distance between you and the destination (CarShop)
To make it easy, you could create a command.

CASE "!addcheckpoint":
$X1=GetCurrentPlayerVar("X"); #Own X coordinate
$Y1=GetCurrentPlayerVar("Y"); #Own Y coordinate
$X2= -60; #CarShop Location X coordinate
$Y2= 106; #CarShop Location Y coordinate

$distX = $X1 - $X2;
$distY = $Y1 - $Y2;
$distuser = ($distX*$distX) + ($distY*$distY); #Calculate distance between You and The CarShop.
privmsg("^8Distance between you and the location: ^3" .$distuser. "^8 Meters");
BREAK;

Note:
Realtime Distance Measuring is not possible in Lapper by default.
You must modify the LFSLapper.exe, which asks C# coding skills.

Correct me if i'm wrong.
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
Well here's a another examplecode. Its a peace of code from a minigame i made.
I've edited a bit.


CASE "!addcheckpoint":
$CPX = GetCurrentPlayerVar("X"); #Get X-axis from player
$CPY = GetCurrentPlayerVar("Y"); #Get Y-axis from player

cmdLFS("/msg ^6›^7New Checkpoint is : ^0(^2X= ".$CPX."^7/^2Y= ".$CPY."^0)" );
RegisterzoneAction( getLapperVar( "ShortTrackName" ), $CPX,$CPY,4, FoundCheckPoint, "");
BREAK;

Sub FoundCheckPoint( $userName )
#Your code when a player drives throught the zone.
EndSub

Bass-Driver
S3 licensed
hi,

Here is a example code how to calculate the distance between 2 drivers or whatever you like.


$X1=GetPlayerVar( $Player1, "X" ); #Own X coordinate
$Y1=GetPlayerVar( $Player1, "Y" ); #Own Y coordinate
$X2=GetPlayerVar( $Player2, "X" ); #User2 X coordinate
$Y2=GetPlayerVar( $Player2, "Y" ); #User2 Y coordinate

$distX = $X1 - $X2;
$distY = $Y1 - $Y2;
$distuser = ($distX*$distX) + ($distY*$distY); #Calculate distance between user


Bass-Driver
S3 licensed
As promised: New LFSLapper Version

Version: 7.0.4.0
Contains function to control autoX startlights.

+-------------------------------+
|Changes from 7.0.3.0 to 7.0.4.0|
+-------------------------------+
1. New Lapperfunction:
startlightcontrol(5,149,1,1); #Control AutoX StartLights // More info in 'Control StartLights.txt' in 'Docs' folder. includes Examplecode

2. Renamed/added Objects for $DetectHitobject var.
Changed: All_Railings' renamed to 'All_Armco
Add: Railing


Have Fun
Bass-Driver
S3 licensed
Ill push this update(7.0.3.1) as official release next weekend. Maybe sooner.
New Version will be (7.0.4.0).
Bass-Driver
S3 licensed
I can set 12 startlightcontrol() functions without crashing.

startlightcontrol(5,149,0,1);
startlightcontrol(5,149,1,1);
startlightcontrol(5,149,2,1);
startlightcontrol(5,149,3,1);
startlightcontrol(5,149,4,1);
startlightcontrol(5,149,5,1);
startlightcontrol(5,149,6,8);
startlightcontrol(5,149,7,1);
startlightcontrol(5,149,8,1);
startlightcontrol(5,149,9,1);
startlightcontrol(5,149,10,1);
startlightcontrol(5,149,11,1);

Dont know what you mean about the Sub thing.
for testing the light i used this code.

EDIT: Moved example/test script to file
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
Its not a event, its a LapperFunction. See first post.

I havent copied the "src"folder, to the testversion. But 'All_Armco' should work.
And Objectnames ( Short/Medium/Long) Armco should work too
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
you can use the startlights for drag. But you cannot place those startlights in demo.
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
Here is the Test Version:

For documentation see first post.
I'm not sure what RESET and UNSET does.

Have Fun

Changes:

[Add]OCO Packet(Startlight Control) (Test)
[Change]ObjectHit: All_Railings' renamed to 'All_Armco'

Edit: Released new LFSLapper version 7.0.4.0 , See Release Thread
Last edited by Bass-Driver, .
LFSLapper adding ISP_OCO packet (StartLight Control)
Bass-Driver
S3 licensed
Hello everyone,

Today i started with implementing the OCO packet in LFSLapper.

After a few tests , the startlight control works good, so far.

You can control the startlights by using a new function:

LapperFunction:
startlightcontrol(5,149,1,1);
startlightcontrol($LightAction,$LightIndex,$LightIndentifier,$LightColor);

Be sure those vars are GlobalVars.

$LightAction:

#4 = OCO_LIGHTS_RESET, // give up control of all lights
#5 = OCO_LIGHTS_SET, // use Data byte to set the bulbs
#6 = OCO_LIGHTS_UNSET, // give up control of the specified lights

$LightIndex:

AXO_START_LIGHTS (149) or STARTLIGHTS_TRACK (240)

$LightIndentifier:

identify particular start lights objects (0 to 63 or 255 = all)

You can give each StartLight a differend number in AutoX editor:

$LightColor:


STARTLIGHTS_TRACK(240) AXO_START_LIGHTS(149)
0 = off 0 = off
1 = red1 1 = red
2 = red2 2 = amber
4 = red3 -
8 = green 8 = green

First testversion will be released soon.
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
Sorry for the incomplete 'ObjectsList'

Should be: TrackSide_Objects
if (newCfg.varsLapper.DetectHitObject.Contains("TrackSide_Objects") && (obh.Index == 0)) //(Scenery Objects)

Changed: 'All_Railings' to 'All_Armco'
Add: 'Railing' as object

Shall i rename the objects too?
Bass-Driver
S3 licensed
Thanks,

I have changed the TrackList file in the DEV version.
The future release could take a while, because i have to update the scripts on my lapper.

Thank you all for testing and enjoy the new version of LFSLapper.
Bass-Driver
S3 licensed
New LFSLapper version:

+-------------------------------+
|Changes from 7.0.1.0 to 7.0.3.0|
+-------------------------------+
1. LapperInsimVersion changed to Version 7 (Thanks to Yisc[NL])

2. New Events:
Event OnCarContact($PlayerA,$PlayerB,$PlayerA_Speed,$PlayerB_Speed,$PlayerA_X,$PlayerB_X,$PlayerA_Y,$PlayerB_Y) # Player event
Event OnCrossingChecker($userName,$Flags,$Time,$Object,$UserSpeed,$CircleIndex) # Player event

3.New PlayerVar:
Z, //Height of player on track
+-------------------------------+
|Changes from v6.014 to 7.0.1.0 |
+-------------------------------+
1. New player vars (case sensitive):
ObjectContactSpeed, //Speed of player when hitting a object
ObjectContactHead, //Heading of player when hitting a object
ObjectContactDir, //Direction of player when hitting a object

AccelerationStartSpeed2, // Min value for the acceleration feature relative to user unit km or mph
AccelerationEndSpeed2, // Max value for the acceleration feature relative to user unit km or mph
AccelerationTime2, // Acceleration time achieved from start to end speed

2. New Lapper Vars
$AccelerationStartSpeed2 = 100; # At which speed to start measuring time. In km/h
$AccelerationEndSpeed2 = 160; # At which speed to stop measuring time. In km/h
$AccelerationStartSpeedMph2 = 60; # At which speed to start measuring time. In Mph
$AccelerationEndSpeedMph2 = 100; # At which speed to stop measuring time. In Mph
$AccelerationPrivateMaxTime2 = 10; # Maximum acceleration time in seconds to show message

$DetectHitObject = ""; #To get objectstrings for detection look at docs/ObjectHit.txt

3. New Events:
Event OnAcceleration2( $userName ) # Player event
Event OnObjectHit($userName,$ObjectFlag,$ObjectHitTime,$Object_X,$Object_Y,$Object_Z,$ObjectType) # Player event

Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
Final Release: CON (Carcontact) and UCO (InSim checkpoint / InSim circle) packets


Update: -Add Circleindex to OnCrossingChecker event.
-Version numbering is changed. Last number is now for small codechanges like bugfixes etc.

See first post
ISP_UCO help
Bass-Driver
S3 licensed
hi,

Ive add the UCO packed in LFSLapper, which is working well.
https://www.lfs.net/forum/thre ... per-adding-ISP-UCO-packet

i have a question about it.

Is it possible to indicate the InsimCircle Index(Object index = 253) and Insim Checkpoint 1/2/3/F(Object index = 252)?
I have red the LytFormat file but i dont know how to code it.

Could someone give me a helping hand?
Bass-Driver
S3 licensed
Whould be nice if it possible to indicate which Checkpoint or Checker you acrossed.
LFSLapper adding ISP_UCO packet
Bass-Driver
S3 licensed
New Packet/Event , new thread.

New packet: UCO - report InSim checkpoint / InSim circle (autoX objects)

To get data from this packet, the new insimversion is required
Thanks to Yisc[NL] for fixing this problem.

##########################################################
#Actions to do on Insim Checker/Checkpoint (AutoX object)#
##########################################################
#When $Flags(bits) returns a value
#UCO_CIRCLE_ENTER, //0 (00) User entered a Checker
#UCO_CIRCLE_LEAVE, //1 (01) User left a Checker
#UCO_CP_FWD, //2 (10) User crossed Checkpoint in forward direction
#UCO_CP_REV, //3 (11) User crossed Checkpoint in reverse direction

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

Edit: Check for newest release in Release Thread.
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
This should be a sticky topic.
Bass-Driver
S3 licensed
New packet: UCO
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
Congrats you did. Thank you
i'm soo stupid.

i totally missed the byte[] or i just didnt know what it means. Sounds very logical to me now. Each packet is 1 byte.

To be sure it works i have add a UCO packet.
As you can see i get data from it.
Bass-Driver
S3 licensed
Lapper sends ISI data to LFS with

byte[] inSimInit = myEncoder.ISI(adminPassword, 0, 0, nameApp, isLocal);
try
{
this.Send(inSimInit, inSimInit.Length);
}
/////////////////////////////////////////////////////////////////////////////////////
public byte[] ISI(string adminPass, int portNum, byte mciSeconds, string nameApp, bool local)
{
byte[] packet = new byte[44];
packet[0] = 44;
packet[1] = (byte)TypePack.ISP_ISI;
packet[2] = 1;
packet[3] = 0;
// Port
packet[4] = (byte)(portNum % 256); // LSB
packet[5] = (byte)(portNum / 256); // MSB

// Flags
if (local)
packet[6] = (byte)ISF.MCI | (byte)ISF.LOCAL | (byte)ISF.OBH | (byte)ISF.CON; // LSB
else
packet[6] = (byte)ISF.MCI | (byte)ISF.OBH | (byte)ISF.CON; // LSB

packet[7] = 7; //Insim Version

packet[8] = 0;

packet[9] = (byte)'!';

// Number of milli seconds between NLP or MCI packets (0=none)
packet[10] = 100; // LSB
packet[11] = 0; // MSB

System.Text.Encoding.ASCII.GetBytes(adminPass, 0, Math.Min(adminPass.Length, 16), packet, 12);
System.Text.Encoding.ASCII.GetBytes(nameApp, 0, Math.Min(nameApp.Length, 16), packet, 28);

return packet;
}

Also i have found a peace of code that isnt used:

//request version Not Need in insim 4, because ISI send This
// byte[] verreq = InSim.Encoder.VER();
// this.Send(verreq, verreq.Length);
//retr version info

I have tried to add/changed code, but nothing works.
Bass-Driver
S3 licensed
ooh sh*t, i forgot to delete some code. About Insim_version 7: this is not the
insimversion that lapper is using. its just a var that i can request from the LFSversion packet.
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
I added 2 emtpy files: LapperVars and Lapper Functions. Here are a few examples.

LapperVars:

Event OnObjectHit:

$DetectHitObject = ""; #To get objectstrings for detection look at docs/ObjectHit.txt

Event OnMaxCarResets

$MaxCarResets = 0;

Static vars that cannot be changed while lapper is running.

Lapper Functions :

privmsg("Your Text here"); # Send text to player
globalMsg("Text Here");#Send text to all players

Not sure if i'm taking over lapper, because sometimes its very hard to understand the lapper sourcecode. And as a non-programmer, it was/is a struggling to get the code working.

But it was/is very learnable and fun todo. I know a littlebit more about C#.

For example: To request InsimVersion 7.
To get data from the newest packets, lapper must request the latest insim version, version 7 in this case. I have changed the code many times. Also i have checked other library's how they request the insimversion. But lapper is completely differend.

i have sent Gai-Luron a PM, to take a look. but no response yet.
Bass-Driver
S3 licensed
Thx, have changed it.

Maybe a good idea, to make a doc with all the lapper vars and functions.
FGED GREDG RDFGDR GSFDG