コード例 #1
0
ファイル: ModClass.cs プロジェクト: FBonini22/Fuel-Mod
        private void onKeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (e.KeyCode == CAN_REFUEL_CONTROL)
            {
                if (p.IsInVehicle() && currentCar != null)
                {
                    //currentCar = new GasVehicle(p.CurrentVehicle);
                    GTA.UI.Notification.Show(currentCar.GetFuelLevel().ToString() + "\n" +
                                             currentCar.GetActualFuelLevel().ToString() + "\n" +
                                             currentCar.GetCurrentFuelConsumption().ToString() + " MPG\n" +
                                             currentCar.distanceT.ToString());
                }


                else if (readyForCanRefuel)
                {
                    vehicleForRefuel.Refuel(FUEL.Jerry_Can);

                    GTA.UI.Notification.Show("Vehicle refueled!");

                    vehicleForRefuel = null;
                    p.Weapons.Remove(GTA.WeaponHash.PetrolCan);

                    readyForCanRefuel = false;
                }
            }

            //Refuel vehicle
            else if (e.KeyCode == STATION_REFUEL_CONTROL)
            {
                if (refuelMenuEnabled)
                {
                    if (IsAtGasStation())
                    {
                        //Refill the vehicle and charge the player
                        if ((int)refillPrice <= Game.Player.Money)
                        {
                            ChargePlayer(refillPrice);

                            currentCar.Refuel(FUEL.Fuel_Pump);
                            GTA.UI.Notification.Show("Vehicle refueled!");

                            justRefueled = true;
                            elapsedTimeSinceLastRefuel = 0;
                            refillPrice = 0;
                        }
                        else
                        {
                            GTA.UI.Notification.Show("You don\'t have enough cash to refuel your vehicle! ");
                            //Add a random pity message
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: ModClass.cs プロジェクト: FBonini22/Fuel-Mod
        //VEHICLE LIST METHODS
        /// <summary>
        /// Adds a vehicle to the savedVehicles List. Checks if vehicle is already in list.
        /// </summary>
        /// <param name="gV"></param>
        private void AddVehicle(GasVehicle gV)
        {
            //Previously was "!SavedVehicles.Contains(gV)"
            if (!savedVehicles.Contains(gV))
            {
                GTA.UI.Notification.Show("Adding gas vehicle to list...");
                if (savedVehicles.Count >= MAX_SAVED_VEHICLES)
                {
                    removeVehicle(0);
                }
                savedVehicles.Add(gV);
            }
            else
            {
                GTA.UI.Notification.Show("List of vehicles already contains this vehicle.");

                currentCar = savedVehicles.Find((GasVehicle gGV) => { return(gGV.Equals(gV)); });
                GTA.UI.Notification.Show("Loaded vehicle from list. Current fuel level is: " + currentCar.GetFuelLevel());
            }
        }