Пример #1
0
        public static void RespawnFractionCar(Vehicle vehicle)
        {
            try
            {
                var    canmats  = vehicle.HasData("CANMATS");
                var    candrugs = vehicle.HasData("CANDRUGS");
                var    canmeds  = vehicle.HasData("CANMEDKITS");
                string number   = vehicle.NumberPlate;
                int    fraction = vehicle.GetData("FRACTION");

                NAPI.Entity.SetEntityPosition(vehicle, FractionVehicles[fraction][number].Item2);
                NAPI.Entity.SetEntityRotation(vehicle, FractionVehicles[fraction][number].Item3);
                VehicleManager.RepairCar(vehicle);
                NAPI.Data.SetEntityData(vehicle, "ACCESS", "FRACTION");
                NAPI.Data.SetEntityData(vehicle, "FRACTION", fraction);
                NAPI.Data.SetEntityData(vehicle, "MINRANK", FractionVehicles[fraction][number].Item4);
                if (canmats)
                {
                    NAPI.Data.SetEntityData(vehicle, "CANMATS", true);
                }
                if (candrugs)
                {
                    NAPI.Data.SetEntityData(vehicle, "CANDRUGS", true);
                }
                if (canmeds)
                {
                    NAPI.Data.SetEntityData(vehicle, "CANMEDKITS", true);
                }
                NAPI.Vehicle.SetVehicleNumberPlate(vehicle, number);
                Core.VehicleStreaming.SetEngineState(vehicle, false);
                VehicleManager.FracApplyCustomization(vehicle, fraction);
            }
            catch (Exception e) { Log.Write("RespawnFractionCar: " + e.Message, nLog.Type.Error); }
        }
Пример #2
0
        public static void SpawnFractionCars(int fraction)
        {
            foreach (var vehicle in FractionVehicles[fraction])
            {
                var model    = vehicle.Value.Item1;
                var canmats  = (model == VehicleHash.Barracks || model == VehicleHash.Youga || model == VehicleHash.Burrito3); // "CANMATS"
                var candrugs = (model == VehicleHash.Youga || model == VehicleHash.Burrito3);                                  // "CANDRUGS"
                var canmeds  = (model == VehicleHash.Ambulance);                                                               // "CANMEDKITS"
                var veh      = NAPI.Vehicle.CreateVehicle(model, vehicle.Value.Item2, vehicle.Value.Item3, vehicle.Value.Item5, vehicle.Value.Item6);

                NAPI.Data.SetEntityData(veh, "ACCESS", "FRACTION");
                NAPI.Data.SetEntityData(veh, "FRACTION", fraction);
                NAPI.Data.SetEntityData(veh, "MINRANK", vehicle.Value.Item4);
                NAPI.Data.SetEntityData(veh, "TYPE", FractionTypes[fraction]);
                if (canmats)
                {
                    NAPI.Data.SetEntityData(veh, "CANMATS", true);
                }
                if (candrugs)
                {
                    NAPI.Data.SetEntityData(veh, "CANDRUGS", true);
                }
                if (canmeds)
                {
                    NAPI.Data.SetEntityData(veh, "CANMEDKITS", true);
                }
                NAPI.Vehicle.SetVehicleNumberPlate(veh, vehicle.Key);
                Core.VehicleStreaming.SetEngineState(veh, false);
                VehicleManager.FracApplyCustomization(veh, fraction);
                if (model == VehicleHash.Submersible || model == VehicleHash.THRUSTER)
                {
                    veh.SetSharedData("PETROL", 0);
                }
            }
        }