Let me show you the code 1st:
With this code only the user with the lowest Connection ID gets hud(insim look/stats shower/w.e u want to call it). Am I missing something there?
If I make it throw an exception it throws out of bounds for "foreach (clsConnection Conn in Connections)" line. I have been trying to fix this for 2 weeks now and no progress.
private void updateHUD(object sender, System.Timers.ElapsedEventArgs e)
{
foreach (clsConnection Conn in Connections)
{
//InSim.Send_MST_Message("!pm broken " + Conn.Username);
int ID = 0;
while (ID <= 25)
{
ID += 1;
string FullHUD = Conn.FullHUD.Split('>')[ID];
FullHUD = FullHUD.Replace('*', ' ');
string[] HUD = FullHUD.ToString().Split(' ');
string Style = HUD[4];
string truefalse = "false";
int buttonCount = ID;
if (HUD[5] == "notalways")
{
truefalse = "false";
}
else
{
truefalse = "true";
}
if (HUD[6] == "BackGround")
{
InSim.Send_BTN_CreateButton("", Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
else if (HUD[6] == "TotalMoney")
{
if (Conn.Cash >= 0)
{
InSim.Send_BTN_CreateButton("^2" + MoneySign + "^8 " + Conn.Cash, Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
else if (Conn.Cash < 0)
{
InSim.Send_BTN_CreateButton("^2" + MoneySign + "^1 " + Conn.Cash, Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
}
else if (HUD[6] == "TodayMoney")
{
if (Conn.Cash - Conn.InitialCash >= 0)
{
InSim.Send_BTN_CreateButton("^7Earned today: ^2" + MoneySign + "^8" + (Conn.Cash - Conn.InitialCash), Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
else if (Conn.Cash - Conn.InitialCash < 0)
{
InSim.Send_BTN_CreateButton("^7Lost today: ^1" + MoneySign + ((Conn.Cash - Conn.InitialCash) - (Conn.Cash - Conn.InitialCash) * 2), Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
}
else if (HUD[6] == "BonusText")
{
InSim.Send_BTN_CreateButton("^7Bonus(" + Conn.Bonus + "%):", Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
else if (HUD[6] == "BonusBar")
{
string bonusStr1 = new string('|', Conn.Bonus / 1000);
string bonusStr2 = new string('|', 100 - Conn.Bonus / 1000);
string bonusStr = "^2" + bonusStr1 + "^0" + bonusStr2;
InSim.Send_BTN_CreateButton("" + bonusStr, Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
else if (HUD[6] == "HealthText")
{
InSim.Send_BTN_CreateButton("^7Health(" + (Conn.Energy / 1000) + "%):", Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
else if (HUD[6] == "HealthBar")
{
string healthStr1 = new string('|', Conn.Energy / 1000);
string healthStr2 = new string('|', 100 - Conn.Energy / 1000);
string healthStr = "^7" + healthStr1 + "^0" + healthStr2;
InSim.Send_BTN_CreateButton("" + healthStr, Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
else if (HUD[6] == "CarsString")
{
//string TempCars1 = "^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "UF1") + "UF1 ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "XFG") + "XFG ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "XRG") + "XRG ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "LX4") + "LX4 ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "LX6") + "LX6 ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "RB4") + "RB4 ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "FXO") + "FXO ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "XRT") + "XRT ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "RAC") + "RAC ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "VWS") + "VWS ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "FZ5") + "FZ5";
//string TempCars2 = "^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "UFR") + "UFR ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "XFR") + "XFR ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "FXR") + "FXR ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "XRR") + "XRR ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "FZR") + "FZR ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "MRT") + "MRT ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "FBM") + "FBM ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "FOX") + "FOX ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "FO8") + "FO8 ^" + Cars.ownsCar(Connections[GetConnIdx(UCID)].Cars, "BF1") + "BF1";
string CarsString = Cars.transformFromNumbers(Conn.Cars);
InSim.Send_BTN_CreateButton("" + CarsString, Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
else if (HUD[6] == "InSimVersion")
{
string InSimVersion = "Version: 1.2.4.2BETA";
InSim.Send_BTN_CreateButton("" + InSimVersion, Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
else if (HUD[6] == "CurrentLocation")
{
InSim.Send_BTN_CreateButton("" + Conn.Location, Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
else if (HUD[6] == "SpeedLimit")
{
InSim.Send_BTN_CreateButton("" + Conn.Speed + "km/h ^7/^8 " + Conn.SpeedLimit + "km/h", Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
else if (HUD[6] == "TotalDistance")
{
InSim.Send_BTN_CreateButton("" + (Conn.TotalDistance / 1000) + "km", Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
else if (HUD[6] == "TodayDistance")
{
InSim.Send_BTN_CreateButton("Today: " + (Conn.DistanceSincePit / 1000) + "km", Flags.ButtonStyles.ISB_C1 - 1 + Convert.ToByte(Style), Convert.ToByte(HUD[0]), Convert.ToByte(HUD[1]), Convert.ToByte(HUD[2]), Convert.ToByte(HUD[3]), Convert.ToByte(buttonCount), Conn.UniqueID, 2, Convert.ToBoolean(truefalse));
}
}
}
}
With this code only the user with the lowest Connection ID gets hud(insim look/stats shower/w.e u want to call it). Am I missing something there?
If I make it throw an exception it throws out of bounds for "foreach (clsConnection Conn in Connections)" line. I have been trying to fix this for 2 weeks now and no progress.