The online racing simulator
Commentary on the "getstat" LFS World script
(358 posts, started )
You can get some of that data from Vortex's Server Script. But with regards to times, that could only be retreived through InSim.
Quote from Victor :i'll keep this in mind for a future update.

excellentasticomente
Quote from the_angry_angel :You can get some of that data from Vortex's Server Script. But with regards to times, that could only be retreived through InSim.

For me connecting to InSim with PHP is the holy grail. I would love to be able to get all of the laps times for the players on a server as they are going around. That would be soo awsome. And I don't think it would take so much time with some C programing on the back end of the LFS server and a query PHP script on the web sever. Sounds like a sick idea.
Quote from the_angry_angel :You can get some of that data from Vortex's Server Script. But with regards to times, that could only be retreived through InSim.

Thanx! This goes above my skills at the moment.

/Tooby
Quote :The script requires webspace with PHP functionality. Also access to the hostXXXXX.txt file of the gameserver is required. This can be either by FTP or HTTP.

That for me pretty much kills it, what if I should want to get information from a server I don't own. What if I am hosting a website from one end and the game server is on the other. It would seem that you would need FTP or HTTP access to the host file. That's just so . . . Ew. Victor, I want to be able to get stats from a server like so.

Webserver (PHP) -> (Internet) -> Gameserver (LFS)
Or if you'd like we could also do this.
Webserver (PHP) -> (Internet) -> LiveForSpeedWorld (HTTP) -> Gameserver (LFS)

The webserver running PHP connects to the Gameserver (Or LFSW) and gets information such as, Track, Mode (Practice / Quly / Race), Laps, Time, and Number of Players. Then information for each race would be as so, Racer's LFSW Name, Racers Nickname, Car, Lap, Time (For Current Lap), Split 1, Split 2, Split 3, Speed Trap, and Stats (DT, SG, 25, 45, DQed).
Quote from Dygear :That for me pretty much kills it, what if I should want to get information from a server I don't own.

Well first off you'll need the URL to get it from. Second, if the administrator is using his brain, it will be password protected. Yes, you could get this information by packet sniffing, but you'd need to get that onto the webhost - and lets face it if you can do that, then whats the point in just going for the hosts.txt file?

Quote :What if I am hosting a website from one end and the game server is on the other. It would seem that you would need FTP or HTTP access to the host file. That's just so . . . Ew. Victor, I want to be able to get stats from a server like so.

You use HTTP to talk to LFSW's pubstats. Whats the problem.

Quote :The webserver running PHP connects to the Gameserver (Or LFSW) and gets information such as, Track, Mode (Practice / Quly / Race), Laps, Time, and Number of Players.

You can already get this from LFS World, but...

Quote :Then information for each race would be as so, Racer's LFSW Name, Racers Nickname, Car, Lap, Time (For Current Lap), Split 1, Split 2, Split 3, Speed Trap, and Stats (DT, SG, 25, 45, DQed).

...not in that level of detail though. There is a time limit of about 60 seconds between each LFS World pubstats query, if I remember correctly, so this level of detail is tricky without it being vastly irrelevant. If you want this much detail, write an InSim server to do it, and then query that - much better.

Software is all about choice. If you dont like it, dont use it. Simple.
Thanks Angel, looks like I am going to do some InSim programming.
(Damn, now I need to teach myself struts in C++).
Dont forget, you're not restricted to using C or C++; anything capable of running sockets should work fine. Even a php script running as cgi (not that you'd want to do this).
Quote from the_angry_angel :Dont forget, you're not restricted to using C or C++; anything capable of running sockets should work fine. Even a php script running as cgi (not that you'd want to do this).

I did not know that PHP had struts, if you could show me somewhere I could learn about them, that would be awsome. I am taking it that a strut is a datatype, and I can't really find anything on them.
Quote from Dygear :I did not know that PHP had struts, if you could show me somewhere I could learn about them, that would be awsome. I am taking it that a strut is a datatype, and I can't really find anything on them.

I think you are confusing "struts" with "structs"; Struts is an MVC framework originally written in Java (but now with clones / ports to other languages), where as a struct is as you assumed a data type.

PHP doesn't have structs, but then you don't need a struct in PHP. An assoc array or a custom class (if it has a few functions tied to it) would be perfectly suitable.
fuel burnt in dl.

What is DL? Deciliters?

1 deciliter = 0.0264172051 US gallon . . .
Hmm it's Centiliters, so the dl seems to be wrong...
Hello all,

I want to startup a hotlap competition for our team, there for i want to display de hotlaptimes from our teammembers on our site. Can somebody help me?

I don't know anithing about programing, so it got to be simple.

If i can modify de teammembers, track and car in a file that displays it in a table and i can include on an other page. I'll be happy.

Display

Teammember - Track - tracklayout - time.

I hope somebody can help me with this, a code that i can copy is very welcome.

Tnx
UPDATE:

We're now at version 1.2. A new feature has been added, which is the hl_log (hotlap log). It comes with plenty of features to make it easy for everyone (see first post of this thread for all details).

Another update is that an id has been added to hotlaps and wr's. This id can be used to download the replay of any hotlap (again, for details, see the first post of this thread).

