Exemplo n.º 1
0
        /// <summary>
        /// Обработчик выхода игрока
        /// </summary>
        public void OnPlayerDisconnect(Client player, string reason)
        {
            if (player.hasData(ClanMission.BOOTY_OBJECT))
            {
                ClanMissionManager.DetachBooty(player);
            }
            var playerInfo = _playerInfoManager.GetInfo(player);

            if (playerInfo == null)
            {
                return;
            }
            if (player.hasData(PlayerData.ON_RACE) || player.hasSyncedData(PlayerData.IS_REGISTERED))
            {
                ProcessRacer(player);
            }
            SyncWork(player);
            SyncPrisoner(player);
            SyncJail(player, playerInfo);
            SyncWeaponAmmo(player, playerInfo);
            SyncClanMissionVote(player, playerInfo);
            playerInfo.LastPosition = PositionConverter.VectorToString(player.position);
            _accountsProvider.UpdateTotalTime(playerInfo.AccountId);
            _playersProvider.UpdatePlayersInfos(new List <PlayerInfo> {
                playerInfo
            });
            _vehiclesProvider.Update(playerInfo.Vehicles.Values);
            _playerInfoManager.Remove(player);
        }
        /// <summary>
        /// Обработчик смерти игрока
        /// </summary>
        public void OnPlayerDeath(Client player, NetHandle handle, int weapon)
        {
            if (player.hasData(PlayerData.ON_EVENT) || player.hasData(PlayerData.ON_RACE) || player.hasData(PlayerData.FIGHTER))
            {
                return;
            }
            if (player.hasData(ClanMission.BOOTY_OBJECT))
            {
                ClanMissionManager.DetachBooty(player);
            }
            var playerInfo = _playerInfoManager.GetInfo(player);

            _inventoryManager.RefreshAmmo(player, playerInfo);
            ProcessKiller(player, handle, playerInfo);
            ProcessPoliceman(player);
            SetDeathPenalty(player, playerInfo);
        }