Esempio n. 1
0
        public static void LoadVehicleFromVehicleData(VehicleData vehicleData)
        {
            Model   model   = new Model(vehicleData.Hash);
            Vehicle vehicle = Extensions.SpawnVehicle(model, vehicleData.Position, vehicleData.Heading);

            if (vehicle != null)
            {
                vehicle.Rotation       = vehicleData.Rotation;
                vehicle.PrimaryColor   = vehicleData.PrimaryColor;
                vehicle.SecondaryColor = vehicleData.SecondaryColor;
                vehicle.Health         = vehicleData.Health;
                vehicle.EngineHealth   = vehicleData.EngineHealth;
            }
            Character.playerVehicle = vehicle;
        }
Esempio n. 2
0
        public void VehicleSpawn(Vector3 position, float heading)
        {
            int maxVehicles = Population.maxVehicles;

            if (IsCityZone(Game.Player.Character.Position))
            {
                maxVehicles = Population.maxVehicles * 2;
            }
            if (((this.vehicleCount < maxVehicles) && ((position != Vector3.Zero) && (Extensions.DistanceBetweenV3(position, this.startingLoc) >= minSpawnDistance))) && (Extensions.DistanceBetweenV3(position, Game.Player.Character.Position) >= minSpawnDistance))
            {
                Vehicle vehicle = Extensions.SpawnVehicle(GetRandomVehicleModel(), position, heading);
                vehicle.EngineHealth = (RandoMath.CachedRandom.Next(0, 100) > 10) ? 0f : 1000f;
                vehicle.DirtLevel    = 14f;
                VehicleDoor[] doors = vehicle.GetDoors();
                int           num3  = 0;
                while (true)
                {
                    if (num3 >= 5)
                    {
                        int item = 0;
                        while (true)
                        {
                            if (item >= 3)
                            {
                                break;
                            }
                            List <int>      theList   = new List <int>();
                            InputArgument[] arguments = new InputArgument[] { vehicle.Handle, item };
                            if (Function.Call <bool>(Hash._0x46E571A0E20D01F1, arguments))
                            {
                                theList.Add(item);
                            }
                            if (theList.Count > 0)
                            {
                                int             randomElementFromList = RandoMath.GetRandomElementFromList <int>(theList);
                                InputArgument[] argumentArray2        = new InputArgument[] { vehicle.Handle, randomElementFromList };
                                Function.Call(Hash._0x9E5B5E4D2CCD2259, argumentArray2);
                            }
                            item++;
                        }
                        break;
                    }
                    VehicleDoor randomElementFromArray = RandoMath.GetRandomElementFromArray <VehicleDoor>(doors);
                    vehicle.OpenDoor(randomElementFromArray, false, true);
                    num3++;
                }
            }
        }