The online racing simulator
mpRes - race statistics web script
MOST RECENT DOWNLOAD
mpRes V2.08 to V2.10
mpRes V2.08
----------------------------------------------------------------------

Hello fellow racers and admins!

After by now a couple of years of playing around with it, I finally decided to publish my webscript for getting race statistics out of the replays.

About the script - the basics

mpRes is a php-script, designed to analyze multiplayer replays gathered from the racing simulation Live for Speed and to produce statistics out of them.
A great deal of the data thereby produced is long known to the community as the InSim-tool Live for Stats originally written by Gai-Luron offers similar features and is widely used to display race statistics. The features offered by mpRes are thus inspired by that tool.
A second basis for this script was the work done by MikeB during the development of his tool mprEdit. Thanks to MikeB - who published his results - we gained a little understanding to the inner structure of LfS multiplayer replays apart from the documented replay headers.
I was able to hook on here ...
The basic idea was to provide a possibility to simplify the offering of race statistics and results by rendering it unnecessary to cope with screenshots or to run the replay through the InSim tool and then manually adapt all the linking inside the resulting HTML-output.

The target audience
This script is designed especially for leagues that want to or must display whole seasons of results and for organizers of big single events, particularly those where takeovers are included and/or rejoining the race (possibly maintaining already done laps) is allowed.
As this script uses some predefined (via config-file) values that determine the outcome of it, I explicitly do not recommend parsing through random replays. For this purpose the abovementioned tool Live for Stats surely is the better choice.

What it does and what not
Well ... the script reads the replays, that you upload to your server and generates results in written and graphical form ...
To a certain extend you can alter the outcome of the results in order to comply with your event's rules. You might also incorporate penalties into your results (penalties may include time, laps or even disqualification of a racer).
On the other hand, it does not make things more simple than possible. The drawback of a quite easy handling once everything is configured is, that you have to configure things first, aditionally you are restricted in naming your replays in order to assign them to the event, they belong to. This might change in the future, when I'll have a database based version of the script ... but you'll be able to see average fuel consumption and engine damages ... just search for it ... Wink

Differences to ingame results
Out of various reasons the results gained by using this script can - and are to some extent meant to - differ from those obtained from LfS itself. These differences are mainly as follows:
  • Disqualifications (e.g. due to not having done a mandatory pitstop) are not automatically done by this script. Instead the racers are included normally into the result as I want the people responsible for an event to be able to decide, when a racer is to be disqualified and when not. Penalties (including disqualifications) can be given on a per file/player basis.
  • Unfinished racers can - depending on the configuration - be defined as finished and thus achieve a regular position (A minimum percentage of the total race distance is to be defined.).
  • Rejoining the race after a defined race progress will be rigorously and impartially ignored. Thus everything done (i.e. any laps) after such a rejoin will not show up in the result.
  • Results of different stints (due to rejoins) can - the corresponding setting provided - be added up to give a total result. A lack of that setting will result in only the last valid stint (see above for invalid ones) being evaluated.
  • Unfinished races, e.g. due to mass disconnections can be reasonably evaluated by manually adjusting the desired race distance.
OK, I think, that's it for the moment ... try it out and let me know, what you think Nod

Here it comes:
mpRes V2.08 to V2.10
mpRes V2.08

Changelog
Legend:

# -> Bug Fix
$ -> Language fix or change
+ -> Addition
- -> Removed
^ -> Change
! -> Note

-------------------------- 2.10 [08-Mar-2021] ------------------------

+ Added support for new mpr file version since LFS0.6V (Test)

-------------------------- 2.08-HFphp55 [11-Feb-2017] ------------------------

# fixed function for colored driver names in case php >= 5.5 is used

------------------------------ 2.08 [07-Feb-2017] ----------------------------

+ Added support for new mpr file version since LFS0.6Q10
+ Added support for updated Blackwood track

------------------------------ 2.07 [21-Feb-2016] ----------------------------

# Fixed broken support for replay containing layout data
! /setlap commands are not yet implemented at this stage, this will be done in the next version

------------------------------ 2.06 [14-Feb-2016] ----------------------------

