The online racing simulator
[Solved] Cruise GPS
Hi all!

I started coding LFSLapper cruise plugin about week and half, and the results are quite amazing!
Reading and researching helps a lot! Wink

After I finished making jobs etc, I forgot to add GPS from player position to job/place position.
But it's quite hard for me since i started week ago.

I have tried something like this.

Sub JobGPS()
IF ( GetCurrentPlayerVar( "JobTest" ) == "1" )
THEN
IF ( DistFromPlace($userName,$argv) <= "450" )
Return( "^7GPS: ^0••••••" );
ENDIF
IF ( DistFromPlace($userName,$argv) <= "250" )
Return( "^7GPS: ^0••^3••^0••" );
ENDIF
IF ( DistFromPlace($userName,$argv) <= "100" )
Return( "^7GPS: ^0•^2••••^0•" );
ENDIF
IF ( DistFromPlace($userName,$argv) <= "50" )
Return( "^7GPS: ^2••••••" );
ENDIF
ENDIF
EndSub

Now
Sub DistFromPlace()

has nothing in it, and I'm afraid that LFSLapper doesn't catch the job position as i registered with RegisterZoneAction.

Any help is appreciated! Smile
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


I understand the calculation between drivers, but If i want to calculate the distance between the driver, and the position he wants to be in, how can be that done?

Eg: Player 1 is at KinderGarten and wants to escort "someones child" to his house as a job, therefore the GPS should identify the position of "someones house" between the driver.

If there's a way to identify the position as a driver, could it be possibly done?

Thanks.
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

Thanks! I'll see what I can do with it. =)
Just as a reminder, using X and Y coordinates is okay, but don't forget that it will calculate the shortest possible length between those two coordinates.
The program doesn't know if that route is possible or not, while in fact that route will never be possible, unless you are driving on the parkinglot with no obstacles at all.
I'm kind of lost, apologies for my impatience, kind of frustrated. Face -> palm

I have tried something like this.

Sub JobGPS()
IF ( GetCurrentPlayerVar( "JobTest" ) == "1" )
THEN
IF ( DistFromPlace($userName) <= "450" )
Return( "^7GPS: ^0••• •••" );
ENDIF
IF ( DistFromPlace($userName) <= "250" )
Return( "^7GPS: ^0••^3• •^0••" );
ENDIF
IF ( DistFromPlace($userName) <= "100" )
Return( "^7GPS: ^0•^2•• ••^0•" );
ENDIF
IF ( DistFromPlace($userName,) <= "50" )
Return( "^7GPS: ^2••• •••" );
ENDIF
ENDIF
EndSub

Sub DistFromPlace($userName)
$gpsplace = ToNum( ToNum( GetCurrentPlayerVar( "X" ) - ToNum( GetCurrentPlayerVar( "Y" ))));
EndSub

I want position from player to current destination. Wouldn't GetLapperVar Work?

Any information and help is appreciated! Smile
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.
WOW! This actually helped me massively, thanks a lot! very informative and helpful, I should credit you on my insim plugin for this amazing piece of information =)

Thanks again. really informative.
This thread is closed

FGED GREDG RDFGDR GSFDG