Ejemplo 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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Записывает информацию о транспорте игрока
        /// </summary>
        public void SetInfo(VehicleInfo vehicleInfo)
        {
            var player = API.getAllPlayers().FirstOrDefault(e => e != null && vehicleInfo.OwnerId == (long)e.getData(PlayerInfoManager.ID_KEY));

            if (player != null)
            {
                SetInfo(player, vehicleInfo);
            }
            else
            {
                _vehiclesProvider.Update(new List <VehicleInfo> {
                    vehicleInfo
                });
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Синхронизировать кэш с бд
        /// </summary>
        private void Synchronize()
        {
            UpdatePlayersData();
            var playersInfos = ServerState.Players.Values.ToList();

            _playersProvider.UpdatePlayersInfos(playersInfos);
            var houses = ServerState.Houses.Values.ToList();

            _housesProvider.UpdateHouses(houses);
            _clanProvider.SaveClans(ServerState.Clans);
            foreach (var player in playersInfos)
            {
                _vehiclesProvider.Update(player.Vehicles.Values);
            }
        }