Пример #1
0
 public static void PlayerDisconnected(ClientInfo _cInfo, bool _bShutdown)
 {
     try
     {
         if (_cInfo != null)
         {
             if (_bShutdown)
             {
                 Log.Out("[SERVERTOOLS] Server shutdown, player disconnected.");
             }
             else if (BattleLogger.IsEnabled && BattleLogger.Exit.Contains(_cInfo.playerId))
             {
                 string _ip = _cInfo.ip;
                 if (_ip.Contains(":"))
                 {
                     _ip = _ip.Split(':').First();
                 }
                 Timers.BattleLogDelay(_cInfo, _ip);
                 Log.Out("[SERVERTOOLS] Player disconnected");
             }
             else
             {
                 Log.Out("[SERVERTOOLS] Player disconnected");
             }
             if (!string.IsNullOrEmpty(_cInfo.playerId) && _cInfo.entityId != -1)
             {
                 if (FriendTeleport.Dict.ContainsKey(_cInfo.entityId))
                 {
                     FriendTeleport.Dict.Remove(_cInfo.entityId);
                     FriendTeleport.Dict1.Remove(_cInfo.entityId);
                 }
                 if (FriendTeleport.Dict.ContainsKey(_cInfo.entityId))
                 {
                     FriendTeleport.Dict.Remove(_cInfo.entityId);
                 }
                 if (FriendTeleport.Dict1.ContainsKey(_cInfo.entityId))
                 {
                     FriendTeleport.Dict1.Remove(_cInfo.entityId);
                 }
                 if (Wallet.IsEnabled && Wallet.Session_Bonus > 0)
                 {
                     if (PersistentOperations.Session.TryGetValue(_cInfo.playerId, out DateTime _time))
                     {
                         TimeSpan varTime           = DateTime.Now - _time;
                         double   fractionalMinutes = varTime.TotalMinutes;
                         int      _timepassed       = (int)fractionalMinutes;
                         if (_timepassed > 60)
                         {
                             int _sessionBonus = _timepassed / 60 * Wallet.Session_Bonus;
                             if (_sessionBonus > 0)
                             {
                                 Wallet.AddCoinsToWallet(_cInfo.playerId, _sessionBonus);
                             }
                         }
                         int _timePlayed = PersistentContainer.Instance.Players[_cInfo.playerId].TotalTimePlayed;
                         PersistentContainer.Instance.Players[_cInfo.playerId].TotalTimePlayed = _timePlayed + _timepassed;
                         PersistentContainer.Instance.Save();
                     }
                 }
                 if (PersistentOperations.Session.ContainsKey(_cInfo.playerId))
                 {
                     PersistentOperations.Session.Remove(_cInfo.playerId);
                 }
                 if (PersistentOperations.PvEViolations.ContainsKey(_cInfo.entityId))
                 {
                     PersistentOperations.PvEViolations.Remove(_cInfo.entityId);
                 }
                 if (Bank.TransferId.ContainsKey(_cInfo.playerId))
                 {
                     Bank.TransferId.Remove(_cInfo.playerId);
                 }
                 if (Zones.ZoneInfo.ContainsKey(_cInfo.entityId))
                 {
                     Zones.ZoneInfo.Remove(_cInfo.entityId);
                 }
                 if (Zones.Forgive.ContainsKey(_cInfo.entityId))
                 {
                     Zones.Forgive.Remove(_cInfo.entityId);
                 }
                 if (Zones.Victim.ContainsKey(_cInfo.entityId))
                 {
                     Zones.Victim.Remove(_cInfo.entityId);
                 }
                 if (Zones.Reminder.ContainsKey(_cInfo.entityId))
                 {
                     Zones.Reminder.Remove(_cInfo.entityId);
                 }
                 if (Zones.ZonePvE.Contains(_cInfo.entityId))
                 {
                     Zones.ZonePvE.Remove(_cInfo.entityId);
                 }
                 if (BloodmoonWarrior.WarriorList.Contains(_cInfo.playerId))
                 {
                     BloodmoonWarrior.WarriorList.Remove(_cInfo.playerId);
                 }
                 if (BattleLogger.Exit.Contains(_cInfo.playerId))
                 {
                     BattleLogger.Exit.Remove(_cInfo.playerId);
                 }
                 if (BattleLogger.ExitPos.ContainsKey(_cInfo.playerId))
                 {
                     BattleLogger.ExitPos.Remove(_cInfo.playerId);
                 }
                 if (KillNotice.Damage.ContainsKey(_cInfo.entityId))
                 {
                     KillNotice.Damage.Remove(_cInfo.entityId);
                 }
                 if (PlayerChecks.Flag.ContainsKey(_cInfo.entityId))
                 {
                     PlayerChecks.Flag.Remove(_cInfo.entityId);
                 }
                 if (Teleportation.Teleporting.Contains(_cInfo.entityId))
                 {
                     Teleportation.Teleporting.Remove(_cInfo.entityId);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerDisconnected: {0}", e.Message));
     }
 }