/// <summary>
        /// Забрать машину со штрафстоянки
        /// </summary>
        private void GetVehicleFromParkingFine(Client player, object[] args)
        {
            var freePlace = GetFreePlace();

            if (freePlace == null)
            {
                API.sendNotificationToPlayer(player, "~r~В данный момент на стоянке нет свободных мест", true);
                return;
            }
            var price      = (int)args[1];
            var playerInfo = PlayerInfoManager.GetInfo(player);

            if (playerInfo.Balance < price)
            {
                API.sendNotificationToPlayer(player, "~r~Недостаточно средств", true);
                return;
            }
            playerInfo.Balance -= price;
            var vehicleInfo = JsonConvert.DeserializeObject <Vehicle>(args[0].ToString());

            vehicleInfo.IsSpawned     = true;
            vehicleInfo.OnParkingFine = false;
            _vehicleManager.CreateVehicle(vehicleInfo, freePlace.Item1, freePlace.Item2);
            _vehicleInfoManager.SetInfo(player, vehicleInfo);
            API.triggerClientEvent(player, ServerEvent.HIDE_PARKING_FINE_MENU);
        }
Esempio n. 2
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. 3
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);
        }
Esempio n. 4
0
        /// <summary>
        /// Проверяет, что игроку доступен контракт банды
        /// </summary>
        private bool ClanRankEnough(Client player, int workLevel, int minLevel, ClanRank minRank)
        {
            if (!LevelEnough(player, workLevel, minLevel))
            {
                return(false);
            }
            var clanInfo = PlayerInfoManager.GetInfo(player).Clan;

            if (clanInfo == null || clanInfo.Rank < minRank)
            {
                API.sendNotificationToPlayer(player, $"~r~Необходимый ранг в банде \"{minRank.GetDescription()}\" и выше", true);
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// Получить зарплату
        /// </summary>
        private void GetSalary(Client player, object[] args)
        {
            var activeWork = WorkInfoManager.GetActiveWork(player);

            if (!WorkIsCorrect(player, activeWork, () => activeWork.Type == WorkType.Police))
            {
                return;
            }
            WorkInfoManager.SetActivity(player, WorkType.Police, false);
            player.resetData(WorkData.IS_POLICEMAN);
            player.resetSyncedData("HasPoliceActions");
            PayOut(player, activeWork);
            PlayerInfoManager.SetPlayerClothes(player);
            PlayerManager.SetPlayerName(player, PlayerInfoManager.GetInfo(player));
            _inventoryManager.EquipWeapon(player);
            _policeAlertManager.HideAllAlerts(player);
            API.triggerClientEvent(player, ServerEvent.HIDE_SARAH_MENU);
        }
Esempio n. 6
0
        /// <summary>
        /// Обработчик входа в угоняемую машину
        /// </summary>
        private void OnEnterHijackedVehicle(Client player, NetHandle vehHandle, int seat)
        {
            var vehicle = API.getEntityFromHandle <Vehicle>(vehHandle);

            if (!vehicle.hasData(THIEFT_VEHICLE))
            {
                return;
            }
            var thiefName = vehicle.hasData(THIEF_NAME) ? (string)vehicle.getData(THIEF_NAME) : string.Empty;

            if (thiefName == player.name)
            {
                var playerClanId = PlayerInfoManager.GetInfo(player).Clan.ClanId;
                API.triggerClientEvent(player, ServerEvent.SHOW_CLAN_QUEST_END_POINT, VehicleTheftData.EndPointPositions[playerClanId]);
            }
            else
            {
                player.warpOutOfVehicle();
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Создает точку сдачи угнаной машины
        /// </summary>
        private void CreateQuestEndPoint(long clanId, Vector3 position)
        {
            var endPoint = API.createCylinderColShape(position, 4f, 3f);

            endPoint.onEntityEnterColShape += (shape, entity) => PlayerHelper.ProcessAction(entity, player => {
                var playerClanId = PlayerInfoManager.GetInfo(player).Clan?.ClanId ?? Validator.INVALID_ID;
                if (clanId != playerClanId)
                {
                    return;
                }
                var vehicle = API.getPlayerVehicle(player);
                if (vehicle.IsNull || !API.hasEntityData(vehicle, THIEFT_VEHICLE))
                {
                    return;
                }
                API.deleteEntity(vehicle);
                SetQuestReward(player);
                ActionHelper.CancelAction(player, CLAN_QUEST_TIMER);
                API.triggerClientEvent(player, ServerEvent.HIDE_CLAN_QUEST_POINTS);
            }, 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~на оружие");
        }
        /// <summary>
        /// Начать работу в полиции
        /// </summary>
        private void WorkInPolice(Client player, object[] args)
        {
            WorkInfoManager.CreateInfoIfNeed(player, WorkType.Police);
            if (HasActiveWork(player) || !CanWork(player, MIN_LEVEL))
            {
                return;
            }
            var playerInfo = PlayerInfoManager.GetInfo(player);

            if (playerInfo.Clan != null)
            {
                API.sendNotificationToPlayer(player, "~r~Вы являетесь членом банды", true);
                return;
            }
            WorkInfoManager.SetActivity(player, WorkType.Police, true);
            player.setData(WorkData.IS_POLICEMAN, true);
            player.setSyncedData("HasPoliceActions", true);
            _workEquipmentManager.SetEquipment(player);
            _policeAlertManager.ShowAllAlerts(player);
            SetPolicemanName(player, playerInfo);
            player.setData(PoliceManager.STATE_KEY, (int)PolicemanState.NoPrisoner);
            API.triggerClientEvent(player, ServerEvent.HIDE_SARAH_MENU);
            API.sendNotificationToPlayer(player, "Вы начали работу ~b~в полиции");
        }