Esempio n. 1
0
        /// <summary>
        /// Покупка еды закусочной
        /// </summary>
        private void BuyBistroFood(Client player, object[] args)
        {
            var price      = (int)args[0];
            var playerInfo = PlayerInfoManager.GetInfo(player);

            if (playerInfo.Balance < price)
            {
                API.sendNotificationToPlayer(player, "~r~Недостаточно денег", true);
                return;
            }
            var satiety    = (int)args[1];
            var newSatiety = playerInfo.Satiety + satiety;

            playerInfo.Satiety  = newSatiety <= PlayerInfo.MAX_VALUE ? newSatiety : PlayerInfo.MAX_VALUE;
            playerInfo.Balance -= price;
            PlayerInfoManager.RefreshUI(player, playerInfo);
            var truckDriverName = args[2].ToString();

            if (!string.IsNullOrEmpty(truckDriverName))
            {
                _bistroManager.SetTruckDriverRevard(truckDriverName, price, playerInfo.Name);
            }
            API.sendNotificationToPlayer(player, $"Сытость восстановлена на ~b~{satiety} ед.");
            API.triggerClientEvent(player, ServerEvent.HIDE_BISTRO_FOOD_MENU);
            var street = (int)args[0];

            if (street != Validator.INVALID_ID)
            {
                _clanManager.ReplenishClanBalance(street, price);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Оплата аренды фургона
        /// </summary>
        private bool PayTrunkRent(Client player, int rentCost)
        {
            var playerInfo = PlayerInfoManager.GetInfo(player);

            if (playerInfo.Balance < rentCost)
            {
                API.sendNotificationToPlayer(player, "~r~Недостаточно денег для аренды фургона", true);
                return(false);
            }
            playerInfo.Balance -= rentCost;
            PlayerInfoManager.RefreshUI(player, playerInfo);
            return(true);
        }
        /// <summary>
        /// Обработчик оплаты штрафа для снятия розыска
        /// </summary>
        private void PayPenalty(Client player, object[] objects)
        {
            var playerInfo = PlayerInfoManager.GetInfo(player);

            if (playerInfo.Wanted.WantedLevel == 0)
            {
                API.sendNotificationToPlayer(player, "~r~Вы не в розыске", true);
                return;
            }
            var penalty = PoliceManager.CalculatePenalty(playerInfo);

            if (playerInfo.Balance < penalty)
            {
                API.sendNotificationToPlayer(player, "~b~Недостаточно средств", true);
                return;
            }
            playerInfo.Balance -= penalty;
            PlayerInfoManager.RefreshUI(player, playerInfo);
            PlayerInfoManager.ClearWanted(player);
            API.sendNotificationToPlayer(player, "~b~Вы сняты с розыска");
        }
        /// <summary>
        /// Обработчик покупки наживки
        /// </summary>
        private void BuyFishBaits(Client player, object[] args)
        {
            var price      = (int)args[0];
            var playerInfo = PlayerInfoManager.GetInfo(player);

            if (!PlayerHelper.EnoughMoney(player, playerInfo, price))
            {
                return;
            }
            playerInfo.Balance -= price;
            if (player.hasData(FishermanManager.FISH_BAITS_COUNT))
            {
                var currentCount = (int)player.getData(FishermanManager.FISH_BAITS_COUNT);
                player.setData(FishermanManager.FISH_BAITS_COUNT, currentCount + BAITS_COUNT);
            }
            else
            {
                player.setData(FishermanManager.FISH_BAITS_COUNT, BAITS_COUNT);
            }
            PlayerInfoManager.RefreshUI(player, playerInfo);
            API.sendNotificationToPlayer(player, "~b~Приобретена наживка");
        }
        /// <summary>
        /// Обработчик покупки лицензии на оружие
        /// </summary>
        private void BuyWeaponLicense(Client player, object[] args)
        {
            var price      = (int)args[0];
            var playerInfo = PlayerInfoManager.GetInfo(player);

            if (!CanBuyLicense(player, playerInfo, price))
            {
                return;
            }
            playerInfo.Balance -= price;
            var license = new InventoryItem {
                OwnerId      = playerInfo.AccountId,
                Name         = InventoryType.WeaponLicense.GetDescription(),
                Type         = InventoryType.WeaponLicense,
                Count        = 1,
                CountInHouse = 0,
                Model        = (int)Validator.INVALID_ID
            };

            playerInfo.Inventory.Add(license);
            PlayerInfoManager.RefreshUI(player, playerInfo);
            API.sendNotificationToPlayer(player, "Приобретена ~b~лицензия ~w~на оружие");
        }