internal void Save() { using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery( "UPDATE users_preferences SET volume = @volume, prefer_old_chat = @prefer_old_chat, ignore_room_invite = @ignore_room_invite, newnavi_x = @newnavi_x, newnavi_y = @newnavi_y, newnavi_width = @newnavi_width, newnavi_height = @newnavi_height, disable_camera_follow = @disable_camera_follow WHERE userid = @userid"); queryReactor.AddParameter("userid", _userId); queryReactor.AddParameter("prefer_old_chat", Plus.BoolToEnum(PreferOldChat)); queryReactor.AddParameter("ignore_room_invite", Plus.BoolToEnum(IgnoreRoomInvite)); queryReactor.AddParameter("volume", Volume); queryReactor.AddParameter("newnavi_x", NewnaviX); queryReactor.AddParameter("newnavi_y", NewnaviY); queryReactor.AddParameter("newnavi_width", NewnaviWidth); queryReactor.AddParameter("newnavi_height", NewnaviHeight); queryReactor.AddParameter("disable_camera_follow", Plus.BoolToEnum(DisableCameraFollow)); queryReactor.RunQuery(); } }
public static void SaveWired(IWiredItem fItem) { if (fItem == null) { return; } using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { var text = string.Empty; var num = 0; foreach (var current in fItem.Items) { if (num != 0) { text += ";"; } text += current.Id; num++; } if (fItem.OtherString == null) { fItem.OtherString = string.Empty; } if (fItem.OtherExtraString == null) { fItem.OtherExtraString = string.Empty; } if (fItem.OtherExtraString2 == null) { fItem.OtherExtraString2 = string.Empty; } queryReactor.SetQuery( "REPLACE INTO items_wireds VALUES (@id, @items, @delay, @string, @bool, @extrastring, @extrastring2)"); queryReactor.AddParameter("id", fItem.Item.Id); queryReactor.AddParameter("items", text); queryReactor.AddParameter("delay", fItem.Delay); queryReactor.AddParameter("string", fItem.OtherString); queryReactor.AddParameter("bool", Plus.BoolToEnum(fItem.OtherBool)); queryReactor.AddParameter("extrastring", fItem.OtherExtraString); queryReactor.AddParameter("extrastring2", fItem.OtherExtraString2); queryReactor.RunQuery(); } }
/// <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; }
/// <summary> /// Updates the preset. /// </summary> /// <param name="preset">The preset.</param> /// <param name="color">The color.</param> /// <param name="intensity">The intensity.</param> /// <param name="bgOnly">if set to <c>true</c> [bg only].</param> /// <param name="hax">if set to <c>true</c> [hax].</param> internal void UpdatePreset(int preset, string color, int intensity, bool bgOnly, bool hax = false) { if (!IsValidColor(color) || (!IsValidIntensity(intensity) && !hax)) { return; } string text = "one"; switch (preset) { case 2: text = "two"; break; case 3: text = "three"; break; default: text = "one"; break; } using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery(string.Format(format: "UPDATE items_moodlight SET preset_{0}='{1},{2},{3}' WHERE item_id='{4}'", args: new object[] { text, color, intensity, Plus.BoolToEnum(bgOnly), ItemId })); queryReactor.RunQuery(); } GetPreset(preset).ColorCode = color; GetPreset(preset).ColorIntensity = intensity; GetPreset(preset).BackgroundOnly = bgOnly; }
/// <summary> /// Unloads the room. /// </summary> /// <param name="room">The room.</param> /// <param name="reason">The reason.</param> internal void UnloadRoom(Room room, string reason) { if (room == null || room.RoomData == null) { return; } if (room.RoomData.Description.Contains("SPACE")) { spaceManager.initiated = false; } if (room.RoomData.Description.Contains("TREES")) { woodManager.initiated = false; } if (room.RoomData.Description.Contains("FARM")) { farmingManager.initiated = false; } if (room.RoomData.Description.Contains("CASINO")) { SlotsManager.initiated = false; } if (Plus.GetGame().MafiaWars.Started) { if (room.RoomData.Description.Contains("MAFIAWARS")) { return; } } if (room.RoomId == ColourManager.GameLobby && ColourManager.LobbyLoop != null) { ColourManager.LobbyLoop.On = false; ColourManager.LobbyLoop = null; } if (room.RoomData.Description.Contains("MAFIAWARLOBBY") && Plus.GetGame().MafiaWars.LobbyLoop != null) { Plus.GetGame().MafiaWars.LobbyLoop.On = false; Plus.GetGame().MafiaWars.LobbyLoop = null; } if (Plus.GetGame().GetNavigator().PrivateCategories.Contains(room.RoomData.Category)) { ((FlatCat)Plus.GetGame().GetNavigator().PrivateCategories[room.RoomData.Category]).UsersNow -= room.UserCount; } room.RoomData.UsersNow = 0; var state = "open"; if (room.RoomData.State == 1) { state = "locked"; } else if (room.RoomData.State > 1) { state = "password"; } using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery( "UPDATE rooms_data SET caption = @caption, description = @description, password = @password, category = " + room.RoomData.Category + ", state = '" + state + "', tags = @tags, users_now = '0', users_max = " + room.RoomData.UsersMax + ", allow_pets = '" + Plus.BoolToEnum(room.RoomData.AllowPets) + "', allow_pets_eat = '" + Plus.BoolToEnum(room.RoomData.AllowPetsEating) + "', allow_walkthrough = '" + Plus.BoolToEnum(room.RoomData.AllowWalkThrough) + "', hidewall = '" + Plus.BoolToEnum(room.RoomData.HideWall) + "', floorthick = " + room.RoomData.FloorThickness + ", wallthick = " + room.RoomData.WallThickness + ", mute_settings='" + room.RoomData.WhoCanMute + "', kick_settings='" + room.RoomData.WhoCanKick + "',ban_settings='" + room.RoomData.WhoCanBan + "', walls_height = '" + room.RoomData.WallHeight + "', chat_type = @chat_t,chat_balloon = @chat_b,chat_speed = @chat_s,chat_max_distance = @chat_m,chat_flood_protection = @chat_f, trade_state = '" + room.RoomData.TradeState + "' WHERE id = " + room.RoomId); queryReactor.AddParameter("caption", room.RoomData.Name); queryReactor.AddParameter("description", room.RoomData.Description); queryReactor.AddParameter("password", room.RoomData.PassWord); queryReactor.AddParameter("tags", string.Join(",", room.RoomData.Tags)); queryReactor.AddParameter("chat_t", room.RoomData.ChatType); queryReactor.AddParameter("chat_b", room.RoomData.ChatBalloon); queryReactor.AddParameter("chat_s", room.RoomData.ChatSpeed); queryReactor.AddParameter("chat_m", room.RoomData.ChatMaxDistance); queryReactor.AddParameter("chat_f", room.RoomData.ChatFloodProtection); queryReactor.RunQuery(); } Room junkRoom; if (!LoadedRooms.TryRemove(room.RoomId, out junkRoom)) { return; } Out.WriteLine(string.Format("Room '{0}' [{1}] was unloaded! Reason: " + reason, room.RoomData.Name, room.RoomId), "", ConsoleColor.DarkGray); foreach (var current in room.GetRoomUserManager().UserList.Values.Where(current => current != null)) { if (current.IsPet) { using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery("UPDATE bots SET x=@x, y=@y, z=@z WHERE id=@id LIMIT 1;"); queryReactor.AddParameter("x", current.X); queryReactor.AddParameter("y", current.Y); queryReactor.AddParameter("z", current.Z); queryReactor.AddParameter("id", current.PetData.PetId); queryReactor.RunQuery(); current.BotAI.Dispose(); } } else if (current.IsBot) { using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery( "UPDATE bots SET x=@x, y=@y, z=@z, name=@name, motto=@motto, look=@look, rotation=@rotation, dance=@dance WHERE id=@id LIMIT 1;"); queryReactor.AddParameter("name", current.BotData.Name); queryReactor.AddParameter("motto", current.BotData.Motto); queryReactor.AddParameter("look", current.BotData.Look); queryReactor.AddParameter("rotation", current.BotData.Rot); queryReactor.AddParameter("dance", current.BotData.DanceId); queryReactor.AddParameter("x", current.X); queryReactor.AddParameter("y", current.Y); queryReactor.AddParameter("z", current.Z); queryReactor.AddParameter("id", current.BotData.BotId); queryReactor.RunQuery(); } current.BotAI.Dispose(); } else { if (current.GetClient() == null) { continue; } room.GetRoomUserManager().RemoveUserFromRoom(current.GetClient(), true, false); current.GetClient().CurrentRoomUserId = -1; } } lock (room.RoomData.RoomChat) { foreach (Chatlog Chat in room.RoomData.RoomChat) { Chat.Save(room.RoomId); } } room.Destroy(); }