@nikka - I did not do the chart indication. This would cause a massive impact on our db, so I can't do that. Instead, if you really want to have chart positions, there is something you can do now that the hl_log has been added, namely, you can create your own exact copy of the entire hotlaps db, so you can calculate chart positions yourself.
You can do this by requesting all hotlap charts once and store those. Then all you have to do is make use of the new hl_log, which returns all the new hotlaps. You add these to your own db and you'll always be up to date.
*edit*Skip to the 'The point' bit if you can't be arsed to read all of my babble. There is a point. I promise *edit*

Excellent stuff Vic, although the 'format' parameter seems to deviate from your (up until now) 'I'll give you the data, you do what you like with it' mantra.

I only have one 'gripe', if you like with the LFSWorld data now.
PBs and PSTs.
Anyone who has written a script to get these on a restricted server (especially if you want both of them because they share a tarpit) will tell you that the current method is a pain in the arse.

Consider a page with a team listing.
Each driver has basic information, car number, name, plate, plus a couple of stats and their best PB.
Lets assume that this team has 15 members.

Now, how to get the data?
The easy way around would be alter the max execution time & make the requests in a loop, sleeping for 5 seconds at the end of each iteration.
(15 * 5) * 2 = 150 seconds.
15 drivers, 5 second delays, once for PBs, again for PSTs.

But not everyone has permission (iirc safe_mode restricts this) to alter the max execution time. Some hosts even limit it to lower than default times.

So how to get it if you can't alter the execution time? A cyclic, or round robin cache mechanism, or alternatively a caching request chain.

The first involves picking a name from the top of the driver list, updating and putting them at the bottom, except each driver needs to appear twice. Once for PB, once for PST.

The second is a bit of a hack, but it gets the job done as quick as a for loop but with only a 5 second execution time required.
Basically, a root request is made that takes the same list a cyclic cache would use as an url parameter. The script takes the first one off the list, requests the data, sleeps for 5 seconds and then recurses by making a HTTP request for itself with the new list. This carries on until the list is empty, at which point the job is done.

IMO that is a very long way around, and incredibly wasteful.

The point

I think a separated list of usernames for PB and PST with separate tarpits of at least a minute would make a lot more sense, especially considering that the majority of users for the lfsworld data seem to be teams.
I don't know the request numbers, and I don't know the database schema, but taking our example above, 2 queries has to be better than 30, especially if there are any joins involved.

Of course thats just my opinion and could be total twaffle, but it makes sense to me.

Otherwise, keep up the good work
Quote from Anarchi-H :I think a separated list of usernames for PB and PST with separate tarpits of at least a minute would make a lot more sense, especially considering that the majority of users for the lfsworld data seem to be teams.

Wow, was just writing a simular request when you beat me to it..

The way I do it today (see http://noobs.vossmedia.de/stats.php (not finished btw, still working on it)) is quite... complex since I have to do one hl/pst/pb-request at a time with a 5 sec delay. Being able to retrieve hl/pb/pst for multiple racers in one request would make life waaaay easier..
Quote from Victor :@nikka - I did not do the chart indication. This would cause a massive impact on our db, so I can't do that. Instead, if you really want to have chart positions, there is something you can do now that the hl_log has been added, namely, you can create your own exact copy of the entire hotlaps db, so you can calculate chart positions yourself.
You can do this by requesting all hotlap charts once and store those. Then all you have to do is make use of the new hl_log, which returns all the new hotlaps. You add these to your own db and you'll always be up to date.

BTW, thanks for the update! My goal was to minimize the number of db requests, so this should work just fine
Hi again!
Thanx Victor for giving us the hl_log.
I almost don't dare to ask but...Could some one explain the date stamp (
<entry uploaddate="1136678609">).

Thanx in advance
/Tooby

Edit: Is there any good (free) php editors where you can have auto complete on commands and easy to find help?
Quote from Tooby :Thanx Victor for giving us the hl_log.
I almost don't dare to ask but...Could some one explain the date stamp (
<entry uploaddate="1136678609">).

Thanx in advance
/Tooby

Edit: Is there any good (free) php editors where you can have auto complete on commands and easy to find help?

It's a unix timestamp. For information on how to translate it in to an easier read format, see http://www.php.net/manual/en/function.date.php

As for auto completing editors, I can't help you. I gave up on 'em long ago, and now instead use gVIM and the reference manual.
A little addition to the XML hotlap log which Vic and I have been developing recently. I'm using the script's output for the WR log at the new LFS Files Setups page

<track> - The ids resolve as follows:
0 - Blackwood
1 - South City
2 - Fern Bay
3 - Autocross/Drag (should never occur in hotlap log)
4 - Kyoto Ring
5 - Westhill
6 - Aston

<config> - The ids refer to the number of the config, starting by 0 for each track.

<rev> - Boolean value 0 or 1 if rev or not.

For example:
BL GP: track = 0, config = 0, rev = 0
Kyoto National rev: track = 4, config = 1, rev = 1
Aston Grand Prix: track = 6, config = 4, rev = 0

