The online racing simulator
MPR - How to get laps done?
(8 posts, started )
MPR - How to get laps done for each racer?
Hello all,

Look this code:


<?php 
if(fread($rp6) == "LFSMPR")
    {
        
fread($rp14);
        
$r["ringe"] = hexdec(bin2hex(fread($rp1)));
        
$r["skill"] = hexdec(bin2hex(fread($rp1)));
        
$r["tuul"] = hexdec(bin2hex(fread($rp1)));
        
$r["wind"] = hexdec(bin2hex(fread($rp1)));
        
$r["version"] = trim(fread($rp8));

        
fread($rp8);
        
$area trim(fread($rp32));
        
$config hexdec(bin2hex(fread($rp1)));
        
$reversed hexdec(bin2hex(fread($rp1)));
        
        
$r["ilm"] = hexdec(bin2hex(fread($rp1)));
        
$r["rada"] = $areas[$area].$config.($reversed "r" "");

        
$finished hexdec(bin2hex(fread($rp1)));

        
fread($rp4);
     
        for(
$i 0$i $finished$i++)
        {
            
$o[$i]["soitja"] = trim(fread($rp24));
            
$o[$i]["plate"] = trim(fread($rp8));
            
$o[$i]["auto"] = trim(fread($rp32));
            
//$o[$i]["laps_c"] = hexdec(bin2hex(fread($rp, 1)));
            
fread($rp1);
            
$o[$i]["pits"] = hexdec(bin2hex (fread($rp1). $pits[$i]));
            
fread($rp1);
            
$o[$i]["maha"] = hexdec(bin2hex(fread($rp1)));
            
$o[$i]["lopp"] = msht2int(fread($rp4));
            
$o[$i]["parim"] = msht2int(fread($rp4));

               
fread($rp4);
        }
    }
?>

In which place of this code do I insert to obtain laps completed for each racer?

Sorry for my english...

Regards
Is this your code, or have you got it from somewhere. Because just glancing at it, it looks like you just need to uncomment the line \\$o[$i]["laps_c"] = hexdec(bin2hex(fread($rp, 1)));


Sorry,

I was not very clearly.

How to include a line in my code that it allows to show the numbers to me of laps completed of each players?

JS
Quote from colcob :Is this your code, or have you got it from somewhere. Because just glancing at it, it looks like you just need to uncomment the line \\$o[$i]["laps_c"] = hexdec(bin2hex(fread($rp, 1)));

This line was created by me Col, if uncommnet give error.

JS
Comparison..
A piece of PHP code:


<?php 
for($i 0$i $finished$i++)
        {
            
$o[$i]["player_name"] = trim(fread($rp24));
            
$o[$i]["plate"] = trim(fread($rp8));
            
$o[$i]["car"] = trim(fread($rp32));
            
//$o[$i]["laps_c"] = hexdec(bin2hex(fread($rp, 1)));
            
fread($rp1);
            
$o[$i]["pits"] = hexdec(bin2hex (fread($rp1). $pits[$i]));
            
fread($rp1);
            
$o[$i]["?????"] = hexdec(bin2hex(fread($rp1)));
            
$o[$i]["overall_time"] = msht2int(fread($rp4));
            
$o[$i]["best_lap"] = msht2int(fread($rp4));

               
fread($rp4);
        }
?>

A piece of MPR Header code:

[FONT=FIXED SYS]RESULT INFO : size 80 bytes per finished player

24 char 0 player name : text, ends 0, no colours
8 char 24 number plate : text, NOTE : NO ZERO AT END
4 char 32 short car name : text, ends 0
24 byte 36 0 : -
1 word 60 laps done : total laps completed
1 word 62 player flags : driver settings (see NOTES)
1 byte 64 confirm flags : penalties (see NOTES)
1 byte 65 number of stops : pit stops count
1 byte 66 0 : -
1 byte 67 0 : -
1 time 68 overall time : msht time
1 time 72 best lap time : msht time (first check point)
1 int 76 0 : -[/FONT]

this is a line:

1 word 60 laps done : total laps completed


JS
#6 - filur
Quote from jscorrea :A piece of PHP code:

Confusing, you're reading 24 bytes of player name, 8 bytes of number plate, 32 bytes of short car string which is only 4 bytes, then you do nothing about the 24 NUL bytes, the commented line attempts to read a 2-byte word as 1 byte, attempt to skip next 2-byte word by reading 1 byte, etc.

Or am i too tired?
Quote from filur :Confusing, you're reading 24 bytes of player name, 8 bytes of number plate, 32 bytes of short car string which is only 4 bytes, then you do nothing about the 24 NUL bytes, the commented line attempts to read a 2-byte word as 1 byte, attempt to skip next 2-byte word by reading 1 byte, etc.

Or am i too tired?

yes is very strange, but this works!!

This code is from priits (tourney system), the code of other MPR parser is almost identical.

The only thing what i need is "laps done for each racer"..im not understand...

JS
finaly, the right code....


<?php 
for($i 0$i $finished$i++)
        {
            
$o[$i]["soitja"] = trim(fread($rp24));
            
$o[$i]["plate"] = trim(fread($rp8));
            
$o[$i]["auto"] = trim(fread($rp4));
            
fread($rp24);
            
$o[$i]["laps_c"] = hexdec(bin2hex(fread($rp2)))/256;
            
fread($rp2);
            
fread($rp1);
            
$o[$i]["pits"] = hexdec(bin2hex (fread($rp1). $pits[$i]));
            
fread($rp1);
            
fread($rp1);
            
//$o[$i]["maha"] = hexdec(bin2hex(fread($rp, 1)));
            
$o[$i]["lopp"] = msht2int(fread($rp4));
            
$o[$i]["parim"] = msht2int(fread($rp4));

               
fread($rp4);
        } 
?>


MPR - How to get laps done?
(8 posts, started )
FGED GREDG RDFGDR GSFDG