The online racing simulator
#1 - EHR11
Measure distance between cars
Hi all.
I'm new on this of LFSlapper programming and I've wanted to make a Twin drift competition scorer. I've seen in some servers like Lislon DRIFT, a config capable to multiply drift points according to the distance between cars.
Anybody knows how to measure this distance on LFSLapper?
Use the X and Y player variables.

See !zone command in the LFSLapper.lpr file to see how they're used.

I think they increase in 1 metre steps.
#3 - EHR11
Thanks, I'll take a look.
#4 - EHR11
OK, I've seen both !zone and !node values. Now, comes another question. How can I get values from other players?
You will likely need to use GetListOfPlayers("N"); and WHILE command.

See Krayy's CIF modules (/default/includes/cif) on how these are used.
#6 - Krayy
If you use the GetCurrentPlayerVar function to get the name of the player in front of or behind you, you can then get their x and y loc like this:

<?php 

$me 
GetPlayerInfo( );
$behind GetPlayerInfo$me["UNameBehind"] );

$xdiff $me["X"] - $behind["X"];
...
etc
?>


TIP: Use the dumpvar($me) command to get a list of variables available in the array that getPlayerInfo returns printed in the lapper console
#7 - EHR11
Ok, the code I have so far is this.

<?php 
$yo 
GetPlayerInfo( );#My car
$adelante GetPlayerInfo$yo["UNameBefore"] );#Front car
$difx = ($yo["X"] - $adelante["X"]);
$dify = ($yo["Y"] - $adelante["Y"]);
Catchevent OnDriftScore    #Drift Event Starts
    
    
IF (difx <= 20) and (dify <= 20#If my car is close enough to the front car (rear doesn't matter yet)

    
THEN 
        $multi 
= ((difx+dify)/2)^-1)*(7); #multiplier
        
IF (multi >=5#
        
THEN           # MULTIPLIER LIMIT set to 5
            
multi =5;  #
        
ENDIF
        
$midrift =($yo["DriftScore"]) + (($yo["LastDriftScore"])*multi-($adelante["LastDriftScore"])); #Final drift score
    
ENDIF
?>

Am I going right? I'm missing something? Sorry for the inconvenience. I'm really n00b at this.
Put all the variables ($yo, $difx, etc) after the CatchEvent line.

Everytime you use a different CatchEvent, you will have to define the variables.

You also have to tell lapper what DriftScore and LastDriftScore are, as in

$DriftScore = GetCurrentPlayerVar( "DriftScore" );
$LastDriftScore = GetCurrentPlayerVar( "LastDriftScore" );

Tell lapper where the end of the event is by finishing with EndCatchEvent.

There's a built in drift scoring system included with lapper - look in
/default/includes/ for driftmeter.lpr. It isn't enabled by default. You have to enable it by opening the addonused.lpr file (in the same directory) - you can use notepad or similar to open and edit - and removing hash symbol from line #include( "./driftmeter");.

Have a look thru there to see how events and variables are used and called.

Also. Be aware of the differences between DriftScore and LastDriftScore; one gives you a score for the drift you've just done, and the other adds all these individual drift scores and gives you a combined total, which is saved at the end of a complete lap.
#9 - EHR11
Thank you very much, fellow! I'll start to fix this code. Thanks again!

FGED GREDG RDFGDR GSFDG