<car> - The cars are listed in the exact order as they appear in LFSWorld:
0 - XF GTI
1 - XR GT
2 - XR GT Turbo
3 - RB4 GT
4 - FXO Turbo
5 - LX4
6 - LX6
7 - MRT5
8 - UF 1000
9 - Raceabout
10 - FZ50
11 - Formula XR
12 - XF GTR
13 - UF GTR
14 - Formula V8
15 - FXO GTR
16 - XR GTR
17 - FZ50 GTR
Small issue with the XML output when the list returned should be empty. The other two formats simply supply 'no output', but the XML one supplies only '</hotlaplog>' which is invalid xml and may throw some parsers, or at least cause bitching about mismatched tags or lack of xml declaration.

Example;
http://www.lfsworld.net/pubsta ... p;control=ks&format=2

In addition, at least one new error message has been introduced. If 'version' is less than 1.2 when requesting 'hl_log', the script returns:

hl_log is only available since version 1.2 and later

*edit*

hl_log appears to be pretty bustified
First, it says 'had uploaded a new WR'. Shouldn't that be 'has' and 'HL'?
Second, the position does not have a value for format 1, and always appears as '1' in format 2.
And lastly, format 1 is missing data, namely track and position.

Unless I missed something and that is how it is supposed to be :s

*edit2*
Just confirmed, format 3 has the same position problem as format 2.
Quote from Anarchi-H :Small issue with the XML output when the list returned should be empty. The other two formats simply supply 'no output', but the XML one supplies only '</hotlaplog>' which is invalid xml and may throw some parsers, or at least cause bitching about mismatched tags or lack of xml declaration.

Example;
http://www.lfsworld.net/pubsta ... p;control=ks&format=2

fixed
Quote from Anarchi-H :
First, it says 'had uploaded a new WR'. Shouldn't that be 'has' and 'HL'?

fixed, but not HL - it's a WR
Quote from Anarchi-H :
Second, the position does not have a value for format 1, and always appears as '1' in format 2.

wha?
Quote from Anarchi-H :
And lastly, format 1 is missing data, namely track and position.

huh?
Quote from Anarchi-H :
Unless I missed something and that is how it is supposed to be :s

*edit2*
Just confirmed, format 3 has the same position problem as format 2.

Sorry, I don't understand the problem. Could do with some more explanation or examples, because positions and all looks dandy here.

<entry uploaddate="1136746340">
<racer>vishnou7022</racer>
<country>Vietnam</country>
<track>0</track>
<config>0</config>
<rev>0</rev>
<car>2</car>
<split1>28450</split1>
<split2>59730</split2>
<split3>85030</split3>
<split4>0</split4>
<pos>126</pos>
<control>w</control>
<flags>517</flags>
<id_hl>31048</id_hl>
</entry>

<u>18:52 08-01-2006</u> <b>vishnou7022</b> had uploaded a new hotlap to 126th place: <b>1:25.030</b> on <b>BL gp</b> with the <b>XRT</b></a>


edit - maybe you meant the laptime was missing in format 1, in the case of a WR. I can't see anything wrong otherwise.
Quote from Anarchi-H :It's a unix timestamp. For information on how to translate it in to an easier read format, see http://www.php.net/manual/en/function.date.php

As for auto completing editors, I can't help you. I gave up on 'em long ago, and now instead use gVIM and the reference manual.

Thanx for the information.

Edit: Question
Is hl_log gonna hold all uploaded hotlaps or just latest?
- (get latest entries from the hotlap upload log) compared to <log_filter> 1=WR's - 2=top10 - 3=top50 - 4=ALL
Why am I asking: earlier today I uploaded a spr and now I can't find it.(time of upload: 2006-01-08 01:03:29)
This is what I use:
http://www.lfsworld.net/pubsta ... log_filter=4&format=2
you'll always get the latest entries. The 'All' in the log_filter only means that it displays the entries no matter the chart-position they ended up in.
So, if you get a list with log_filter=1 , you get the 50 last uploaded wr's. If you get a list with log_filter=2, you get the 50 last uploaded hotlaps that ended up in the top10, but if you get a list with log_filter=4, you get the 50 last uploaded hotlaps - no matter their chart position.
You can set the amount of entries that it returns with the parameter &lines=50 (50 is default, 150 is max).
Quote from Victor :you'll always get the latest entries. The 'All' in the log_filter only means that it displays the entries no matter the chart-position they ended up in.
So, if you get a list with log_filter=1 , you get the 50 last uploaded wr's. If you get a list with log_filter=2, you get the 50 last uploaded hotlaps that ended up in the top10, but if you get a list with log_filter=4, you get the 50 last uploaded hotlaps - no matter their chart position.
You can set the amount of entries that it returns with the parameter &lines=50 (50 is default, 150 is max).

Thanx for the info!
* Would it be possible to add <id_hl>38155</id_hl> too &action=hl,ch and wr? (It would be nice to be able to get the *.spr file)
* Would it be possible to get the format option (xml) to the other actions?

Alot of silly questions...
/tooby


Commentary on the "getstat" LFS World script
(358 posts, started )
FGED GREDG RDFGDR GSFDG