Ejemplo n.º 1
0
 public static void LoadVehicles()
 {
     foreach (var vehicle in ContextFactory.Instance.Vehicle.Where(x => x.Respawnable).ToList())
     {
         var vehicleController = new VehicleController(vehicle, API.shared.createVehicle((VehicleHash)vehicle.Model, new Vector3(vehicle.PosX, vehicle.PosY, vehicle.PosZ), new Vector3(0.0f, 0.0f, vehicle.Rot), vehicle.Color1, vehicle.Color2));
         if (vehicle.Group != null) // -1 is reserved for non-group job vehicles.
         {
             vehicleController.Group = EntityManager.GetGroup(vehicle.Group.Id);
         }
         if (vehicleController.VehicleData.Model == RentModels.ScooterModel)
         {
             vehicleController.Vehicle.delete();
         }
     }
     API.shared.consoleOutput("[GM] Загружено транспорта: " + ContextFactory.Instance.Vehicle.Count() + " ед.");
 }
Ejemplo n.º 2
0
        private void RespawnStaticGroupVehicle(int groupId)
        {
            var allStaticVehicles = ContextFactory.Instance.Vehicle.Where(x => x.GroupId == groupId).ToList();

            foreach (var vehicle in allStaticVehicles)
            {
                var vehicleController = EntityManager.GetVehicle(vehicle);
                var vehiclePostition  = new Vector3(vehicle.PosX, vehicle.PosY, vehicle.PosZ);

                if (vehicleController.Vehicle.occupants.Length == 0 &&
                    vehicleController.Vehicle.position != vehiclePostition)
                {
                    vehicleController.Vehicle.delete();

                    vehicle.Fuel = FuelByType.GetFuel(vehicle.Model);
                    var newVehicle = new VehicleController(vehicle,
                                                           API.shared.createVehicle((VehicleHash)vehicle.Model,
                                                                                    new Vector3(vehicle.PosX, vehicle.PosY, vehicle.PosZ),
                                                                                    new Vector3(0.0f, 0.0f, vehicle.Rot), vehicle.Color1, vehicle.Color2));
                }
            }
            ContextFactory.Instance.SaveChanges();
        }
Ejemplo n.º 3
0
        public static void RespawnWorkVehicle(Data.Vehicle vehicle, int vehicleModel, int vehicleCol1, int vehicleCol2)
        {
            var vehiclePosX = vehicle.PosX;
            var vehiclePosY = vehicle.PosY;
            var vehiclePosZ = vehicle.PosZ;
            var vehicleRotZ = vehicle.Rot;

            var vehicleController = EntityManager.GetVehicle(vehicle);

            vehicleController.Vehicle.delete();

            VehicleController newVehicle = new VehicleController(vehicle,
                                                                 API.shared.createVehicle((VehicleHash)vehicle.Model,
                                                                                          new Vector3(vehiclePosX, vehiclePosY, vehiclePosZ),
                                                                                          new Vector3(0.0f, 0.0f, vehicleRotZ), vehicleCol1, vehicleCol2));

            if (vehicle.Model == RentModels.TaxiModel)
            {
                vehicle.Character = null;
                vehicle.RentTime  = 0;
            }
            ContextFactory.Instance.SaveChanges();
        }