Thats a pretty interesting problem. I would love to hear some theory on this if anyone else has done this before. I'm pretty sure there is no direct InSim function that will give you this detail and outside of getting this information from MCI / NLP packets you'd have to rely on the SPX & LAP packets so you have two problems.
What happens in the case that more then two cars pass more then one car in a single update? Say a grid of 32 cars invert between updates ... how does one handle this situation? Once you can answer that, you can answer start programming.
Anyone have any theory, I'd love to hear it.
A race order is like so.
Car1
Car2
Car3
Car4
Car5
Car6
Car7
Car8
Car9
Car10
Car11
Car12
Car13
Car14
Car15
Car16
Car17
Car18
Car19
Car20
Car21
Car22
Car23
Car24
Car25
Car26
Car27
Car28
Car29
Car30
Car31
Car32
On the next update everyone has change positions.
Car32
Car31
Car30
Car29
Car28
Car27
Car26
Car25
Car24
Car23
Car22
Car21
Car20
Car19
Car18
Car17
Car16
Car15
Car14
Car13
Car12
Car11
Car10
Car9
Car8
Car7
Car6
Car5
Car4
Car3
Car2
Car1
I think from this point, you would have to look at the problem on a per positions basis.
Car 32 just over took the entire field, and is now in 1st.
Car 31 just over took 29 cars, and is now in 2nd.
Car 30 just over took 27 cars, and is now in 3rd.
Car 29 just over took 25 cars, and is now in 4th.
Car 28 just over took 23 cars, and is now in 5th.
Car 27 just over took 21 cars, and is now in 6th.
Car 26 just over took 19 cars, and is now in 7th.
Car 25 just over took 17 cars, and is now in 8th.
Car 24 just over took 15 cars, and is now in 9th.
Car 23 just over took 13 cars, and is now in 10th.
Car 22 just over took 11 cars, and is now in 11th.
Car 21 just over took 9 cars, and is now in 12th.
Car 20 just over took 7 cars, and is now in 13th.
Car 19 just over took 5 cars, and is now in 14th.
Car 18 just over took 3 cars, and is now in 15th.
Car 17 just over took 1 car, and is now in 16th.
Car 16 just lost 1 place, and is now in 17th.
Car 15 just lost 3 places, and is now in 18th.
Car 14 just lost 5 places, and is now in 19th.
Car 13 just lost 7 places, and is now in 20th.
Car 12 just lost 9 places, and is now in 21st.
Car 11 just lost 11 places, and is now in 22nd.
Car 10 just lost 13 places, and is now in 23rd.
Car 9 just lost 15 places, and is now in 24th.
Car 8 just lost 17 places, and is now in 25th.
Car 7 just lost 19 places, and is now in 26th.
Car 6 just lost 21 places, and is now in 27th.
Car 5 just lost 23 places, and is now in 28th.
Car 4 just lost 25 places, and is now in 29th.
Car 3 just lost 27 places, and is now in 30th.
Car 2 just lost 29 places, and is now in 31st.
Car 1 just lost 31 places, and is now in last.
<?php
$gridSize = $this->getGridSize(); # Now a real function ... right now.
$lPositions = $this->getLastPositions(); # Also, not a real function.
$cPositions = $this->getCurrentPositions(); # Just an example for the peusdo-code.
for ($Pos = 1; $Pos <= $gridSize; ++$Pos)
{
if ($lPositions[$Pos] == $cPositions[$Pos])
continue; # There has been no change for this position, skip.
# If we get to this part, there has been a change.
echo $this->getPlayerByPLID($cPositions[$Pos])->PName; # Prints the Player Name of the Car.
$positionDelta = $Pos - $this->getPlayerByPLID($cPositions[$Pos])->Pos;
if ($positionDelta == $gridSize - 1)
echo 'just over took the entire field,';
else if ($positionDelta > 0)
echo "just over took $positionDelta car' . ($positionDelta > 1) ? 's,' : ',';
else if ($positionDelta < 0)
echo "just lost $positionDelta place' . ($positionDelta < 1) ? 's,' : ',';
echo "and is now in $Pos" . PHP_EOL;
}
?>
The above output should be pretty easy to do, and it should also be pretty fast. We just have to funnel this information some how into our plugin, we need to build ourselves a race position tracking mechanism, first before we can go any further.