Exemplo n.º 1
0
        /// <summary>
        /// Updates the <see cref="CurrentVehicle"/> and the <see cref="CurrentPreset"/>
        /// </summary>
        /// <returns></returns>
        private async Task GetCurrentVehicle()
        {
            PlayerPed = PlayerPedId();

            if (IsPedInAnyVehicle(PlayerPed, false))
            {
                int vehicle = GetVehiclePedIsIn(PlayerPed, false);

                if (VehiclesPermissions.IsVehicleAllowed(vehicle) && GetPedInVehicleSeat(vehicle, -1) == PlayerPed && !IsEntityDead(vehicle))
                {
                    // Update current vehicle and get its preset
                    if (vehicle != CurrentVehicle)
                    {
                        CurrentVehicle = vehicle;
                        CurrentPreset  = CreateHandlingPreset(CurrentVehicle);
                        PresetChanged?.Invoke(this, EventArgs.Empty);
                    }
                }
                else
                {
                    // If current vehicle isn't a car or player isn't driving current vehicle or vehicle is dead
                    CurrentVehicle = -1;
                    CurrentPreset  = null;
                }
            }
            else
            {
                // If player isn't in any vehicle
                CurrentVehicle = -1;
                CurrentPreset  = null;
            }

            await Task.FromResult(0);
        }
Exemplo n.º 2
0
        private void ReadVehiclePermissions(string filename = "VehiclesPermissions.xml")
        {
            string strings = null;

            try
            {
                strings = LoadResourceFile(ResourceName, filename);
                VehiclesPermissions.ParseXml(strings);
                CitizenFX.Core.Debug.WriteLine($"{ScriptName}: Loaded {filename}, found {VehiclesPermissions.Classes.Count} class rules and {VehiclesPermissions.Vehicles.Count} vehicle rules");
            }
            catch (Exception e)
            {
                CitizenFX.Core.Debug.WriteLine(e.Message);
                CitizenFX.Core.Debug.WriteLine(e.StackTrace);
                CitizenFX.Core.Debug.WriteLine($"{ScriptName}: Error loading {filename}");
            }
        }