I was reading forum earlier about someone wanting a way to measure and show gforce (http://www.lfsforum.net/showthread.php?p=1502458#post1502458) and I wondered if it could be done with lapper.
Well, it can!
Assuming my maths is correct, the code is as follows:
And don't forget to put following in your language file;
If you want to make increase or decrease the number of decimal places, (above code outputs to 2), so change the number at end of $gforce_mph and $gforce_kph to suit. If you take away the round() function, it gives 5 or 6 decimal places.
Also, not sure, but I suppose it's possible (but beyond me) to save the gforce "scores" in one of the lapper databases and output as a table to show best/highest gforce.
txt attachement is for my workings out - NOT lapper code.
Aide Memoir:
gravity = 9.80665 metres per second
9.80665 m/s = 21.936851 mph or 35.30394 km/h
Well, it can!
Assuming my maths is correct, the code is as follows:
<?php
Event OnAcceleration( $userName )
$AccelerationStartSpeedMph = 1; # At which speed to start measuring time. In Mph
$AccelerationEndSpeedMph = 60; # At which speed to stop measuring time. In Mph
$AccelerationStartSpeed = 1; # At which speed to start measuring time. In km/h
$AccelerationEndSpeed = 100; # At which speed to stop measuring time. In km/h
$gravity_mph = 21.93685; # An acceleration of 21.93685 mph per second is equal to 1g (0 - 100 mph in 1 second = 4.56g)
$gravity_kph =35.30394; # An acceleration of 35.30394 kp/h per second is equal to 1g
$ass = GetCurrentPlayerVar("AccelerationStartSpeed"); # Starting speed
$aes = GetCurrentPlayerVar("AccelerationEndSpeed"); # End speed
$at = GetCurrentPlayerVar("AccelerationTime"); # Acceleration time achieved from start to end speed
$us = GetCurrentPlayerVar("UnitSpeed"); # Unit of the speed of the player's car
$gforce_velocity_difference = ($aes - $ass);
$gforce_accel = $gforce_velocity_difference/$at;
$gforce_mph = round(($gforce_accel/$gravity_mph),2);
$gforce_kph = round(($gforce_accel/$gravity_kph),2);
IF ($us = "mph")
THEN
openPrivButton( "gforce",77,60,46,8,5,5,32,langEngine("%{main_gforce}%",$gforce_mph ));
ELSE
openPrivButton( "gforce",77,60,46,8,5,5,32,langEngine("%{main_gforce}%",$gforce_kph ));
ENDIF
EndEvent
?>
<?php
LANG "EN"
main_gforce = "^7You pulled ^1{0} ^7g's";
EndLang
?>
Also, not sure, but I suppose it's possible (but beyond me) to save the gforce "scores" in one of the lapper databases and output as a table to show best/highest gforce.
txt attachement is for my workings out - NOT lapper code.
Aide Memoir:
gravity = 9.80665 metres per second
9.80665 m/s = 21.936851 mph or 35.30394 km/h