In my cruise I have a problem when there is more about 10 connections cop system starts to bug. For example cant find anyone in some distance. In my cruise its 250. What could be the reason for that and how to fix it?
<?php
Dictionary<byte, Point3D> carsPosition;
...
for(int i = 0; i < MCI.CountC; i++) {
byte _plid = MCI.CompCar[i].PLID;
int x = MCI.CompCar[i].X;
int y = MCI.CompCar[i].Y;
int z = MCI.CompCar[i].Z;
carsPosition[_plid] = new Point3D(x, y, z);
}
?>
Error 20 'LFS_External.Packets.IS_MCI' does not contain a definition for 'CountC' and no extension method 'CountC' accepting a first argument of type 'LFS_External.Packets.IS_MCI' could be found (are you missing a using directive or an assembly reference?)
<?php
// Detailed car information packet (max 8 per packet)
private void MCI_CarInformation(Packets.IS_MCI MCI)
{
try
{
//CompCar is the CompCar packet structure I added to clsPlayer
int idx = 0;
for (int i = 0; i < MCI.NumC; i++)
{
// Look at Comment 1 first!
// --------------------------------------------------------
// Comment 2:
// You GetConnectionIndex (GetConnIdx).
// While you really need to GetPlayerIndex (GetPlyIdx).
// On top of that, you give GetConnIdx a PLID (Player ID).
// If you really needed to use GetConnIdx, you are supposed to give it an UCID (Unique Connection ID) too.
// Final conclusion: The line below is terribly wrong.
// --------------------------------------------------------
// Solution
// Replace the line below with the following:
// idx = GetPlyIdx(MCI.Info[i].PLID);
// --------------------------------------------------------
idx = GetConnIdx(MCI.Info[i].PLID);
// --------------------------------------------------------
// Comment 1:
// So, you want a players index.
// In Players[idx] the idx variable should be an index of the Players list (obviously).
// But instead, look at what happens in Comment 2.
// --------------------------------------------------------
Players[idx].CompCar.AngVel = MCI.Info[i].AngVel;
Players[idx].CompCar.Direction = MCI.Info[i].Direction;
Players[idx].CompCar.Heading = MCI.Info[i].Heading;
Players[idx].CompCar.Info = MCI.Info[i].Info;
Players[idx].CompCar.Lap = MCI.Info[i].Lap;
Players[idx].CompCar.Node = MCI.Info[i].Node;
Players[idx].CompCar.PLID = MCI.Info[i].PLID;
Players[idx].CompCar.Position = MCI.Info[i].Position;
Players[idx].CompCar.Speed = MCI.Info[i].Speed;
Players[idx].CompCar.X = MCI.Info[i].X;
Players[idx].CompCar.Y = MCI.Info[i].Y;
Players[idx].CompCar.Z = MCI.Info[i].Z;
decimal SpeedMS = (decimal) (((MCI.Info[i].Speed / 32768f) * 100f) / 2);
decimal Speed = (decimal)((MCI.Info[i].Speed * (100f / 32768f)) * 3.6f);
decimal ConvSpeed = (decimal)(Speed * 25 / 1000);
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].TotalDistance += Convert.ToInt32(SpeedMS);
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].DistanceSincePit += Convert.ToInt32(SpeedMS);
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].LicenseDistance += Convert.ToInt32(SpeedMS);
//Connections[idx].DistanceSincePit += Convert.ToInt32(SpeedMS1);
Connections[idx].TotalDistance += Convert.ToInt32(SpeedMS);
Players[GetPlyIdx(MCI.Info[i].PLID)].Payout += ConvSpeed;
}
for (int i = 0; i < MCI.NumC; i++) //We want everyone to update before checking them.
{
MCI_Update(MCI.Info[i].PLID);
}
}
}
?>