/// <summary>
        /// Обработывает успешную авторизацию игрока
        /// </summary>
        private void ProcessLogin(Client player, PlayerInfo playerInfo)
        {
            var appearance = _playersAppearanceProvider.Get(playerInfo.AccountId);

            playerInfo.Skin       = (Skin)appearance.Skin;
            playerInfo.Appearance = appearance;
            API.triggerClientEvent(player, ServerEvent.SHOW_INTERFACE);
            _gtaCharacter.SetAppearance(player, appearance);
            _gtaCharacter.SetClothes(player, playerInfo.Clothes.Where(e => e.OnPlayer).ToList());
            SetPosition(player, playerInfo);
            PlayerManager.SetPlayerName(player, playerInfo);
            player.resetSyncedData(DISABLE_HOTKEYS);
            if (_admins.Contains(player.socialClubName))
            {
                player.setSyncedData("IsAdmin", true);
            }
            if (playerInfo.PhoneNumber != 0)
            {
                player.setSyncedData("HasPhone", true);
            }
            player.freeze(false);
            _playerInfoManager.RefreshUI(player, playerInfo);
            API.sendNativeToPlayer(player, Hash.DISPLAY_RADAR, true);
            API.sendChatMessageToAll($"~g~[Информация]: {playerInfo.Name} зашел на сервер. Онлайн: {ServerState.Players.Count}");
        }
        /// <summary>
        /// Одеть одежду игрока
        /// </summary>
        public void SetPlayerClothes(Client player, bool withAppearanse = false)
        {
            if (!API.isPlayerConnected(player))
            {
                return;
            }
            if (withAppearanse)
            {
                var playerInfo = GetInfo(player);
                API.setPlayerSkin(player, (PedHash)playerInfo.Skin);
                _gtaCharacter.SetAppearance(player, playerInfo.Appearance);
            }
            var clothes = GetInfo(player).Clothes.Where(e => e.OnPlayer).ToList();

            _gtaCharacter.SetClothes(player, clothes);
        }
示例#3
0
        /// <summary>
        /// Сохранить кастомизацию персонажа
        /// </summary>
        private void SaveCharacter(Client player, object[] args)
        {
            var name        = args[1].ToString();
            var surname     = args[2].ToString();
            var playerInfo  = _playerInfoManager.GetInfo(player);
            var playerName  = $"{GetPretty(name)} {GetPretty(surname)}";
            var nameSuccess = _playersProvider.SetName(playerInfo.AccountId, playerName);

            if (!nameSuccess)
            {
                API.triggerClientEvent(player, ServerEvent.NAME_ALREADY_EXIST);
                return;
            }
            var character = JsonConvert.DeserializeObject <PlayerAppearance>(args[0].ToString());

            _gtaCharacter.SetAppearance(player, character);
            SetPlayerInfo(player, playerInfo, playerName, character.Skin);
            _playersAppearanceProvider.Save(playerInfo.AccountId, character);
            SetPlayerInStartLocation(player);
            API.sendNativeToPlayer(player, Hash.DISPLAY_RADAR, true);
        }