+ Added support for new mpr file version since LFS0.6K9
+ Added support for Rockingham weather update
# Path files for Kyoto-Bugfix included
! /setlap commands are not yet implemented at this stage, this will be done in the next version

------------------------------ 2.05 [20-Dec-2015] ----------------------------

+ Added support for new Rockingham tracks in LFS0.6K
# fix for racers finishing laps before race even started
! /setlap commands are not yet implemented at this stage, this will be done in the next version

------------------------------ 2.04-hf [02-May-2015] ----------------------------

# fix for compatibility with php > 5.5.0 (modified pack/unpack)
! /setlap commands are not yet implemented at this stage, this will be done in the next version

------------------------------ 2.04 [02-April-2015] ----------------------------

+ add new Westhill tracks compatibility
^ increase of maximum players to 40
! /setlap commands are not yet implemented at this stage, this will be done in the next version

------------------------------ 2.03 [06-Janury-2015] ----------------------------

+ ignore takeovers in single driver replays
+ added quick results overview for simple lists (res) and csv exports (csv)

------------------------------ 2.02 [01-November-2013] ----------------------------

# fixed some error in graph_select.php
# fixed wrong function getlanguage() in includes/functions.php
# fixed wrong argument for font width in graphs_png.php
+ added language variables graph->all and graph->nosvg to lang/en.ini and lang/de.ini
+ added change of tyretype to pit icons (green tyre means type was changed, details are shown in tooltip)
^ added script version to footer, the script also checks now, if a result was created with a previous version and recreates it in that case

------------------------------ 2.01 [01-April-2013] ----------------------------

# fixed wrong language variable for race progress chart in graphselect.php (line 43)
# fixed wrong variable for lap-deviation of single drivers in tpl/sta.tpl.php (line 48)
# fixed some language variables in lang/en.ini
+ added handicap shown on results for finished players (includes/get_replays.php | includes/readmpr/header.php | includes/readmpr/postprocess.php | tpl/erg.tpl.php | lang/en.ini | lang/de.ini)

--------------- 2.00 final (first official release) [22-March-2013] -----------
Attached files
mpres208.zip - 6.3 MB - 1298 views
mpres208-210.zip - 34.4 KB - 762 views
#2 - troy
Nice, I always liked those cityliga stats, good to see you've decided to make it public.
I also have to recommend this tool highly. We as CityLiga are using this tool for years now and to be honest, it's perfect for our requirements as a league. If you're interested to see it in action, feel free to visit our results-section here:

http://cl.racemore.de/mpres/?lang=en

As a league with multiple grids and a couple of races per raceday sometimes, it's a big faciliation to set up the tool once before the season and just upload the replays after the races to have very quick results. As a league with possible time penalties it's very easy for us to implement this penaltys into a final result.

I also highly recommend the possibility of having detailed stats for endurance races with driver swaps etc. It's a USP of this tool and a very interesting feature.

Great to see this tool finally published
Congratulations on mpRes, its a very impressive piece of software. I'm in the process of moving over to it right now. I do however have a few questions, I was wondering if we can customize any of the software output? I use the english and plan to fix all the lower case lettering on most of the pages if you will allow that. Also wondering how hard it would be to also show intake and mass on the results page. We run a handicap system of racing it and would be a very handy thing to have.

Overall mpRes gets a massive thumbs up, i'm totally impressed as to how much time it will save me!

Edit: also some of the graphs don't appear to be showing fullsize they don't span accross the width of the page? Any ideas?
Hey!

Well, thanks for testing (and the the nice rating)!

