private void UpButton_Click(object sender, RoutedEventArgs e) { int selectedIndex = DefaultStationsGrid.SelectedIndex; if (selectedIndex > 0 && selectedIndex < DefaultStations.Rows.Count) { DataRow selectedRow = DefaultStations.Rows[selectedIndex]; DataRow newRow = DefaultStations.NewRow(); newRow["name"] = selectedRow["name"]; newRow["distance"] = selectedRow["distance"]; DefaultStations.Rows.RemoveAt(selectedIndex); DefaultStations.Rows.InsertAt(newRow, selectedIndex - 1); DefaultStationsGrid.SelectedIndex = selectedIndex - 1; } }
private void OnTickSelect(object Sender, EventArgs Args) { // Get if the player is leaving the vehicle bool IsExitingVehicle = Function.Call <bool>(Hash.GET_IS_TASK_ACTIVE, Game.Player.Character, 2); bool IsEnteringVehicle = Function.Call <bool>(Hash.GET_IS_TASK_ACTIVE, Game.Player.Character, 160); Vehicle CurrentVehicle = Game.Player.Character.CurrentVehicle; // If there is a vehicle but it does not has a radio stored if (CurrentVehicle != null && !CurrentRadio.ContainsKey(CurrentVehicle)) { // See if the User has configured a radio by trying to get the values Default Custom = DefaultStations.Find(X => X.Hash == CurrentVehicle.Model.GetHashCode()); // If there is an entry on the custom radios and is more than one if (Custom != null && Custom.Radios.Count > 0) { // Try to get a custom radio int RandomRadio = Randomizer.Next(Custom.Radios.Count); Radio CustomRadio = Radios.Find(X => X.UUID == Custom.Radios[RandomRadio]); // If the radio is not valid, play a random radio if (CustomRadio == null) { CurrentRadio[CurrentVehicle] = GetRandomRadio(); } // Otherwise, use the one that we have else { CurrentRadio[CurrentVehicle] = CustomRadio; } } // If there is no custom radio, information, use a random one else { CurrentRadio[CurrentVehicle] = GetRandomRadio(); } // Finally, play the radio PlayRadio(CurrentRadio[CurrentVehicle]); } // If there is a radio stored but the current radio does not match if (CurrentVehicle != null && CurrentRadio[CurrentVehicle] != Selected) { // Set the current radio as selected CurrentRadio[CurrentVehicle] = Selected; } // If the player is not on a vehicle and the selected radio is not OFF, or is leaving the vehicle, or the game is paused else if ((CurrentVehicle == null && Selected != Radios[0]) || IsExitingVehicle || Game.IsPaused) { // Set the radio as off but don't store it PlayRadio(Radios[0], false); // And mark the radio as paused Paused = true; } // If the player is on a vehicle and the radio is paused and is the player is not exiting the vehicle else if (CurrentVehicle != null && Paused && !IsExitingVehicle) { // If the player is on a vehicle PlayRadio(Selected); Paused = false; } }