The online racing simulator
Display total distance
(11 posts, closed, started )
Display total distance
display button distance code ??


Confused
You think you can ask code without doing anything?

Few questions:

-Did you used the search function on this forum to search for examples?
-Have you build something in LFSLapper before? YES? like what.
-Do you know how to add Buttons in LFSLapper. (Show example)
-Could you post the code you have trouble with.

Give correct anwsers to these questions and we might help you.
I'll Answer The Question:

-The search function in this forum to look for examples would you do?= I DID, I COULDN'T FIND

--------------------------------------------------------------------------------------------------------------
-Have you built anything in LFS lapper?=YES
Sample:

VehicleSpeed
VehicleType
Vehicle PlateNumber
and more...
--------------------------------------------------------------------------------------------------------------

-Do you know how to add buttons in LFS lapper? (Example display) YES

openGlobalButton( "sample1",0,100,20,4,12,-1,32,"^1clock^7: ^7". GetLapperVar ( "LongTime" ),"" );

-----------------------------------------------------------------------------------------------------------
-You can send the code I have the problem. I have no idea.
total vehicle miles went. but I have no idea.Shrug
There is an event in LFSLapper named :

<?php 
#################################################
#Action when a predefined dist is done by player#
# Minimum dist is 100 meters
# -1 deactivate this feature
#################################################
$distToDo 100;
Event OnDistDone$userName # Player event
EndEvent
?>


This event executes every time after every 100 meters the driver has driven.

To count the total distance see the examplecode below.
Examplecode:
SetPlayervar($userName,"DistXFG",(GetPlayerVar($userName,"DistXFG")+$distToDo));

To store the values
What you must do is to create an PlayerVar that will be saved in the LFSLapper database.
You could use these functions

Global var functions (fi_stored):

SetStoredValue("varname", $value) - sets a variable
GetStoredValue("varname") - returns variable as a string
GetStoredNum("varname") - returns variable as a numeric (or as -1 if it's not a number), so you don't need to do a ToNum($var) conversion if you're doing numeric comparisons

User var functions (fi_user_value):

SetUserStoredValue($username, "varname", $value) - Sets a variable
GetUserStoredValue($username, "varname") - returns variable as a string
GetUserStoredNum($username, "varname") - returns variable as a numeric

Button to display total distance.

openPrivButton( "totaldistance",75,111,50,10,5,-1,ISB_DARK, GetPlayerVar($userName,"DistXFG");

Have fun playing with it.
lapper, I'm new too and could you give the file that you prepare.

km.lpr ???

please and thank you
The total miles I can't Hard. Not give total

My English is bad, I use translation..
You have to understand, it wont help you , if i give you a working code.
To learn/understand LFSLapper. You have to try to create scripts yourself.

In my post i give you a good example how to display the total distance.
Now it is up to you to build something. Once you understand how it works. It will be more easily to make more scripts.

Also check out other "(un)finished" scripts aswell. Those scripts are a good way to learn creating scripts in LFSLapper.
just one more time.Na-na please wont can't.Thumbs upThumbs up

After 2 months I will learn the commands in LFSlapperWavePetals
You don't need to do anything complicated - the info you want is already coded as player variables in lapper - look for the playerVars.txt file in the /docs folder, and put them in a button...that's what I did, and I've been using my distance done panel for few years now.



From personal experience, be aware that repeatedly updating the distance info will result in lag on your server if more than a few people on track at same time.

Please don't ask me for further info or code ... you have been supplied with enough information in these posts to get what you want. If you can't do it now, wait the 2 months you talk about.
Attached images
LFS Distance done.jpg
CASE "!distance":
CASE "!dt":
privmsg( "Current Distance: " . Round(ToNum( GetCurrentPlayerVar("TotDistMeter") / 1000),1));
privmsg( "Total Distance: " . Round(ToNum( ToNum( GetCurrentPlayerVar( "KM" ) + GetCurrentPlayerVar("TotDistMeter") ) / 1000 ),1));
BREAK;


SetCurrentPlayerVar( "Dist", ToNum( ToNum( GetCurrentPlayerVar( "KM" ) + GetCurrentPlayerVar("TotDistMeter") ) / 1000 ));
setUserStoredValue( "Dist", GetCurrentPlayerVar( "KM" ) );








can you please edit this code.
Quote from FurkanBaglibel :CASE "!distance":
CASE "!dt":
privmsg( "Current Distance: " . Round(ToNum(GetCurrentPlayerVar("TotDistMeter") / 1000),1));
privmsg( "Total Distance: " . Round(ToNum(GetCurrentPlayerVar( "KM" ) + GetCurrentPlayerVar("TotDistMeter") / 1000 ),1));
BREAK;


SetCurrentPlayerVar( "Dist", ToNum(GetCurrentPlayerVar( "KM" ) + GetCurrentPlayerVar("TotDistMeter") ) / 1000);
setUserStoredValue( "Dist", GetCurrentPlayerVar( "KM" ) );


You are almost there.

Place The 2 last lines in 'OnDistDone' event. And see if it works. If it doesnt, check the errorfiles.
You will find them in the 'logs' folder(bin/default/logs)
This thread is closed

Display total distance
(11 posts, closed, started )
FGED GREDG RDFGDR GSFDG