예제 #1
0
        /// <summary>
        /// Обработчик логина игрока
        /// </summary>
        private void PlayerLogin(Client player, object[] args)
        {
            var email    = args[0].ToString();
            var password = args[1].ToString();
            var account  = _accountsProvider.Get(email, password);

            if (account == null)
            {
                API.triggerClientEvent(player, ServerEvent.BAD_LOGIN);
                return;
            }
            var playerInfo = _playersProvider.GetInfo(account.Id);

            _playerInfoManager.Add(player, playerInfo);
            API.setPlayerHealth(player, playerInfo.Health);
            API.triggerClientEvent(player, ServerEvent.HIDE_AUTH);
            if (!string.IsNullOrEmpty(playerInfo.Name))
            {
                ProcessLogin(player, playerInfo);
                LoadPlayerVehicles(player, playerInfo);
                _inventoryManager.EquipWeapon(player);
                _giftsManager.ProcessDaysGift(player, account);
            }
            else
            {
                API.setEntityDimension(player, (int)-playerInfo.AccountId);
                _creatingCharManager.ShowCreator(player);
            }
            account.LastLogin = DateTime.Now;
            _accountsProvider.Update(account);
            _giftsManager.StartGiftsTimer(player);
        }
예제 #2
0
        /// <summary>
        /// Обработчик регистрации нового игрока
        /// </summary>
        private void PlayerRegister(Client player, object[] args)
        {
            var email         = args[0].ToString();
            var password      = args[1].ToString();
            var friendReferal = args[2].ToString();
            var createResult  = _accountsProvider.Create(email, password, friendReferal);

            if (!createResult)
            {
                API.triggerClientEvent(player, ServerEvent.BAD_REGISTER);
                return;
            }
            var account = _accountsProvider.Get(email, password);

            _playersProvider.Add(account);
            var playerInfo = _playersProvider.GetInfo(account.Id);

            _playerInfoManager.Add(player, playerInfo);
            API.triggerClientEvent(player, ServerEvent.HIDE_AUTH);
            API.setEntityDimension(player, (int)-account.Id);
            _creatingCharManager.ShowCreator(player);
        }