public static void PlayerDisconnected(ClientInfo _cInfo, bool _bShutdown) { try { if (_cInfo != null) { Log.Out("[SERVERTOOLS] Player disconnected"); if (!string.IsNullOrEmpty(_cInfo.playerId) && _cInfo.entityId != -1) { if (ExitCommand.IsEnabled && ExitCommand.Players.ContainsKey(_cInfo.entityId) && !_bShutdown) { Timers.ExitWithoutCommand(_cInfo, _cInfo.ip); } 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; } } 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 (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)); } }
public static void PlayerDisconnected(ClientInfo _cInfo, bool _bShutdown) { try { if (_cInfo != null && _cInfo.CrossplatformId != null) { string id = _cInfo.CrossplatformId.CombinedString; Log.Out(string.Format("[SERVERTOOLS] Player with id '{0}' '{1}' disconnected", _cInfo.PlatformId.CombinedString, id)); if (ExitCommand.IsEnabled && ExitCommand.Players.ContainsKey(_cInfo.entityId) && !_bShutdown) { Timers.ExitWithoutCommand(_cInfo, _cInfo.ip); } 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(id, 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.AddCurrency(id, sessionBonus); } } int timePlayed = PersistentContainer.Instance.Players[id].TotalTimePlayed; PersistentContainer.Instance.Players[id].TotalTimePlayed = timePlayed + timepassed; PersistentContainer.DataChange = true; } } if (Bank.TransferId.ContainsKey(id)) { Bank.TransferId.Remove(id); } if (Zones.ZonePlayer.ContainsKey(_cInfo.entityId)) { Zones.ZonePlayer.Remove(_cInfo.entityId); } if (Zones.Reminder.ContainsKey(_cInfo.entityId)) { Zones.Reminder.Remove(_cInfo.entityId); } if (BloodmoonWarrior.WarriorList.Contains(_cInfo.entityId)) { BloodmoonWarrior.WarriorList.Remove(_cInfo.entityId); BloodmoonWarrior.KilledZombies.Remove(_cInfo.entityId); } if (Teleportation.Teleporting.Contains(_cInfo.entityId)) { Teleportation.Teleporting.Remove(_cInfo.entityId); } if (LevelUp.PlayerLevels.ContainsKey(_cInfo.entityId)) { LevelUp.PlayerLevels.Remove(_cInfo.entityId); } if (KillNotice.Damage.ContainsKey(_cInfo.entityId)) { KillNotice.Damage.Remove(_cInfo.entityId); } if (InfiniteAmmo.Dict.ContainsKey(_cInfo.entityId)) { InfiniteAmmo.Dict.Remove(_cInfo.entityId); } if (PersistentOperations.NewPlayerQue.Contains(_cInfo)) { PersistentOperations.NewPlayerQue.Remove(_cInfo); } if (PersistentOperations.BlockChatCommands.Contains(_cInfo)) { PersistentOperations.BlockChatCommands.Remove(_cInfo); } if (PersistentOperations.Session.ContainsKey(id)) { PersistentOperations.Session.Remove(id); } } else { Log.Out("[SERVERTOOLS] Player disconnected"); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerDisconnected: {0}", e.Message)); } }