Esempio n. 1
0
        public void SpawnCars(List <string> vehicles)
        {
            int i = 0;

            foreach (var number in vehicles)
            {
                if (i >= GarageManager.GarageTypes[Type].VehiclesPositions.Count)
                {
                    continue;
                }
                var vehData = VehicleManager.Vehicles[number];
                if (vehData.Health < 1)
                {
                    continue;
                }
                var veh = NAPI.Vehicle.CreateVehicle(NAPI.Util.VehicleNameToModel(vehData.Model), GarageManager.GarageTypes[Type].VehiclesPositions[i] + new Vector3(0, 0, 0.25), GarageManager.GarageTypes[Type].VehiclesRotations[i], 0, 0);
                veh.NumberPlate = number;
                NAPI.Entity.SetEntityDimension(veh, (uint)Dimension);
                VehicleStreaming.SetEngineState(veh, false);
                VehicleStreaming.SetLockStatus(veh, true);
                veh.SetData("ACCESS", "GARAGE");
                veh.SetData("ITEMS", vehData.Items);
                veh.SetSharedData("PETROL", vehData.Fuel);
                VehicleManager.ApplyCustomization(veh);
                entityVehicles.Add(number, new Tuple <int, NetHandle>(i, veh));
                i++;
            }
        }
Esempio n. 2
0
        public void SpawnCarAtPosition(Client player, string number, Vector3 position, Vector3 rotation)
        {
            if (vehiclesOut.ContainsKey(number))
            {
                Main.Players[player].LastVeh = "";
                return;
            }

            var vData = VehicleManager.Vehicles[number];
            var veh   = NAPI.Vehicle.CreateVehicle(NAPI.Util.VehicleNameToModel(vData.Model), position, rotation, 0, 0, number);

            vehiclesOut.Add(number, veh);

            veh.SetSharedData("PETROL", vData.Fuel);
            veh.SetData("ACCESS", "PERSONAL");
            veh.SetData("OWNER", player);
            veh.SetData("ITEMS", vData.Items);

            //VehicleManager.Vehicles[number].Position = JsonConvert.SerializeObject(Position + new Vector3(0, 0, 0.3));
            //VehicleManager.Vehicles[number].Position = JsonConvert.SerializeObject(Rotation);
            //Main.Players[player].LastVeh = number;

            NAPI.Vehicle.SetVehicleNumberPlate(veh, number);

            VehicleStreaming.SetEngineState(veh, false);
            VehicleStreaming.SetLockStatus(veh, true);

            VehicleManager.ApplyCustomization(veh);
        }
Esempio n. 3
0
        public void GetVehicleFromGarage(Client player, string number)
        {
            var vData = VehicleManager.Vehicles[number];
            var veh   = NAPI.Vehicle.CreateVehicle(NAPI.Util.VehicleNameToModel(vData.Model), Position + new Vector3(0, 0, 0.3), Rotation, 0, 0, number);

            vehiclesOut.Add(number, veh);
            veh.SetSharedData("PETROL", vData.Fuel);
            veh.SetData("ACCESS", "PERSONAL");
            veh.SetData("OWNER", player);
            veh.SetData("ITEMS", vData.Items);

            //VehicleManager.Vehicles[number].Position = JsonConvert.SerializeObject(Position + new Vector3(0, 0, 0.3));
            //VehicleManager.Vehicles[number].Position = JsonConvert.SerializeObject(Rotation);
            //Main.Players[player].LastVeh = number;

            NAPI.Vehicle.SetVehicleNumberPlate(veh, number);

            if (Type == -1)
            {
                VehicleStreaming.SetEngineState(veh, false);
                VehicleStreaming.SetLockStatus(veh, true);
            }
            else
            {
                player.SetIntoVehicle(veh, -1);
                if (vData.Fuel > 0)
                {
                    VehicleStreaming.SetEngineState(veh, true);
                }
                else
                {
                    VehicleStreaming.SetEngineState(veh, false);
                }
            }

            if (Type != -1)
            {
                NAPI.Task.Run(() =>
                {
                    try
                    {
                        NAPI.Entity.DeleteEntity(entityVehicles[number].Item2);
                        entityVehicles.Remove(number);
                    }
                    catch { }
                });
            }

            VehicleManager.ApplyCustomization(veh);
        }
Esempio n. 4
0
        public void SpawnCar(string number)
        {
            if (entityVehicles.ContainsKey(number))
            {
                return;
            }
            int i = 0;

            for (i = 0; i < 10; i++)
            {
                if (entityVehicles.Values.FirstOrDefault(t => t.Item1 == i) == null)
                {
                    break;
                }
            }

            if (i >= GarageManager.GarageTypes[Type].VehiclesPositions.Count)
            {
                return;
            }

            var vehData = VehicleManager.Vehicles[number];

            if (vehData.Health < 1)
            {
                return;
            }
            var veh = NAPI.Vehicle.CreateVehicle(NAPI.Util.VehicleNameToModel(vehData.Model), GarageManager.GarageTypes[Type].VehiclesPositions[i] + new Vector3(0, 0, 0.25), GarageManager.GarageTypes[Type].VehiclesRotations[i], 0, 0);

            veh.NumberPlate = number;
            NAPI.Entity.SetEntityDimension(veh, (uint)Dimension);
            VehicleStreaming.SetEngineState(veh, false);
            VehicleStreaming.SetLockStatus(veh, true);
            veh.SetData("ACCESS", "GARAGE");
            veh.SetData("ITEMS", vehData.Items);
            veh.SetSharedData("PETROL", vehData.Fuel);
            VehicleManager.ApplyCustomization(veh);
            entityVehicles.Add(number, new Tuple <int, NetHandle>(i, veh));
        }