If you have any suggestions for customizations or improvements, please feel free to tell me. For the language fixes, please do so (just post the corrected one afterwards, so I'll be able to implement it for later releases).
(Also for anybody else who is willing to translate to his own language, please submit a corresponding file, I'll implement it for coming releases!)

For the handicaps, unfortunately that's not possible, because these two parameters are not available to me.

The graphs that are sometimes not expanding to full width are a known bug. I'm quite sure that this is because the qidth is not explicitly stated in the object-tag of the html-code. Still need to come up with an idea for that. Suggestions are strongly appreciated

Oh, and in case you come across any errors, please provide the replay (or a link to it) and the settings (as stated in event_definitions.txt and/or .mprdiff) ... I'll have a look into it
No worries I have made some changes to the en.ini..Still checking over it all before I post..
I was hoping the intake and mass were available in the mpr headerhttp://www.lfs.net/?page=MPR..guess it is not that easy
Quote from therbo :I was hoping the intake and mass were available in the mpr headerhttp://www.lfs.net/?page=MPR..guess it is not that easy

OK, it is available there, but only for those cars, that physically finished the race. For any car that retired we do not get the information. That's why I decided to not have it at all, also as it only states the handicaps for that moment ...
Nevertheless I could implement that quite easily for the next release, but only with the restrictions mentioned above.
Quote from avetere :OK, it is available there, but only for those cars, that physically finished the race. For any car that retired we do not get the information. That's why I decided to not have it at all, also as it only states the handicaps for that moment ...
Nevertheless I could implement that quite easily for the next release, but only with the restrictions mentioned above.

Interesting, we only add/remove handicap to racers who complete 80% of race distance anyways, so if the handicap settings can be available in the results that would work really well for us. If you do get time to implement it we would definitely use it, if you don't have time thats ok I understand.

I have attached the en.ini I have made a change or to changed "run" to "round" we have Season --> Round --> Race.

Still noticing extra functions you have also done like the avg fuel consumption and showing engine damage in the graphs, have had postive comments from our regulars. Glad I made the switch to mpRes doing stats on Friday nite was just to easy.
Attached files
en.ini.txt - 9.7 KB - 532 views
Thanks!

I'll have a look into the handicap stuff and then implement it alongside the changed en.ini (and one or two minor bugs I found) ...
new version online (see first post)

For handicaps to be shown on "old" races please parse again using force_load option (or delete .mprdata from saves directory)
Quote from avetere :new version online (see first post)

For handicaps to be shown on "old" races please parse again using force_load option (or delete .mprdata from saves directory)

Wow, that was very quick!! Inital test showing its working as requested I owe you a beer or 2!! Thanks
Hi, I have noticed that the tracks .png does not display? I'm wondering if the file location is correct in the menus.tpl.php file (line ~90) "/image/tracks" should it not be "/image/rendered/track/" ?

Also getting quite a few errors in the log now I have noticed today.

PHP Warning: Cannot modify header information - headers already sent by (output started at /public_html/mpres/includes/functions.php:587) in /public_html/mpres/tpl/header.tpl.php on line 13
PHP Warning: arsort() expects parameter 1 to be array, null given in /public_html/mpres/includes/functions.php on line 587
PHP Warning: array_keys() expects parameter 1 to be array, null given in /public_html/mpres/includes/functions.php on line 588
PHP Warning: array_intersect() [<a href='function.array-intersect'>function.array-intersect</a>]: Argument #1 is not an array in /public_html/mpres/includes/functions.php on line 590
PHP Warning: array_shift() expects parameter 1 to be array, null given in /public_html/mpres/includes/functions.php on line 590

It is all working fine, just thought I'd pass it on
No, the original notation is ok but should actuallz read images/tracks ...
I also tried it on your site and it worked well for both svg and png tracks

Actually, if you change the path to the one you stated above, you will just be able to show track images that are already present. This is just the storage path. The original path ultimately leads you to the corresponding trackimage_xxx.php that looks for an image in the storage path and if it is not present, then renders it on the fly (and afterwards stores it).

As I said, I tried and it wirked well ... but your server took a bit of time for the rendering ... maybe you were just to unpatient?!

As for the errors, I think, I know the reason ... I'll send you a hotfix by pm. please try it out and if that works, I'll correct that
Quote from avetere :No, the original notation is ok but should actuallz read images/tracks ...
I also tried it on your site and it worked well for both svg and png tracks

Actually, if you change the path to the one you stated above, you will just be able to show track images that are already present. This is just the storage path. The original path ultimately leads you to the corresponding trackimage_xxx.php that looks for an image in the storage path and if it is not present, then renders it on the fly (and afterwards stores it).

As I said, I tried and it wirked well ... but your server took a bit of time for the rendering ... maybe you were just to unpatient?!

As for the errors, I think, I know the reason ... I'll send you a hotfix by pm. please try it out and if that works, I'll correct that

I only have this problem when I'm at work and it attempted to display the png... it is using IE8.. that is the only time I see the track gfx not appear.
The page had finished loading so I was being patient enough...i think. Anyways I appreciate your help.. love your app.. Sorry if I seem to be showing otherwise!
Hm ... ok I was now able to reproduce the error I think ... seems like IE tries to load one of the images for an extended period of time. For me hitting Esc (abort loading) helped and the png-image was displayed ... I'll have a look into it ...

And please don't worry! I'm happy with any error that is finally found ... this way i can fix them
update 2.02
Hey folks!

I've just uploaded a new version with a few minor bugfixes.
Also now a change of tyre type is displayed on the pitstop pane.
Piticons have been changed in a way that any tyre that has been changed (but remained the same type) is shown on blue (as before), when the type was changed it is shown in green.
The details for tyre types (including the changes) are shown in a tooltip when hovering over the icon.
There is one known bug though: I can at the moment not differentiate between "road normal" and "hybrid" as the initial tyres (when leaving the pits or at race start). Whenever a car comes to track with one of these, I will assume "road normal" as default. If this was really "hybrid", then there will be a false "type change" upon a pitstop.
Quote from avetere :Hey folks!

I've just uploaded a new version with a few minor bugfixes.
Also now a change of tyre type is displayed on the pitstop pane.
Piticons have been changed in a way that any tyre that has been changed (but remained the same type) is shown on blue (as before), when the type was changed it is shown in green.
The details for tyre types (including the changes) are shown in a tooltip when hovering over the icon.
There is one known bug though: I can at the moment not differentiate between "road normal" and "hybrid" as the initial tyres (when leaving the pits or at race start). Whenever a car comes to track with one of these, I will assume "road normal" as default. If this was really "hybrid", then there will be a false "type change" upon a pitstop.

Thanks Avetere, I'll be sure to take a look
Good morning fellow racers!

I've just uploaded a new version of the script, that now can handle the new lfs-version 0.6H (including the test patches leading to it, most notably G14/17 ...).
We now have support for the new Westhill and the increased number of maximum racers.

You find the whole script attached to the first post ...

But: The new /setlap function is at the moment not implemented, that needs to come in the next version. Actually the function is at the moment fully ignored.

Nevertheless: Have fun and stay tuned!
Good morning!

In the first post you'll now find a small hotfix for compatibility with newer releases of php (>5.5.0) ... That is probably most interesting to people, who want to set up the script on a local server using xammp ...
If you are running the script on php < 5.5.0 (which will probably be the case for most webservers) there is no actual need to implement the hotfix as there are no other new features for the moment ...
Hello, I have downloaded and installed the script, according to the instructions in the readme file. The webpage is available, but no data is generated, while I think I have set the replay files in the correct place and with the correct name.
Any help would be appreciated.
Could you send me (PM):
- a link
- a copy of the event_definitions.txt
- the naming/path of one of the replays
?
Requested file
Quote from avetere :Could you send me (PM):
- a link
- a copy of the event_definitions.txt
- the naming/path of one of the replays
?

Here's the requested file.
Attached files
event_definitions.txt - 4.5 KB - 483 views
Well, that's a step in the right direction.
Now I see a huge new error, which I suspect has something to do with rights on the filesystem.
I have no experience in dealing with IIS, so I need to find out, how to give the directories you mentioned in the readme, the correct rights.
I see ... so I guess IIS is probably the problem here as it doesn't understand the url rewriting (mod_rewrite) provided in the .htaccess file. This is basically designed to be used on an apache2 webserver, not IIS.
Unfortunately I'm not familiar with IIS either, so I would need to look that up and see what we can do here.

mpRes - race statistics web script
(59 posts, started )
FGED GREDG RDFGDR GSFDG