/// <summary>
        /// Завершение рабочей точки
        /// </summary>
        private void FinishPoint(Client player, object[] args)
        {
            player.resetSyncedData(FISH_BITES_EVENT);
            if ((bool)args[0])
            {
                var workLevel = _workInfoManager.GetActiveWork(player).Level;
                var reward    = _rewards[workLevel];
                var isBoat    = player.hasSyncedData(WorkData.IS_FISHERMAN_ON_BOAT);
                var salary    = isBoat ? reward.Salary * 2 : reward.Salary;
                var exp       = isBoat ? (int)(reward.Exp * 1.5) : reward.Exp;
                _workInfoManager.SetSalary(player, WorkType.Fisherman, salary);
                _workInfoManager.SetExperience(player, WorkType.Fisherman, reward.WorkExp);
                _playerInfoManager.SetExperience(player, exp);
            }
            else
            {
                API.sendNotificationToPlayer(player, "~m~Вы упустили рыбу");
            }
            var pointBaits = (int)player.getData(POINT_BAITS_COUNT);

            if (pointBaits < 5)
            {
                SetFishBites(player);
                player.setData(POINT_BAITS_COUNT, pointBaits + 1);
            }
            else
            {
                API.stopPlayerAnimation(player);
                ShowNextPoint(player);
                player.setData(POINT_BAITS_COUNT, 0);
            }
        }
Exemple #2
0
        /// <summary>
        /// Обработчик входа игрока в самолет
        /// </summary>
        private void OnPlayerEnterVehicle(Client player, NetHandle vehicleHandle, int seat)
        {
            var vehicle = API.getEntityFromHandle <Vehicle>(vehicleHandle);

            if (!vehicle.hasData(PLANE_KEY))
            {
                return;
            }
            var activeWork = _workInfoManager.GetActiveWork(player);

            if (activeWork == null || activeWork.Type != WorkType.Pilot)
            {
                WarpOut(player, "Вы не работаете летчиком");
                return;
            }
            if (!AllowToFlyPlane(vehicle, activeWork.Level))
            {
                player.setData(WAS_WARPED, true);
                WarpOut(player, "Недостаточный уровень работы для данного самолета");
                return;
            }
            var contract = PlayerHelper.GetData <DeliveryContract>(player, WorkData.DELIVERY_CONTRACT, null);

            if (contract == null)
            {
                API.sendNotificationToPlayer(player, "~r~Необходимо заключить контракт", true);
                return;
            }
            API.triggerClientEvent(player, ServerEvent.SHOW_PILOT_TARGET_POINT, contract.TargetPosition);
        }
        /// <summary>
        /// Отобращает информацию игрока
        /// </summary>
        private void GetPlayerInfo(Client player, object[] args)
        {
            var playerInfo = _playerInfoManager.GetInfo(player);
            var activeWork = _workInfoManager.GetActiveWork(player);
            var info       = CreateShortPlayerInfo(playerInfo, activeWork);
            var events     = EventsScheduler.ActiveEvent?.GetInfo(player);

            API.triggerClientEvent(player, ServerEvent.SHOW_PLAYER_INFO, JsonConvert.SerializeObject(info), JsonConvert.SerializeObject(events));
        }
Exemple #4
0
        /// <summary>
        /// Устанавливает рабочее снаряжение игрока
        /// </summary>
        public void SetEquipment(Client player)
        {
            var activeWork = _workInfoManager.GetActiveWork(player);

            if (activeWork == null)
            {
                return;
            }
            var isMale = _playerInfoManager.IsMale(player);

            switch (activeWork.Type)
            {
            case WorkType.Loader:
            case WorkType.Forklift:
            case WorkType.Builder:
                SetLoaderClothes(player, isMale);
                break;

            case WorkType.BusDriver:
            case WorkType.Trucker:
            case WorkType.TaxiDriver:
                SetDriverClothes(player, isMale);
                break;

            case WorkType.Police:
                SetPoliceEquipment(player, isMale, activeWork.Level);
                break;

            case WorkType.FoodTrunk:
                SetBistroClothes(player, isMale, false);
                break;

            case WorkType.FoodDeliveryMan:
                SetBistroClothes(player, isMale, true);
                break;

            case WorkType.Wrecker:
                SetWreckerClothes(player, isMale);
                break;

            case WorkType.Pilot:
                SetPilotEquipment(player, isMale);
                break;

            case WorkType.Fisherman:
                SetFishermanEquipment(player, isMale);
                break;

            case WorkType.Farmer:
            case WorkType.TractorDriver:
                SetFarmerEquipment(player, isMale);
                break;

            default:
                throw new ArgumentException("Неизвестный тип работы!");
            }
        }
Exemple #5
0
        /// <summary>
        /// Проверить, что у игрока нет активной работы
        /// </summary>
        protected bool HasActiveWork(Client player, List <WorkType> allowedTypes = null)
        {
            var activeWork = WorkInfoManager.GetActiveWork(player);

            if (activeWork == null || allowedTypes != null && allowedTypes.Contains(activeWork.Type))
            {
                return(false);
            }
            API.sendNotificationToPlayer(player, $"~r~Вы уже работаете. Активная: {activeWork.Type.GetDescription()}", true);
            return(true);
        }
Exemple #6
0
        /// <summary>
        /// Синхронизировать активную работу игрока
        /// </summary>
        private void SyncWork(Client player)
        {
            var activeWork = _workInfoManager.GetActiveWork(player);

            if (activeWork == null)
            {
                return;
            }
            _playerInfoManager.SetBalance(player, activeWork.Salary);
            activeWork.Salary = 0;
            activeWork.Active = false;
            _workInfoManager.SetWorkInfo(player, activeWork);
        }
        /// <summary>
        /// Завершение рабочей точки
        /// </summary>
        private void FinishPoint(Client player, object[] args)
        {
            API.stopPlayerAnimation(player);
            var workInfo = _workInfoManager.GetActiveWork(player);

            if (workInfo == null)
            {
                return;
            }
            var reward = _rewards[workInfo.Level];

            _workInfoManager.SetSalary(player, WorkType.Builder, reward.Salary);
            _workInfoManager.SetExperience(player, WorkType.Builder, reward.WorkExp);
            _playerInfoManager.SetExperience(player, reward.Exp);
            ShowNextPoint(player);
        }