/// <summary> /// Called when [disconnect]. /// </summary> /// <param name="reason">The reason.</param> internal void OnDisconnect(string reason) { if (Disconnected) { return; } Disconnected = true; if (_inventoryComponent != null) { if (_mClient.GetRoleplay().UsingPet&& GetRoomUser().MyPet != null) { using (var Adapt = Plus.GetDatabaseManager().GetQueryReactor()) { Adapt.RunFastQuery("UPDATE bots SET room_id = '0' WHERE id = ' " + GetRoomUser().MyPet.PetData.PetId + "'"); } _mClient.GetMessageHandler().PickUpPet(_mClient, GetRoomUser().MyPet.PetData.PetId, true); } _inventoryComponent.RunDbUpdate(); _inventoryComponent.SetIdleState(); } var navilogs = string.Empty; if (NavigatorLogs.Any()) { navilogs = NavigatorLogs.Values.Aggregate(navilogs, (current, navi) => current + string.Format("{0},{1},{2};", navi.Id, navi.Value1, navi.Value2)); navilogs = navilogs.Remove(navilogs.Length - 1); } Plus.GetGame().GetClientManager().UnregisterClient(Id, UserName); SessionManagement.IncreaseDisconnection(); Out.WriteLine("[" + UserName + "] has logged out! Reason: " + reason, "", ConsoleColor.DarkYellow); TimeSpan GetOnlineSeconds = DateTime.Now - TimeLoggedOn; int SecondsToGive = GetOnlineSeconds.Seconds; int GiveOnlineTime = Plus.GetUnixTimeStamp() - TimeLoggedOn1; if (_mClient.GetRoleplay().IsBoxing&& _mClient.GetRoleplay().BoxingRoom != null && _mClient.GetRoleplay().BoxingRoom.SoloQueue != null) { if (_mClient.GetRoleplay().BoxingRoom.SoloQueue.PlayerQueue.Contains(_mClient)) { _mClient.GetRoleplay().BoxingRoom.SoloQueue.PlayerQueue.Remove(_mClient); } _mClient.GetRoleplay().BoxingRoom.SoloQueue.RemoveBoxer(_mClient, true); } // If the user is in colour wars if (_mClient.GetRoleplay().inColourWars) { // Remove the user from team string team; team = _mClient.GetRoleplay().ColourWarTeam.Colour.ToLower().ToString(); _mClient.GetRoleplay().SaveQuickStat("last_cw_team", team); ColourManager.RemovePlayerFromTeam(_mClient, _mClient.GetRoleplay().ColourWarTeam, true, "eat", true); } if (_mClient.GetRoleplay().InMafiaWars) { Plus.GetGame().MafiaWars.RemoveUserFromGame(_mClient, _mClient.GetRoleplay().TeamString, true, true); } if (_mClient.GetRoleplay().Bag != null) { HabboHotel.Roleplay.Misc.RoleplayManager.PickRock(_mClient.GetRoleplay().Bag, _mClient.GetRoleplay().Bag.RoomId); } if (!_habboinfoSaved) { _habboinfoSaved = true; using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { if (this != null) { if (_mClient != null) { if (_mClient.GetRoleplay() != null) { _mClient.GetRoleplay().SaveStats(); _mClient.GetRoleplay().Dispose(); // Dispose of roleplay } } } queryReactor.SetQuery("UPDATE users SET activity_points = " + ActivityPoints + ", credits = " + Credits + ", seasonal_currency = " + BelCredits + ", online='0', last_online = '" + Plus.GetUnixTimeStamp() + "', builders_items_used = " + BuildersItemsUsed + ", navigator = '" + Plus.BoolToEnum(NewNavigator) + "', navilogs = @navilogs WHERE id = " + Id + " LIMIT 1;UPDATE users_stats SET achievement_score=" + AchievementPoints + " WHERE id=" + Id + " LIMIT 1;"); queryReactor.AddParameter("navilogs", navilogs); queryReactor.RunQuery(); queryReactor.RunFastQuery("UPDATE users_stats SET online_seconds = online_seconds + " + GiveOnlineTime + " WHERE id = " + Id); if (Rank >= 4u) { queryReactor.RunFastQuery( string.Format( "UPDATE moderation_tickets SET status='open', moderator_id=0 WHERE status='picked' AND moderator_id={0}", Id)); } } } if (InRoom && CurrentRoom != null) { CurrentRoom.GetRoomUserManager().RemoveUserFromRoom(_mClient, false, false); } if (_messenger != null) { _messenger.AppearOffline = true; _messenger.Destroy(); } if (_avatarEffectsInventoryComponent != null) { _avatarEffectsInventoryComponent.Dispose(); } _mClient = null; }