Пример #1
0
 public static void LoadVehicle(AccountController account, int id)
 {
     Data.Vehicle VM = ContextFactory.Instance.Vehicle.Where(x => x.Id == id).FirstOrDefault();
     if (VM != null)
     {
         VehicleController _vehicle = new VehicleController(VM, API.shared.createVehicle((VehicleHash)VM.Model, new Vector3(VM.PosX, VM.PosY, VM.PosZ), new Vector3(0.0f, 0.0f, VM.Rot), VM.Color1, VM.Color2));
         API.shared.sendNotificationToPlayer(account.Client, "You spawned your " + API.shared.getVehicleDisplayName((VehicleHash)VM.Model));
     }
 }
Пример #2
0
 public static void LoadVehicles()
 {
     foreach (var vehicle in ContextFactory.Instance.Vehicle.Where(x => x.Group != null).ToList())
     {
         VehicleController 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);
         }
     }
     API.shared.consoleOutput("[GM] Loaded vehicles: " + ContextFactory.Instance.Vehicle.Count());
 }
Пример #3
0
        public static void LoadVehicle(Client player, int id)
        {
            var vm = ContextFactory.Instance.Vehicle.FirstOrDefault(x => x.Id == id);

            if (vm == null)
            {
                return;
            }
            var vehicle = new VehicleController(vm, API.shared.createVehicle((VehicleHash)vm.Model, new Vector3(vm.PosX, vm.PosY, vm.PosZ), new Vector3(0.0f, 0.0f, vm.Rot), vm.Color1, vm.Color2));

            API.shared.sendNotificationToPlayer(player, "You spawned your " + API.shared.getVehicleDisplayName((VehicleHash)vm.Model));
        }
Пример #4
0
        private void RespawnStaticGroupVehicle(int groupId)
        {
            var allStaticVehicles = ContextFactory.Instance.Vehicle.Where(x => x.GroupId == groupId);

            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();
        }
Пример #5
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();
        }
Пример #6
0
        private void OnPlayerEnterVehicle(Client player, NetHandle vehicle)
        {
            AccountController account = player.getData("ACCOUNT");

            if (account == null)
            {
                return;
            }

            VehicleController _VehicleController = EntityManager.GetVehicle(vehicle);

            if (_VehicleController != null)
            {
                if (_VehicleController.VehicleData.Character == account.CharacterController.Character)
                {
                    API.sendNotificationToPlayer(player, "You have entered your car.");
                }
                else if (account.CharacterController.IsInGroup(_VehicleController.Group.Group.Id))
                {
                    API.sendNotificationToPlayer(player, "You have entered a vehicle of your organization.");
                }
            }
            API.triggerClientEvent(player, "show_vehicle_hud");
        }
Пример #7
0
        public void car(Client player, string Choice)
        {
            AccountController account = player.getData("ACCOUNT");

            if (account == null)
            {
                return;
            }

            if (Choice == "engine")
            {
                VehicleController VehicleController = EntityManager.GetVehicle(player.vehicle);
                if (VehicleController == null || player.vehicleSeat != -1)
                {
                    API.sendChatMessageToPlayer(player, "~r~ERROR: ~w~You are not in a vehicle or on the driver's seat.");
                    return;
                }

                if (!VehicleController.CheckAccess(account))
                {
                    API.sendNotificationToPlayer(player, "You cannot operate this vehicle.");
                    return;
                }
                else
                {
                    if (API.getVehicleEngineStatus(VehicleController.Vehicle))
                    {
                        VehicleController.Vehicle.engineStatus = false;
                        ChatController.sendProxMessage(player, 15.0f, "~#C2A2DA~", account.CharacterController.FormatName + " turns the key in the ignition and the engine stops.");
                    }
                    else
                    {
                        VehicleController.Vehicle.engineStatus = true;
                        ChatController.sendProxMessage(player, 15.0f, "~#C2A2DA~", account.CharacterController.FormatName + " turns the key in the ignition and the engine starts.");
                    }
                }
            }
            else if (Choice == "park")
            {
                VehicleController VehicleController = EntityManager.GetVehicle(player.vehicle);
                Data.Vehicle      VM = VehicleController.VehicleData;
                if (VM == null || player.vehicleSeat != -1)
                {
                    API.sendNotificationToPlayer(player, "~r~ERROR: ~w~You are not in a vehicle or on the driver's seat.");
                    return;
                }

                if (VehicleController.CheckAccess(account, account.CharacterController))
                {
                    VehicleController.ParkVehicle(player);
                }
                else
                {
                    API.sendNotificationToPlayer(player, "~r~ERROR: ~w~You cannot park this car.");
                }
            }

            else if (Choice == "hood" || Choice == "trunk")
            {
                VehicleController VehicleController = null;
                if (player.isInVehicle)
                {
                    VehicleController = EntityManager.GetVehicle(player.vehicle);
                }
                else
                {
                    VehicleController = EntityManager.GetVehicleControllers().Find(x => x.Vehicle.position.DistanceTo(player.position) < 3.0f);
                }

                if (VehicleController == null)
                {
                    API.sendNotificationToPlayer(player, "You are not near a vehicle.");
                    return;
                }

                if (VehicleController.CheckAccess(account))
                {
                    if (Choice == "hood")
                    {
                        VehicleController.TriggerDoor(VehicleController.Vehicle, 4);
                    }
                    else
                    {
                        VehicleController.TriggerDoor(VehicleController.Vehicle, 5);
                    }
                }
                else
                {
                    API.sendNotificationToPlayer(player, "~r~ERROR: ~w~You cannot park this car.");
                }
            }
        }