private void CarDataIn(InSim insim, IS_MCI mci) { //Console.WriteLine("IS_MSI pack received"); for (int i = 0; i < mci.NumC; i++) { if (allCars.GetCarID(mci.Info[i].PLID) != -1) { // Milimeters precision allCars.UpdateCarRawCoordinates(mci.Info[i].PLID, mci.Info[i].X / 65.535, mci.Info[i].Y / 65.535, mci.Info[i].Z / 65.535); // Meters precision allCars.UpdateCarCoordinates(mci.Info[i].PLID, mci.Info[i].X / 65535, mci.Info[i].Y / 65535, mci.Info[i].Z / 65535); allCars.UpdateCarSpeed(mci.Info[i].PLID, mci.Info[i].Speed); allCars.UpdateCarHeading(mci.Info[i].PLID, mci.Info[i].Heading / 182); // Somehow makes it 360 degrees. Will come back later allCars.CarCalculations(mci.Info[i].PLID); } else { // This will spam a bit while starting program, but necessary later on; Console.WriteLine("Requesting info"); _inSim.Send( new IS_TINY { SubT = TinyType.TINY_NPL, ReqI = 1 } ); } } }
public static void MCI(InSim insim, IS_MCI MCI) { try { foreach (CompCar car in MCI.Info) { Players NPL; if (Players._players.TryGetValue(car.PLID, out NPL)) { foreach (Connections Conn in Connections._connections.Values) { if (Conn.PLID == car.PLID) { Conn.X = (car.X / 65536); Conn.Y = (car.Y / 65536); Conn.Z = (car.Z / 65536); Conn.Heading = ((car.Heading / 256) + 128); Conn.Angle = (car.AngVel / 16384); Conn.Speed = car.Speed; } } } } } catch (InSimException IEx) { Logger.Error(IEx.Message, Logger.Types.NCN); } }
private void ButtonGorunumu(InSim insim, IS_MCI mci) { try { IS_NCN conn = new IS_NCN(); string[] buttons1 = { string.Format(textBox1.Text), string.Format(textBox2.Text), string.Format(textBox3.Text), string.Format(textBox4.Text), }; for (byte i = 0, id = 1, top = (byte)numericUpDown1.Value; i < buttons1.Length; i++, id++, top += (byte)numericUpDown5.Value) { insim.Send(new IS_BTN { ReqI = 255, UCID = conn.UCID, ClickID = id, BStyle = ButtonStyles.ISB_DARK | ButtonStyles.ISB_LEFT, T = top, L = (byte)numericUpDown2.Value, W = (byte)numericUpDown3.Value, H = (byte)numericUpDown4.Value, Text = buttons1[i], }); } string[] buttons2 = { string.Format(textBox5.Text), string.Format(textBox6.Text), string.Format(textBox7.Text), string.Format(textBox8.Text), }; for (byte i = 0, id = 5, top = (byte)numericUpDown6.Value; i < buttons2.Length; i++, id++, top += (byte)numericUpDown10.Value) { insim.Send(new IS_BTN { ReqI = 255, UCID = conn.UCID, ClickID = id, BStyle = ButtonStyles.ISB_DARK | ButtonStyles.ISB_LEFT, T = top, L = (byte)numericUpDown7.Value, W = (byte)numericUpDown8.Value, H = (byte)numericUpDown9.Value, Text = buttons2[i], }); } } catch { } }
// MCI - Multi Car Info private void MultiCarInfo(InSim insim, IS_MCI mci) { try { { foreach (CompCar car in mci.Info) { Connections conn = GetConnection(car.PLID); int Sped = Convert.ToInt32(MathHelper.SpeedToKph(car.Speed)); decimal SpeedMS = (decimal)(((car.Speed / 32768f) * 100f) / 2); decimal Speed = (decimal)((car.Speed * (100f / 32768f)) * 3.6f); int kmh = car.Speed / 91; int mph = car.Speed / 146; var X = car.X; var Y = car.Y; var Z = car.Z; var angle = car.AngVel / 30; string anglenew = ""; foreach (var cne in _players.Values) { if (cne.UCID == conn.UCID) { cne.kmh = kmh; cne.mph = mph; _connections[cne.UCID].TotalDistance += Convert.ToInt32(SpeedMS); } } anglenew = angle.ToString().Replace("-", ""); { } } } } catch (Exception e) { } }
// MCI - Multi Car Info private void MultiCarInfo(InSim insim, IS_MCI mci) { try { { foreach (CompCar car in mci.Info) { Connections conn = GetConnection(car.PLID); if (conn.UCID != 0) { int Sped = Convert.ToInt32(MathHelper.SpeedToKph(car.Speed)); decimal SpeedMS = (int)(((car.Speed / 32768f) * 100f) / 2); decimal Speed = (int)((car.Speed * (100f / 32768f)) * 3.6f); int kmh = car.Speed / 91; int mph = car.Speed / 146; var X = car.X / 65536; var Y = car.Y / 65536; var Z = car.Z / 65536; var angle = car.AngVel / 30; string anglenew = ""; // int Angle = AbsoluteAngleDifference(car.Direction, car.Heading); _players[car.PLID].kmh = kmh; _players[car.PLID].mph = mph; conn.TotalDistance += Convert.ToInt32(SpeedMS); // anglenew = angle.ToString().Replace("-", ""); UpdateGui(conn.UCID, true); } } } } catch (Exception e) { LogTextToFile("error", "MCI - Exception: " + e, false); } }
private void MCI_CarUpdates(InSim insim, IS_MCI MCI) { try { foreach (CompCar car in MCI.Info) { Connections conn = GetConnection(car.PLID); { int Sped = Convert.ToInt32(MathHelper.SpeedToKph(car.Speed)); decimal SpeedMS = (int)(((car.Speed / 32768f) * 100f) / 2); decimal Speed = (int)((car.Speed * (100f / 32768f)) * 3.6f); int kmh = car.Speed / 91; int mph = car.Speed / 146; var X = car.X; var Y = car.Y; var Z = car.Z; var angle = car.AngVel / 30; string anglenew = ""; int Angle = AbsoluteAngleDifference(car.Direction, car.Heading); _players[car.PLID].kmh = kmh; _players[car.PLID].mph = mph; conn.TotalDistance += Convert.ToInt32(SpeedMS); conn.BonusDistance += Convert.ToInt32(SpeedMS); if (AskedPosition == true && AskedPosUCID == conn.UCID) { // SendRCMToUsername(CurrentConnection.UName, "Your Position is: " + (car.X / 65535) + ", " + (car.Y / 65535), 5000);//keep the message for 5seconds(5000ms) insim.Send(AskedPosUCID, "^3X: ^7" + (car.X / 65535) + " ^3Y: ^7" + (car.Y / 65535)); insim.Send(AskedPosUCID, "^3Speed: ^1" + Speed + " ^3Angle: ^1" + Angle); AskedPosition = false; AskedPosUCID = 255; } // if (GetDistXY(car.X, car.Y, -80, 1002) < 100) /* * if (conn.OnTrack == true) * { * conn.InShopDist = (GetDistXY(car.X, car.Y, -80, 1002)); * if (conn.InShopDist < 10) * v * { * insim.Send(conn.UCID, "^8Welcome to the ^2" + "Mechanics"); * } * }*/ string text = String.Format( "^1X: {0:F2} ^2Y: {1:F2} ^3Z: {2:F2}", car.X / 65536, car.Y / 65536, car.Z / 65536); if (conn.UName == "kristofferandersen") { // mci insim.Send(new IS_BTN { Text = "^7" + text, UCID = conn.UCID, ReqI = 17, ClickID = 17, BStyle = ButtonStyles.ISB_DARK, H = 4, W = 30, T = 0, L = 139, }); } #region ' WE2X ' switch (TrackName) { case "WE2X": { // if (((car.X / 65536) >= -143) && (car.X / 65536 <= -967) && (car.Y / 65536 >= -151) && (car.Y / 65536 <= 966)) // if (MathHelper.LengthToMeters(MathHelper.Distance(car.X, car.Y, -147, 971)) < 5) // if (((car.X / 65536) >= -258) && (car.X / 65536 <= -3) && (car.Y / 65536 >= 873) && (car.Y / 65536 <= 834)) /*conn.InBankDist = GetDistXY(car.X, car.Y, -148, 971); * if (conn.InBankDist < 2) * { * insim.Send(255, "you're there!"); * }*/ break; } } #endregion UpdateGui(conn.UCID, false, true); anglenew = angle.ToString().Replace("-", ""); } } } catch (Exception e) { LogTextToFile("error", "[+++] BTC - Exception: " + e, false); } }