Exemple #1
0
        public RPVehicle(int id, int ownerId, FactionI factionID, VehicleHash model, float parkx, float parky, float parkz, float parkrotationx, float parkrotationy, float parkrotationz, int color1, int color2, String licensePlateText = "", Boolean spawn = true)
        {
            this.id                = id;
            this.ownerId           = ownerId;
            this.factionID         = factionID;
            this.model             = model;
            this.parkPosition      = new Vector3(parkx, parky, parkz);
            this.parkRotation      = new Vector3(parkrotationx, parkrotationy, parkrotationz);
            this.licensePlateText  = licensePlateText;
            this.licensePlateStyle = 0;
            this.color1            = color1;
            this.color2            = color2;
            this.handle            = null;

            if (spawn && ownerId < 0)
            {
                this.Spawn();
                this.ToggleDoorLock();
            }

            if (!licensePlateText.Equals("") && this.spawned)
            {
                this.handle.numberPlate = licensePlateText;
            }

            VehicleManager.Instance().SubscribeToVehicleDestroyedEvent(this.VehicleDestroyedEvent);
        }
Exemple #2
0
        /// <summary>
        /// Buys a vehicle with selected attributes
        /// </summary>
        /// <param name="character">Character who is buying</param>
        /// <param name="model">Vehicle model</param>
        /// <param name="color1">Color 1</param>
        /// <param name="color2">Color 2</param>
        public void PurchaseVehicle(Character character, string model, int color1, int color2)
        {
            if (IsCharacterInShop(character))
            {
                if (DoesShopHaveModel(model))
                {
                    int price = GetPriceForModel(model);
                    if (character.money >= price)
                    {
                        // Deduct the money
                        // Create vehicle and add to databse
                        // Add vehicle to vehicle manager
                        // Inform bueyer that he got new vehicle

                        character.SetMoney(character.money - price);
                        string licensePlate = VehicleManager.Instance().GenerateUnusedLicensePlate();
                        int    id           = VehicleManager.Instance().AddVehicleToDatabase(character.ID, Factions.FactionEnums.CIVILIAN, model, -223.2121f, -1168.157f, 22.5882f, 0.5045538f, 0.1192265f, -91.68389f, licensePlate, 0, color1, color2);
                        VehicleManager.Instance().SendUpdatedVehicleToClient(character, id, licensePlate, false);
                        character.TriggerEvent("EVENT_CHARACTER_EXIT_VEHICLE_SHOP");
                        character.SendNotification("Vehicle purchased!\nExit the shop and access the vehicle from your F1 menu");
                    }
                    else
                    {
                        character.SendNotification("You don't have enough money to buy this vehicle!");
                    }
                }
            }
        }
Exemple #3
0
 public void LockVehicle(Client client)
 {
     VehicleManager.Instance().LockVehicle(client);
 }