/// <summary> /// Composes the specified session. /// </summary> /// <param name="session">The session.</param> /// <param name="quest">The quest.</param> /// <returns>ServerMessage.</returns> internal static ServerMessage Compose(GameClient session, Quest quest) { var amountOfQuestsInCategory = Yupi.GetGame().GetQuestManager().GetAmountOfQuestsInCategory(quest.Category); var i = quest == null ? amountOfQuestsInCategory : quest.Number; var i2 = quest == null ? 0 : session.GetHabbo().GetQuestProgress(quest.Id); var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("QuestCompletedMessageComposer")); serverMessage.AppendString(quest.Category); serverMessage.AppendInteger(i); serverMessage.AppendInteger(quest.Name.Contains("xmas2012") ? 1 : amountOfQuestsInCategory); serverMessage.AppendInteger(quest == null ? 3 : quest.RewardType); serverMessage.AppendInteger(quest == null ? 0 : quest.Id); serverMessage.AppendBool(quest != null && session.GetHabbo().CurrentQuestId == quest.Id); serverMessage.AppendString(quest == null ? string.Empty : quest.ActionName); serverMessage.AppendString(quest == null ? string.Empty : quest.DataBit); serverMessage.AppendInteger(quest == null ? 0 : quest.Reward); serverMessage.AppendString(quest == null ? string.Empty : quest.Name); serverMessage.AppendInteger(i2); serverMessage.AppendInteger(quest == null ? 0u : quest.GoalData); serverMessage.AppendInteger(quest == null ? 0 : quest.TimeUnlock); serverMessage.AppendString(""); serverMessage.AppendString(""); serverMessage.AppendBool(true); serverMessage.AppendBool(true); return serverMessage; }
/// <summary> /// Composes the index. /// </summary> /// <param name="rank">The rank.</param> /// <param name="type">The type.</param> /// <returns>ServerMessage.</returns> internal static ServerMessage ComposeIndex(uint rank, string type) { IEnumerable<CatalogPage> pages = Yupi.GetGame().GetCatalogManager().Categories.Values.OfType<CatalogPage>().ToList(); IOrderedEnumerable<CatalogPage> sortedPages = pages.Where(x => x.ParentId == -2 && x.MinRank <= rank).OrderBy(x => x.OrderNum); if (type == "NORMAL") sortedPages = pages.Where(x => x.ParentId == -1 && x.MinRank <= rank).OrderBy(x => x.OrderNum); ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("CatalogueIndexMessageComposer")); message.AppendBool(true); message.AppendInteger(0); message.AppendInteger(-1); message.AppendString("root"); message.AppendString(string.Empty); message.AppendInteger(0); message.AppendInteger(sortedPages.Count()); foreach (CatalogPage cat in sortedPages) { message.AppendBool(cat.Visible); message.AppendInteger(cat.IconImage); message.AppendInteger(cat.PageId); message.AppendString(cat.CodeName); message.AppendString(cat.Caption); message.AppendInteger(cat.FlatOffers.Count); foreach (uint i in cat.FlatOffers.Keys) message.AppendInteger(i); IOrderedEnumerable<CatalogPage> sortedSubPages = pages.Where(x => x.ParentId == cat.PageId && x.MinRank <= rank).OrderBy(x => x.OrderNum); message.AppendInteger(sortedSubPages.Count()); foreach (CatalogPage subCat in sortedSubPages) { message.AppendBool(subCat.Visible); message.AppendInteger(subCat.IconImage); message.AppendInteger(subCat.PageId); message.AppendString(subCat.CodeName); message.AppendString(subCat.Caption); message.AppendInteger(subCat.FlatOffers.Count); foreach (uint i2 in subCat.FlatOffers.Keys) message.AppendInteger(i2); message.AppendInteger(0); } } message.AppendBool(false); message.AppendString(type); return message; }
/// <summary> /// Searializes the specified reply. /// </summary> /// <param name="reply">The reply.</param> internal void Searialize(ServerMessage reply) { reply.AppendInteger(UserId); reply.AppendString(UserName); reply.AppendString(Motto); reply.AppendBool(Yupi.GetGame().GetClientManager().GetClient(UserId) != null); reply.AppendBool(false); reply.AppendString(string.Empty); reply.AppendInteger(0); reply.AppendString(Look); reply.AppendString(LastOnline); }
internal static void GenerateMessage(Pet pet) { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("RespectPetComposer")); serverMessage.AppendInteger(pet.VirtualId); serverMessage.AppendBool(true); pet.Room.SendMessage(serverMessage); }
internal void Serialize(ref ServerMessage message) { Habbo habbo = Yupi.GetHabboById(UserId); message.AppendInteger(Yupi.DifferenceInMilliSeconds(TimeStamp, DateTime.Now)); message.AppendInteger(UserId); message.AppendString(habbo == null ? "*User not found*" : habbo.UserName); message.AppendString(Message); message.AppendBool(GlobalMessage); }
/// <summary> /// Composes the specified session. /// </summary> /// <param name="session">The session.</param> /// <param name="quests">The quests.</param> /// <param name="send">if set to <c>true</c> [send].</param> /// <returns>ServerMessage.</returns> internal static ServerMessage Compose(GameClient session, List<Quest> quests, bool send) { var dictionary = new Dictionary<string, int>(); var dictionary2 = new Dictionary<string, Quest>(); foreach (var current in quests) { if (!current.Category.Contains("xmas2012")) { if (!dictionary.ContainsKey(current.Category)) { dictionary.Add(current.Category, 1); dictionary2.Add(current.Category, null); } if (current.Number >= dictionary[current.Category]) { var questProgress = session.GetHabbo().GetQuestProgress(current.Id); if (session.GetHabbo().CurrentQuestId != current.Id && questProgress >= current.GoalData) { dictionary[current.Category] = current.Number + 1; } } } } foreach (var current2 in quests) { foreach (var current3 in dictionary) { if (!current2.Category.Contains("xmas2012") && current2.Category == current3.Key && current2.Number == current3.Value) { dictionary2[current3.Key] = current2; break; } } } var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("QuestListMessageComposer")); serverMessage.AppendInteger(dictionary2.Count); foreach (var current4 in dictionary2) { if (current4.Value != null) { SerializeQuest(serverMessage, session, current4.Value, current4.Key); } } foreach (var current5 in dictionary2) { if (current5.Value == null) { SerializeQuest(serverMessage, session, current5.Value, current5.Key); } } serverMessage.AppendBool(send); return serverMessage; }
/// <summary> /// Serializes the promotions result list flatcats. /// </summary> /// <param name="flatCatId">The flat cat identifier.</param> /// <param name="direct">if set to <c>true</c> [direct].</param> /// <param name="message">The message.</param> internal static void SerializePromotionsResultListFlatcats(int flatCatId, bool direct, ServerMessage message) { PublicCategory flatCat = Yupi.GetGame().GetNavigator().GetFlatCat(flatCatId); message.AppendString("new_ads"); message.AppendString(flatCat.Caption); message.AppendInteger(0); message.AppendBool(true); message.AppendInteger(-1); KeyValuePair<RoomData, uint>[] rooms = Yupi.GetGame().GetRoomManager().GetEventRooms(); Yupi.GetGame().GetNavigator().SerializeNavigatorPopularRoomsNews(ref message, rooms, flatCatId, direct); }
/// <summary> /// Serializes the search result list flatcats. /// </summary> /// <param name="flatCatId">The flat cat identifier.</param> /// <param name="direct">if set to <c>true</c> [direct].</param> /// <param name="message">The message.</param> internal static void SerializeSearchResultListFlatcats(int flatCatId, bool direct, ServerMessage message) { PublicCategory flatCat = Yupi.GetGame().GetNavigator().GetFlatCat(flatCatId); if (flatCat == null) return; message.AppendString($"category__{flatCat.Caption}"); message.AppendString(flatCat.Caption); message.AppendInteger(0); message.AppendBool(true); message.AppendInteger(-1); KeyValuePair<RoomData, uint>[] rooms = Yupi.GetGame().GetRoomManager().GetActiveRooms(); Yupi.GetGame().GetNavigator().SerializeNavigatorPopularRoomsNews(ref message, rooms, flatCatId, direct); }
/// <summary> /// Gets the packet. /// </summary> /// <returns>ServerMessage.</returns> internal ServerMessage GetPacket() { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("EffectsInventoryMessageComposer")); serverMessage.AppendInteger(_effects.Count); foreach (AvatarEffect current in _effects) { serverMessage.AppendInteger(current.EffectId); serverMessage.AppendInteger(current.Type); serverMessage.AppendInteger(current.TotalDuration); serverMessage.AppendInteger(0); serverMessage.AppendInteger(current.TimeLeft); serverMessage.AppendBool(current.TotalDuration == -1); } return serverMessage; }
/// <summary> /// Composes the specified achievement. /// </summary> /// <param name="achievement">The achievement.</param> /// <param name="level">The level.</param> /// <param name="pointReward">The point reward.</param> /// <param name="pixelReward">The pixel reward.</param> /// <returns>ServerMessage.</returns> internal static ServerMessage Compose(Achievement achievement, uint level, uint pointReward, uint pixelReward) { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("UnlockAchievementMessageComposer")); serverMessage.AppendInteger(achievement.Id); serverMessage.AppendInteger(level); serverMessage.AppendInteger(144); serverMessage.AppendString($"{achievement.GroupName}{level}"); serverMessage.AppendInteger(pointReward); serverMessage.AppendInteger(pixelReward); serverMessage.AppendInteger(0); serverMessage.AppendInteger(10); serverMessage.AppendInteger(21); serverMessage.AppendString(level > 1 ? $"{achievement.GroupName}{level - 1}" : string.Empty); serverMessage.AppendString(achievement.Category); serverMessage.AppendBool(true); return serverMessage; }
/// <summary> /// Composes the specified achievement. /// </summary> /// <param name="achievement">The achievement.</param> /// <param name="targetLevel">The target level.</param> /// <param name="targetLevelData">The target level data.</param> /// <param name="totalLevels">The total levels.</param> /// <param name="userData">The user data.</param> /// <returns>ServerMessage.</returns> internal static ServerMessage Compose(Achievement achievement, uint targetLevel, AchievementLevel targetLevelData, uint totalLevels, UserAchievement userData) { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("AchievementProgressMessageComposer")); serverMessage.AppendInteger(achievement.Id); serverMessage.AppendInteger(targetLevel); serverMessage.AppendString($"{achievement.GroupName}{targetLevel}"); serverMessage.AppendInteger(targetLevelData.Requirement); serverMessage.AppendInteger(targetLevelData.Requirement); serverMessage.AppendInteger(targetLevelData.RewardPixels); serverMessage.AppendInteger(0); serverMessage.AppendInteger(userData.Progress); serverMessage.AppendBool(userData.Level >= totalLevels); serverMessage.AppendString(achievement.Category); serverMessage.AppendString(string.Empty); serverMessage.AppendInteger(totalLevels); serverMessage.AppendInteger(0); return serverMessage; }
/// <summary> /// Composes the specified session. /// </summary> /// <param name="session">The session.</param> /// <param name="achievements">The achievements.</param> /// <returns>ServerMessage.</returns> internal static ServerMessage Compose(GameClient session, List<Achievement> achievements) { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("AchievementListMessageComposer")); serverMessage.AppendInteger(achievements.Count); foreach (Achievement achievement in achievements) { UserAchievement achievementData = session.GetHabbo().GetAchievementData(achievement.GroupName); uint i = achievementData?.Level + 1 ?? 1; uint count = (uint) achievement.Levels.Count; if (i > count) i = count; AchievementLevel achievementLevel = achievement.Levels[i]; AchievementLevel oldLevel = achievement.Levels.ContainsKey(i - 1) ? achievement.Levels[i - 1] : achievementLevel; serverMessage.AppendInteger(achievement.Id); serverMessage.AppendInteger(i); serverMessage.AppendString($"{achievement.GroupName}{i}"); serverMessage.AppendInteger(oldLevel.Requirement); serverMessage.AppendInteger(achievementLevel.Requirement); serverMessage.AppendInteger(achievementLevel.RewardPoints); serverMessage.AppendInteger(0); serverMessage.AppendInteger(achievementData?.Progress ?? 0); serverMessage.AppendBool(!(achievementData == null || achievementData.Level < count)); serverMessage.AppendString(achievement.Category); serverMessage.AppendString(string.Empty); serverMessage.AppendInteger(count); serverMessage.AppendInteger(0); } serverMessage.AppendString(string.Empty); return serverMessage; }
/// <summary> /// Serializes the quest. /// </summary> /// <param name="message">The message.</param> /// <param name="session">The session.</param> /// <param name="quest">The quest.</param> /// <param name="category">The category.</param> internal static void SerializeQuest(ServerMessage message, GameClient session, Quest quest, string category) { if (message == null || session == null) { return; } var amountOfQuestsInCategory = Yupi.GetGame().GetQuestManager().GetAmountOfQuestsInCategory(category); { var num = quest == null ? amountOfQuestsInCategory : quest.Number - 1; var num2 = quest == null ? 0 : session.GetHabbo().GetQuestProgress(quest.Id); if (quest != null && quest.IsCompleted(num2)) { num++; } message.AppendString(category); message.AppendInteger(quest == null ? 0 : (quest.Category.Contains("xmas2012") ? 0 : num)); message.AppendInteger(quest == null ? 0 : (quest.Category.Contains("xmas2012") ? 0 : amountOfQuestsInCategory)); message.AppendInteger(quest?.RewardType ?? 3); message.AppendInteger(quest?.Id ?? 0); message.AppendBool(quest != null && session.GetHabbo().CurrentQuestId == quest.Id); message.AppendString(quest == null ? string.Empty : quest.ActionName); message.AppendString(quest == null ? string.Empty : quest.DataBit); message.AppendInteger(quest?.Reward ?? 0); message.AppendString(quest == null ? string.Empty : quest.Name); message.AppendInteger(num2); message.AppendInteger(quest?.GoalData ?? 0u); message.AppendInteger(quest?.TimeUnlock ?? 0); message.AppendString(string.Empty); message.AppendString(string.Empty); message.AppendBool(true); } }
public override void OnTrigger(GameClient session, RoomItem item, int request, bool hasRights) { if (session == null || item?.GetRoom() == null || !hasRights) return; IWiredItem wired = item.GetRoom().GetWiredHandler().GetWired(item); if (wired == null) return; string extraInfo = wired.OtherString; bool flag = wired.OtherBool; int delay = wired.Delay/500; List<RoomItem> list = wired.Items.Where(roomItem => roomItem != null).ToList(); string extraString = wired.OtherExtraString; string extraString2 = wired.OtherExtraString2; switch (item.GetBaseItem().InteractionType) { case Interaction.TriggerTimer: { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer")); serverMessage.AppendBool(false); serverMessage.AppendInteger(5); serverMessage.AppendInteger(list.Count); foreach (RoomItem current in list) serverMessage.AppendInteger(current.Id); serverMessage.AppendInteger(item.GetBaseItem().SpriteId); serverMessage.AppendInteger(item.Id); serverMessage.AppendString(extraInfo); serverMessage.AppendInteger(1); serverMessage.AppendInteger(delay); serverMessage.AppendInteger(1); serverMessage.AppendInteger(3); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); session.SendMessage(serverMessage); return; } case Interaction.TriggerRoomEnter: { ServerMessage serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer")); serverMessage2.AppendBool(false); serverMessage2.AppendInteger(0); serverMessage2.AppendInteger(list.Count); foreach (RoomItem current2 in list) serverMessage2.AppendInteger(current2.Id); serverMessage2.AppendInteger(item.GetBaseItem().SpriteId); serverMessage2.AppendInteger(item.Id); serverMessage2.AppendString(extraInfo); serverMessage2.AppendInteger(0); serverMessage2.AppendInteger(0); serverMessage2.AppendInteger(7); serverMessage2.AppendInteger(0); serverMessage2.AppendInteger(0); serverMessage2.AppendInteger(0); session.SendMessage(serverMessage2); return; } case Interaction.TriggerGameEnd: { ServerMessage serverMessage3 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer")); serverMessage3.AppendBool(false); serverMessage3.AppendInteger(0); serverMessage3.AppendInteger(list.Count); foreach (RoomItem current3 in list) serverMessage3.AppendInteger(current3.Id); serverMessage3.AppendInteger(item.GetBaseItem().SpriteId); serverMessage3.AppendInteger(item.Id); serverMessage3.AppendString(extraInfo); serverMessage3.AppendInteger(0); serverMessage3.AppendInteger(0); serverMessage3.AppendInteger(8); serverMessage3.AppendInteger(0); serverMessage3.AppendInteger(0); serverMessage3.AppendInteger(0); session.SendMessage(serverMessage3); return; } case Interaction.TriggerGameStart: { ServerMessage serverMessage4 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer")); serverMessage4.AppendBool(false); serverMessage4.AppendInteger(0); serverMessage4.AppendInteger(list.Count); foreach (RoomItem current4 in list) serverMessage4.AppendInteger(current4.Id); serverMessage4.AppendInteger(item.GetBaseItem().SpriteId); serverMessage4.AppendInteger(item.Id); serverMessage4.AppendString(extraInfo); serverMessage4.AppendInteger(0); serverMessage4.AppendInteger(0); serverMessage4.AppendInteger(8); serverMessage4.AppendInteger(0); serverMessage4.AppendInteger(0); serverMessage4.AppendInteger(0); session.SendMessage(serverMessage4); return; } case Interaction.TriggerLongRepeater: { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer")); serverMessage.AppendBool(false); serverMessage.AppendInteger(5); serverMessage.AppendInteger(0); serverMessage.AppendInteger(item.GetBaseItem().SpriteId); serverMessage.AppendInteger(item.Id); serverMessage.AppendString(""); serverMessage.AppendInteger(1); serverMessage.AppendInteger(delay/10); //fix serverMessage.AppendInteger(0); serverMessage.AppendInteger(12); serverMessage.AppendInteger(0); session.SendMessage(serverMessage); return; } case Interaction.TriggerRepeater: { ServerMessage serverMessage5 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer")); serverMessage5.AppendBool(false); serverMessage5.AppendInteger(5); serverMessage5.AppendInteger(list.Count); foreach (RoomItem current5 in list) serverMessage5.AppendInteger(current5.Id); serverMessage5.AppendInteger(item.GetBaseItem().SpriteId); serverMessage5.AppendInteger(item.Id); serverMessage5.AppendString(extraInfo); serverMessage5.AppendInteger(1); serverMessage5.AppendInteger(delay); serverMessage5.AppendInteger(0); serverMessage5.AppendInteger(6); serverMessage5.AppendInteger(0); serverMessage5.AppendInteger(0); session.SendMessage(serverMessage5); return; } case Interaction.TriggerOnUserSay: { ServerMessage serverMessage6 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer")); serverMessage6.AppendBool(false); serverMessage6.AppendInteger(0); serverMessage6.AppendInteger(list.Count); foreach (RoomItem current6 in list) serverMessage6.AppendInteger(current6.Id); serverMessage6.AppendInteger(item.GetBaseItem().SpriteId); serverMessage6.AppendInteger(item.Id); serverMessage6.AppendString(extraInfo); serverMessage6.AppendInteger(0); serverMessage6.AppendInteger(0); serverMessage6.AppendInteger(0); serverMessage6.AppendInteger(0); serverMessage6.AppendInteger(0); serverMessage6.AppendInteger(0); session.SendMessage(serverMessage6); return; } case Interaction.TriggerScoreAchieved: { ServerMessage serverMessage7 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer")); serverMessage7.AppendBool(false); serverMessage7.AppendInteger(5); serverMessage7.AppendInteger(0); serverMessage7.AppendInteger(item.GetBaseItem().SpriteId); serverMessage7.AppendInteger(item.Id); serverMessage7.AppendString(""); serverMessage7.AppendInteger(1); serverMessage7.AppendInteger(string.IsNullOrWhiteSpace(extraInfo) ? 100 : int.Parse(extraInfo)); serverMessage7.AppendInteger(0); serverMessage7.AppendInteger(10); serverMessage7.AppendInteger(0); serverMessage7.AppendInteger(0); session.SendMessage(serverMessage7); return; } case Interaction.TriggerStateChanged: { ServerMessage serverMessage8 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer")); serverMessage8.AppendBool(false); serverMessage8.AppendInteger(5); serverMessage8.AppendInteger(list.Count); foreach (RoomItem current8 in list) serverMessage8.AppendInteger(current8.Id); serverMessage8.AppendInteger(item.GetBaseItem().SpriteId); serverMessage8.AppendInteger(item.Id); serverMessage8.AppendString(extraInfo); serverMessage8.AppendInteger(0); serverMessage8.AppendInteger(0); serverMessage8.AppendInteger(1); serverMessage8.AppendInteger(delay); serverMessage8.AppendInteger(0); serverMessage8.AppendInteger(0); session.SendMessage(serverMessage8); return; } case Interaction.TriggerWalkOnFurni: { ServerMessage serverMessage9 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer")); serverMessage9.AppendBool(false); serverMessage9.AppendInteger(5); serverMessage9.AppendInteger(list.Count); foreach (RoomItem current9 in list) serverMessage9.AppendInteger(current9.Id); serverMessage9.AppendInteger(item.GetBaseItem().SpriteId); serverMessage9.AppendInteger(item.Id); serverMessage9.AppendString(extraInfo); serverMessage9.AppendInteger(0); serverMessage9.AppendInteger(0); serverMessage9.AppendInteger(1); serverMessage9.AppendInteger(0); serverMessage9.AppendInteger(0); serverMessage9.AppendInteger(0); session.SendMessage(serverMessage9); return; } case Interaction.ActionMuteUser: { ServerMessage serverMessage18 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage18.AppendBool(false); serverMessage18.AppendInteger(5); serverMessage18.AppendInteger(0); serverMessage18.AppendInteger(item.GetBaseItem().SpriteId); serverMessage18.AppendInteger(item.Id); serverMessage18.AppendString(extraInfo); serverMessage18.AppendInteger(1); serverMessage18.AppendInteger(delay); serverMessage18.AppendInteger(0); serverMessage18.AppendInteger(20); serverMessage18.AppendInteger(0); serverMessage18.AppendInteger(0); session.SendMessage(serverMessage18); return; } case Interaction.TriggerWalkOffFurni: { ServerMessage serverMessage10 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer")); serverMessage10.AppendBool(false); serverMessage10.AppendInteger(5); serverMessage10.AppendInteger(list.Count); foreach (RoomItem current10 in list) serverMessage10.AppendInteger(current10.Id); serverMessage10.AppendInteger(item.GetBaseItem().SpriteId); serverMessage10.AppendInteger(item.Id); serverMessage10.AppendString(extraInfo); serverMessage10.AppendInteger(0); serverMessage10.AppendInteger(0); serverMessage10.AppendInteger(1); serverMessage10.AppendInteger(0); serverMessage10.AppendInteger(0); serverMessage10.AppendInteger(0); serverMessage10.AppendInteger(0); session.SendMessage(serverMessage10); return; } case Interaction.TriggerCollision: { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer")); serverMessage.AppendBool(false); serverMessage.AppendInteger(5); serverMessage.AppendInteger(0); serverMessage.AppendInteger(item.GetBaseItem().SpriteId); serverMessage.AppendInteger(item.Id); serverMessage.AppendString(string.Empty); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); serverMessage.AppendInteger(11); serverMessage.AppendInteger(0); session.SendMessage(serverMessage); return; } case Interaction.ActionGiveScore: { // Por hacer. ServerMessage serverMessage11 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage11.AppendBool(false); serverMessage11.AppendInteger(5); serverMessage11.AppendInteger(0); serverMessage11.AppendInteger(item.GetBaseItem().SpriteId); serverMessage11.AppendInteger(item.Id); serverMessage11.AppendString(""); serverMessage11.AppendInteger(2); if (string.IsNullOrWhiteSpace(extraInfo)) { serverMessage11.AppendInteger(10); // Puntos a dar serverMessage11.AppendInteger(1); // Numero de veces por equipo } else { string[] integers = extraInfo.Split(','); serverMessage11.AppendInteger(int.Parse(integers[0])); // Puntos a dar serverMessage11.AppendInteger(int.Parse(integers[1])); // Numero de veces por equipo } serverMessage11.AppendInteger(0); serverMessage11.AppendInteger(6); serverMessage11.AppendInteger(0); serverMessage11.AppendInteger(0); serverMessage11.AppendInteger(0); session.SendMessage(serverMessage11); return; } case Interaction.ConditionGroupMember: case Interaction.ConditionNotGroupMember: { ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer")); message.AppendBool(false); message.AppendInteger(5); message.AppendInteger(0); message.AppendInteger(item.GetBaseItem().SpriteId); message.AppendInteger(item.Id); message.AppendString(""); message.AppendInteger(0); message.AppendInteger(0); message.AppendInteger(10); session.SendMessage(message); return; } case Interaction.ConditionItemsMatches: case Interaction.ConditionItemsDontMatch: { ServerMessage serverMessage21 = new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer")); serverMessage21.AppendBool(false); serverMessage21.AppendInteger(5); serverMessage21.AppendInteger(list.Count); foreach (RoomItem current20 in list) serverMessage21.AppendInteger(current20.Id); serverMessage21.AppendInteger(item.GetBaseItem().SpriteId); serverMessage21.AppendInteger(item.Id); serverMessage21.AppendString(extraString2); serverMessage21.AppendInteger(3); if (string.IsNullOrWhiteSpace(extraInfo) || !extraInfo.Contains(",")) { serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(0); } else { string[] boolz = extraInfo.Split(','); foreach (string stringy in boolz) serverMessage21.AppendInteger(stringy.ToLower() == "true" ? 1 : 0); } serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(0); session.SendMessage(serverMessage21); return; } case Interaction.ActionPosReset: { ServerMessage serverMessage12 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage12.AppendBool(false); serverMessage12.AppendInteger(5); serverMessage12.AppendInteger(list.Count); foreach (RoomItem current12 in list) serverMessage12.AppendInteger(current12.Id); serverMessage12.AppendInteger(item.GetBaseItem().SpriteId); serverMessage12.AppendInteger(item.Id); serverMessage12.AppendString(extraString2); serverMessage12.AppendInteger(3); if (string.IsNullOrWhiteSpace(extraInfo)) { serverMessage12.AppendInteger(0); serverMessage12.AppendInteger(0); serverMessage12.AppendInteger(0); } else { string[] boolz = extraInfo.Split(','); foreach (string stringy in boolz) serverMessage12.AppendInteger(stringy.ToLower() == "true" ? 1 : 0); } serverMessage12.AppendInteger(0); serverMessage12.AppendInteger(3); serverMessage12.AppendInteger(delay); // Delay serverMessage12.AppendInteger(0); session.SendMessage(serverMessage12); return; } case Interaction.ActionMoveRotate: { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage.AppendBool(false); serverMessage.AppendInteger(5); serverMessage.AppendInteger(list.Count(roomItem => roomItem != null)); foreach (RoomItem roomItem in list.Where(roomItem => roomItem != null)) serverMessage.AppendInteger(roomItem.Id); serverMessage.AppendInteger(item.GetBaseItem().SpriteId); serverMessage.AppendInteger(item.Id); serverMessage.AppendString(string.Empty); serverMessage.AppendInteger(2); serverMessage.AppendIntegersArray(extraInfo, ';', 2); serverMessage.AppendInteger(0); serverMessage.AppendInteger(4); serverMessage.AppendInteger(delay); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); session.SendMessage(serverMessage); } break; case Interaction.ActionMoveToDir: { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage.AppendBool(false); serverMessage.AppendInteger(5); serverMessage.AppendInteger(list.Count(roomItem => roomItem != null)); foreach (RoomItem roomItem in list.Where(roomItem => roomItem != null)) serverMessage.AppendInteger(roomItem.Id); serverMessage.AppendInteger(item.GetBaseItem().SpriteId); serverMessage.AppendInteger(item.Id); serverMessage.AppendString(string.Empty); serverMessage.AppendInteger(2); serverMessage.AppendIntegersArray(extraInfo, ';', 2); serverMessage.AppendInteger(0); serverMessage.AppendInteger(13); serverMessage.AppendInteger(delay); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); session.SendMessage(serverMessage); } break; case Interaction.ActionResetTimer: { ServerMessage serverMessage14 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage14.AppendBool(false); serverMessage14.AppendInteger(0); serverMessage14.AppendInteger(0); serverMessage14.AppendInteger(item.GetBaseItem().SpriteId); serverMessage14.AppendInteger(item.Id); serverMessage14.AppendString(extraInfo); serverMessage14.AppendInteger(0); serverMessage14.AppendInteger(0); serverMessage14.AppendInteger(1); serverMessage14.AppendInteger(delay); serverMessage14.AppendInteger(0); serverMessage14.AppendInteger(0); session.SendMessage(serverMessage14); return; } case Interaction.ActionShowMessage: case Interaction.ActionKickUser: case Interaction.ActionEffectUser: { ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage15.AppendBool(false); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(list.Count); foreach (RoomItem current15 in list) serverMessage15.AppendInteger(current15.Id); serverMessage15.AppendInteger(item.GetBaseItem().SpriteId); serverMessage15.AppendInteger(item.Id); serverMessage15.AppendString(extraInfo); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(7); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); session.SendMessage(serverMessage15); return; } case Interaction.ActionTeleportTo: { ServerMessage serverMessage16 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage16.AppendBool(false); serverMessage16.AppendInteger(5); serverMessage16.AppendInteger(list.Count); foreach (RoomItem roomItem in list) serverMessage16.AppendInteger(roomItem.Id); serverMessage16.AppendInteger(item.GetBaseItem().SpriteId); serverMessage16.AppendInteger(item.Id); serverMessage16.AppendString(extraInfo); serverMessage16.AppendInteger(0); serverMessage16.AppendInteger(8); serverMessage16.AppendInteger(0); serverMessage16.AppendInteger(delay); serverMessage16.AppendInteger(0); serverMessage16.AppendByte(2); session.SendMessage(serverMessage16); return; } case Interaction.ActionToggleState: { ServerMessage serverMessage17 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage17.AppendBool(false); serverMessage17.AppendInteger(5); serverMessage17.AppendInteger(list.Count); foreach (RoomItem current17 in list) serverMessage17.AppendInteger(current17.Id); serverMessage17.AppendInteger(item.GetBaseItem().SpriteId); serverMessage17.AppendInteger(item.Id); serverMessage17.AppendString(extraInfo); serverMessage17.AppendInteger(0); serverMessage17.AppendInteger(8); serverMessage17.AppendInteger(0); serverMessage17.AppendInteger(delay); serverMessage17.AppendInteger(0); serverMessage17.AppendInteger(0); session.SendMessage(serverMessage17); return; } case Interaction.ActionGiveReward: { if (!session.GetHabbo().HasFuse("fuse_use_superwired")) return; ServerMessage serverMessage18 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage18.AppendBool(false); serverMessage18.AppendInteger(5); serverMessage18.AppendInteger(0); serverMessage18.AppendInteger(item.GetBaseItem().SpriteId); serverMessage18.AppendInteger(item.Id); serverMessage18.AppendString(extraInfo); serverMessage18.AppendInteger(3); serverMessage18.AppendInteger(extraString == "" ? 0 : int.Parse(extraString)); serverMessage18.AppendInteger(flag ? 1 : 0); serverMessage18.AppendInteger(extraString2 == "" ? 0 : int.Parse(extraString2)); serverMessage18.AppendInteger(0); serverMessage18.AppendInteger(17); serverMessage18.AppendInteger(0); serverMessage18.AppendInteger(0); session.SendMessage(serverMessage18); return; } case Interaction.ConditionHowManyUsersInRoom: case Interaction.ConditionNegativeHowManyUsers: { ServerMessage serverMessage19 = new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer")); serverMessage19.AppendBool(false); serverMessage19.AppendInteger(5); serverMessage19.AppendInteger(0); serverMessage19.AppendInteger(item.GetBaseItem().SpriteId); serverMessage19.AppendInteger(item.Id); serverMessage19.AppendString(""); serverMessage19.AppendInteger(2); if (string.IsNullOrWhiteSpace(extraInfo)) { serverMessage19.AppendInteger(1); serverMessage19.AppendInteger(50); } else foreach (string integers in extraInfo.Split(',')) serverMessage19.AppendInteger(int.Parse(integers)); serverMessage19.AppendBool(false); serverMessage19.AppendInteger(0); serverMessage19.AppendInteger(1290); session.SendMessage(serverMessage19); return; } case Interaction.ConditionFurnisHaveUsers: case Interaction.ConditionStatePos: case Interaction.ConditionTriggerOnFurni: case Interaction.ConditionFurniTypeMatches: case Interaction.ConditionFurnisHaveNotUsers: case Interaction.ConditionFurniTypeDontMatch: case Interaction.ConditionTriggererNotOnFurni: { ServerMessage serverMessage19 = new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer")); serverMessage19.AppendBool(false); serverMessage19.AppendInteger(5); serverMessage19.AppendInteger(list.Count); foreach (RoomItem current18 in list) serverMessage19.AppendInteger(current18.Id); serverMessage19.AppendInteger(item.GetBaseItem().SpriteId); serverMessage19.AppendInteger(item.Id); serverMessage19.AppendInteger(0); serverMessage19.AppendInteger(0); serverMessage19.AppendInteger(0); serverMessage19.AppendBool(false); serverMessage19.AppendBool(true); session.SendMessage(serverMessage19); return; } case Interaction.ConditionFurniHasNotFurni: case Interaction.ConditionFurniHasFurni: { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer")); serverMessage.AppendBool(false); serverMessage.AppendInteger(5); serverMessage.AppendInteger(list.Count); foreach (RoomItem current18 in list) serverMessage.AppendInteger(current18.Id); serverMessage.AppendInteger(item.GetBaseItem().SpriteId); serverMessage.AppendInteger(item.Id); serverMessage.AppendString(string.Empty); serverMessage.AppendInteger(1); serverMessage.AppendInteger(flag); //bool serverMessage.AppendInteger(0); serverMessage.AppendInteger(item.GetBaseItem().InteractionType == Interaction.ConditionFurniHasFurni ? 7 : 18); session.SendMessage(serverMessage); return; } case Interaction.ConditionTimeLessThan: case Interaction.ConditionTimeMoreThan: { ServerMessage serverMessage21 = new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer")); serverMessage21.AppendBool(false); serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(item.GetBaseItem().SpriteId); serverMessage21.AppendInteger(item.Id); serverMessage21.AppendString(""); serverMessage21.AppendInteger(1); serverMessage21.AppendInteger(delay); //delay serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(item.GetBaseItem().InteractionType == Interaction.ConditionTimeMoreThan ? 3 : 4); session.SendMessage(serverMessage21); return; } case Interaction.ConditionUserWearingEffect: case Interaction.ConditionUserNotWearingEffect: { int effect; int.TryParse(extraInfo, out effect); ServerMessage serverMessage21 = new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer")); serverMessage21.AppendBool(false); serverMessage21.AppendInteger(5); serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(item.GetBaseItem().SpriteId); serverMessage21.AppendInteger(item.Id); serverMessage21.AppendString(""); serverMessage21.AppendInteger(1); serverMessage21.AppendInteger(effect); serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(12); session.SendMessage(serverMessage21); return; } case Interaction.ConditionUserWearingBadge: case Interaction.ConditionUserNotWearingBadge: case Interaction.ConditionUserHasFurni: { ServerMessage serverMessage21 = new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer")); serverMessage21.AppendBool(false); serverMessage21.AppendInteger(5); serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(item.GetBaseItem().SpriteId); serverMessage21.AppendInteger(item.Id); serverMessage21.AppendString(extraInfo); serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(11); session.SendMessage(serverMessage21); return; } case Interaction.ConditionDateRangeActive: { int date1 = 0; int date2 = 0; try { string[] strArray = extraInfo.Split(','); date1 = int.Parse(strArray[0]); date2 = int.Parse(strArray[1]); } catch { } ServerMessage serverMessage21 = new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer")); serverMessage21.AppendBool(false); serverMessage21.AppendInteger(5); serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(item.GetBaseItem().SpriteId); serverMessage21.AppendInteger(item.Id); serverMessage21.AppendString(extraInfo); serverMessage21.AppendInteger(2); serverMessage21.AppendInteger(date1); serverMessage21.AppendInteger(date2); serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(24); session.SendMessage(serverMessage21); return; } case Interaction.ActionJoinTeam: { ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage15.AppendBool(false); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(item.GetBaseItem().SpriteId); serverMessage15.AppendInteger(item.Id); serverMessage15.AppendString(extraInfo); serverMessage15.AppendInteger(1); serverMessage15.AppendInteger(delay); // Team (1-4) serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(9); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); session.SendMessage(serverMessage15); return; } case Interaction.ActionLeaveTeam: { ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage15.AppendBool(false); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(item.GetBaseItem().SpriteId); serverMessage15.AppendInteger(item.Id); serverMessage15.AppendString(extraInfo); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(10); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); session.SendMessage(serverMessage15); return; } case Interaction.TriggerBotReachedAvatar: { ServerMessage serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer")); serverMessage2.AppendBool(false); serverMessage2.AppendInteger(0); serverMessage2.AppendInteger(list.Count); foreach (RoomItem current2 in list) serverMessage2.AppendInteger(current2.Id); serverMessage2.AppendInteger(item.GetBaseItem().SpriteId); serverMessage2.AppendInteger(item.Id); serverMessage2.AppendString(extraInfo); serverMessage2.AppendInteger(0); serverMessage2.AppendInteger(0); serverMessage2.AppendInteger(14); serverMessage2.AppendInteger(0); serverMessage2.AppendInteger(0); serverMessage2.AppendInteger(0); session.SendMessage(serverMessage2); return; } case Interaction.TriggerBotReachedStuff: { ServerMessage serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer")); serverMessage2.AppendBool(false); serverMessage2.AppendInteger(5); serverMessage2.AppendInteger(list.Count); foreach (RoomItem current2 in list) serverMessage2.AppendInteger(current2.Id); serverMessage2.AppendInteger(item.GetBaseItem().SpriteId); serverMessage2.AppendInteger(item.Id); serverMessage2.AppendString(extraInfo); serverMessage2.AppendInteger(0); serverMessage2.AppendInteger(0); serverMessage2.AppendInteger(13); serverMessage2.AppendInteger(0); serverMessage2.AppendInteger(0); serverMessage2.AppendInteger(0); session.SendMessage(serverMessage2); return; } case Interaction.ActionBotClothes: { ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage15.AppendBool(false); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(item.GetBaseItem().SpriteId); serverMessage15.AppendInteger(item.Id); serverMessage15.AppendString(extraInfo + (char) 9 + extraString); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(26); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); session.SendMessage(serverMessage15); return; } case Interaction.ActionBotFollowAvatar: { ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage15.AppendBool(false); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(item.GetBaseItem().SpriteId); serverMessage15.AppendInteger(item.Id); serverMessage15.AppendString(extraInfo); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(25); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); session.SendMessage(serverMessage15); return; } case Interaction.ActionBotGiveHanditem: { ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage15.AppendBool(false); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(item.GetBaseItem().SpriteId); serverMessage15.AppendInteger(item.Id); serverMessage15.AppendString(extraInfo); serverMessage15.AppendInteger(1); serverMessage15.AppendInteger(delay); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(24); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); session.SendMessage(serverMessage15); return; } case Interaction.ActionBotMove: { ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage15.AppendBool(false); serverMessage15.AppendInteger(5); serverMessage15.AppendInteger(list.Count); foreach (RoomItem current2 in list) serverMessage15.AppendInteger(current2.Id); serverMessage15.AppendInteger(item.GetBaseItem().SpriteId); serverMessage15.AppendInteger(item.Id); serverMessage15.AppendString(extraInfo); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(22); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); session.SendMessage(serverMessage15); return; } case Interaction.ActionBotTalk: { ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage15.AppendBool(false); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(item.GetBaseItem().SpriteId); serverMessage15.AppendInteger(item.Id); serverMessage15.AppendString(extraInfo + (char) 9 + extraString); serverMessage15.AppendInteger(1); serverMessage15.AppendInteger(Yupi.BoolToInteger(flag)); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(23); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); session.SendMessage(serverMessage15); return; } case Interaction.ActionBotTalkToAvatar: { ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage15.AppendBool(false); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(item.GetBaseItem().SpriteId); serverMessage15.AppendInteger(item.Id); serverMessage15.AppendString(extraInfo + (char) 9 + extraString); serverMessage15.AppendInteger(1); serverMessage15.AppendInteger(Yupi.BoolToInteger(flag)); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(27); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); session.SendMessage(serverMessage15); return; } case Interaction.ActionBotTeleport: { ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage15.AppendBool(false); serverMessage15.AppendInteger(5); serverMessage15.AppendInteger(list.Count); foreach (RoomItem current2 in list) serverMessage15.AppendInteger(current2.Id); serverMessage15.AppendInteger(item.GetBaseItem().SpriteId); serverMessage15.AppendInteger(item.Id); serverMessage15.AppendString(extraInfo); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(21); serverMessage15.AppendInteger(0); serverMessage15.AppendInteger(0); session.SendMessage(serverMessage15); return; } case Interaction.ActionChase: { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage.AppendBool(false); serverMessage.AppendInteger(5); serverMessage.AppendInteger(list.Count); foreach (RoomItem roomItem in list) serverMessage.AppendInteger(roomItem.Id); serverMessage.AppendInteger(item.GetBaseItem().SpriteId); serverMessage.AppendInteger(item.Id); serverMessage.AppendString(string.Empty); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); serverMessage.AppendInteger(11); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); session.SendMessage(serverMessage); return; } case Interaction.ConditionUserHasHanditem: { ServerMessage serverMessage21 = new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer")); serverMessage21.AppendBool(false); serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(item.GetBaseItem().SpriteId); serverMessage21.AppendInteger(item.Id); serverMessage21.AppendString(extraInfo); serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(0); serverMessage21.AppendInteger(25); session.SendMessage(serverMessage21); return; } case Interaction.ActionCallStacks: { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage.AppendBool(false); serverMessage.AppendInteger(5); serverMessage.AppendInteger(list.Count); foreach (RoomItem current15 in list) serverMessage.AppendInteger(current15.Id); serverMessage.AppendInteger(item.GetBaseItem().SpriteId); serverMessage.AppendInteger(item.Id); serverMessage.AppendString(extraInfo); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); serverMessage.AppendInteger(18); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); session.SendMessage(serverMessage); return; } case Interaction.ArrowPlate: case Interaction.PressurePad: case Interaction.PressurePadBed: case Interaction.RingPlate: case Interaction.ColorTile: case Interaction.ColorWheel: case Interaction.FloorSwitch1: case Interaction.FloorSwitch2: break; case Interaction.SpecialRandom: { ServerMessage serverMessage24 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage24.AppendBool(false); serverMessage24.AppendInteger(5); serverMessage24.AppendInteger(list.Count); foreach (RoomItem current23 in list) serverMessage24.AppendInteger(current23.Id); serverMessage24.AppendInteger(item.GetBaseItem().SpriteId); serverMessage24.AppendInteger(item.Id); serverMessage24.AppendString(extraInfo); serverMessage24.AppendInteger(0); serverMessage24.AppendInteger(8); serverMessage24.AppendInteger(0); serverMessage24.AppendInteger(0); serverMessage24.AppendInteger(0); serverMessage24.AppendInteger(0); session.SendMessage(serverMessage24); return; } case Interaction.SpecialUnseen: { ServerMessage serverMessage25 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer")); serverMessage25.AppendBool(false); serverMessage25.AppendInteger(5); serverMessage25.AppendInteger(list.Count); foreach (RoomItem current24 in list) serverMessage25.AppendInteger(current24.Id); serverMessage25.AppendInteger(item.GetBaseItem().SpriteId); serverMessage25.AppendInteger(item.Id); serverMessage25.AppendString(extraInfo); serverMessage25.AppendInteger(0); serverMessage25.AppendInteger(8); serverMessage25.AppendInteger(0); serverMessage25.AppendInteger(0); serverMessage25.AppendInteger(0); serverMessage25.AppendInteger(0); session.SendMessage(serverMessage25); return; } default: return; } }
/// <summary> /// Serializes the theGroup information. /// </summary> /// <param name="group">The theGroup.</param> /// <param name="response">The response.</param> /// <param name="session">The session.</param> /// <param name="room">The room.</param> /// <param name="newWindow">if set to <c>true</c> [new window].</param> internal void SerializeGroupInfo(Group group, ServerMessage response, GameClient session, Room room, bool newWindow = false) { if (room == null || group == null) return; DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); DateTime dateTime2 = dateTime.AddSeconds(group.CreateTime); response.Init(LibraryParser.OutgoingRequest("GroupDataMessageComposer")); response.AppendInteger(group.Id); response.AppendBool(true); response.AppendInteger(group.State); response.AppendString(group.Name); response.AppendString(group.Description); response.AppendString(group.Badge); response.AppendInteger(group.RoomId); response.AppendString(Yupi.GetGame().GetRoomManager().GenerateRoomData(@group.RoomId) == null ? "No room found.." : Yupi.GetGame().GetRoomManager().GenerateRoomData(group.RoomId).Name); response.AppendInteger(@group.CreatorId == session.GetHabbo().Id ? 3 : (group.Requests.ContainsKey(session.GetHabbo().Id) ? 2 : (group.Members.ContainsKey(session.GetHabbo().Id) ? 1 : 0))); response.AppendInteger(group.Members.Count); response.AppendBool(session.GetHabbo().FavouriteGroup == group.Id); response.AppendString($"{dateTime2.Day.ToString("00")}-{dateTime2.Month.ToString("00")}-{dateTime2.Year}"); response.AppendBool(group.CreatorId == session.GetHabbo().Id); response.AppendBool(group.Admins.ContainsKey(session.GetHabbo().Id)); response.AppendString(Yupi.GetHabboById(@group.CreatorId) == null ? string.Empty : Yupi.GetHabboById(group.CreatorId).UserName); response.AppendBool(newWindow); response.AppendBool(group.AdminOnlyDeco == 0u); response.AppendInteger(group.Requests.Count); response.AppendBool(group.Forum.Id != 0); room.SendMessage(response); }
/// <summary> /// Serializes the theGroup members. /// </summary> /// <param name="response">The response.</param> /// <param name="theGroup">The theGroup.</param> /// <param name="reqType">Type of the req.</param> /// <param name="session">The session.</param> /// <param name="searchVal">The search value.</param> /// <param name="page">The page.</param> /// <returns>ServerMessage.</returns> internal ServerMessage SerializeGroupMembers(ServerMessage response, Group theGroup, uint reqType, GameClient session, string searchVal = "", int page = 0) { if (theGroup == null || session == null) return null; if (page < 1) page = 0; response.AppendInteger(theGroup.Id); response.AppendString(theGroup.Name); response.AppendInteger(theGroup.RoomId); response.AppendString(theGroup.Badge); List<GroupMember> groupList = GetGroupUsersByString(theGroup, searchVal, reqType); if(groupList != null) { List<List<GroupMember>> list = Split(groupList); if(list != null) { if (reqType == 0) { response.AppendInteger(list.Count); if (theGroup.Members.Count > 0 && list.Count > 0 && list[page] != null) { response.AppendInteger(list[page].Count); using (List<GroupMember>.Enumerator enumerator = list[page].GetEnumerator()) { while (enumerator.MoveNext()) { GroupMember current = enumerator.Current; AddGroupMemberIntoResponse(response, current); } } } else response.AppendInteger(0); } else if (reqType == 1) { response.AppendInteger(theGroup.Admins.Count); List<GroupMember> paging = page <= list.Count ? list[page] : null; if ((theGroup.Admins.Count > 0) && (list.Count > 0) && paging != null) { response.AppendInteger(list[page].Count); using (List<GroupMember>.Enumerator enumerator = list[page].GetEnumerator()) { while (enumerator.MoveNext()) { GroupMember current = enumerator.Current; AddGroupMemberIntoResponse(response, current); } } } else response.AppendInteger(0); } else if (reqType == 2) { response.AppendInteger(theGroup.Requests.Count); if (theGroup.Requests.Count > 0 && list.Count > 0 && list[page] != null) { response.AppendInteger(list[page].Count); using (List<GroupMember>.Enumerator enumerator = list[page].GetEnumerator()) { while (enumerator.MoveNext()) { GroupMember current = enumerator.Current; response.AppendInteger(3); if (current != null) { response.AppendInteger(current.Id); response.AppendString(current.Name); response.AppendString(current.Look); } response.AppendString(string.Empty); } } } else response.AppendInteger(0); } } else response.AppendInteger(0); } else response.AppendInteger(0); response.AppendBool(session.GetHabbo().Id == theGroup.CreatorId); response.AppendInteger(14); response.AppendInteger(page); response.AppendInteger(reqType); response.AppendString(searchVal); return response; }
/// <summary> /// Serializes the update. /// </summary> /// <param name="friend">The friend.</param> /// <returns>ServerMessage.</returns> internal ServerMessage SerializeUpdate(MessengerBuddy friend) { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("FriendUpdateMessageComposer")); serverMessage.AppendInteger(0); serverMessage.AppendInteger(1); serverMessage.AppendInteger(0); friend.Serialize(serverMessage, GetClient()); serverMessage.AppendBool(false); return serverMessage; }
/// <summary> /// Updates the user status. /// </summary> /// <param name="user">The user.</param> /// <param name="cycleGameItems">if set to <c>true</c> [cyclegameitems].</param> internal void UpdateUserStatus(RoomUser user, bool cycleGameItems) { if (user == null) return; if (user.Statusses.ContainsKey("lay") || user.Statusses.ContainsKey("sit")) { user.Statusses.Remove("lay"); user.Statusses.Remove("sit"); user.UpdateNeeded = true; } bool isBot = user.IsBot; if (isBot) cycleGameItems = false; try { Gamemap roomMap = _userRoom.GetGameMap(); Point userPoint = new Point(user.X, user.Y); RoomItem[] allRoomItemForSquare = roomMap.GetCoordinatedHeighestItems(userPoint).ToArray(); List<RoomItem> itemsOnSquare = roomMap.GetCoordinatedItems(userPoint); double newZ = _userRoom.GetGameMap().SqAbsoluteHeight(user.X, user.Y, itemsOnSquare) + (user.RidingHorse && user.IsPet == false ? 1 : 0); if (Math.Abs(newZ - user.Z) > 0) { user.Z = newZ; user.UpdateNeeded = true; } foreach (RoomItem item in allRoomItemForSquare) { if (cycleGameItems) { item.UserWalksOnFurni(user); } if (item.GetBaseItem().IsSeat) { if (!user.Statusses.ContainsKey("sit")) { if (item.GetBaseItem().StackMultipler && !string.IsNullOrWhiteSpace(item.ExtraData)) if (item.ExtraData != "0") { int num2 = Convert.ToInt32(item.ExtraData); if (!user.Statusses.ContainsKey("sit")) user.Statusses.Add("sit", item.GetBaseItem().ToggleHeight[num2].ToString(CultureInfo.InvariantCulture) .Replace(',', '.')); } else { if (!user.Statusses.ContainsKey("sit")) user.Statusses.Add("sit", Convert.ToString(item.GetBaseItem().Height, CultureInfo.InvariantCulture)); } else { if (!user.Statusses.ContainsKey("sit")) user.Statusses.Add("sit", Convert.ToString(item.GetBaseItem().Height, CultureInfo.InvariantCulture)); } } if (Math.Abs(user.Z - item.Z) > 0 || user.RotBody != item.Rot) { user.Z = item.Z; user.RotHead = item.Rot; user.RotBody = item.Rot; user.UpdateNeeded = true; } } Interaction interactionType = item.GetBaseItem().InteractionType; switch (interactionType) { case Interaction.QuickTeleport: case Interaction.GuildGate: case Interaction.WalkInternalLink: { item.Interactor.OnUserWalk(user.GetClient(), item, user); break; } case Interaction.None: break; case Interaction.PressurePadBed: case Interaction.Bed: { if (!user.Statusses.ContainsKey("lay")) user.Statusses.Add("lay", ServerUserChatTextHandler.GetString(item.GetBaseItem().Height)); else { if (user.Statusses["lay"] != ServerUserChatTextHandler.GetString(item.GetBaseItem().Height)) user.Statusses["lay"] = ServerUserChatTextHandler.GetString(item.GetBaseItem().Height); } user.Z = item.Z; user.RotHead = item.Rot; user.RotBody = item.Rot; user.UpdateNeeded = true; if (item.GetBaseItem().InteractionType == Interaction.PressurePadBed) { item.ExtraData = "1"; item.UpdateState(); } break; } case Interaction.Guillotine: { if (!user.Statusses.ContainsKey("lay")) user.Statusses.Add("lay", ServerUserChatTextHandler.GetString(item.GetBaseItem().Height)); else if (user.Statusses["lay"] != ServerUserChatTextHandler.GetString(item.GetBaseItem().Height)) user.Statusses["lay"] = ServerUserChatTextHandler.GetString(item.GetBaseItem().Height); user.Z = item.Z; user.RotBody = item.Rot; item.ExtraData = "1"; item.UpdateState(); AvatarEffectComponent avatarEffectsInventoryComponent = user.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent(); avatarEffectsInventoryComponent.ActivateCustomEffect(133); break; } case Interaction.FootballGate: break; case Interaction.BanzaiGateBlue: case Interaction.BanzaiGateRed: case Interaction.BanzaiGateYellow: case Interaction.BanzaiGateGreen: { int effect = (int) item.Team + 32; TeamManager teamManagerForBanzai = user.GetClient().GetHabbo().CurrentRoom.GetTeamManagerForBanzai(); AvatarEffectComponent avatarEffectsInventoryComponent = user.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent(); if (user.Team == Team.None) { if (!teamManagerForBanzai.CanEnterOnTeam(item.Team)) break; if (user.Team != Team.None) teamManagerForBanzai.OnUserLeave(user); user.Team = item.Team; teamManagerForBanzai.AddUser(user); if (avatarEffectsInventoryComponent.CurrentEffect != effect) avatarEffectsInventoryComponent.ActivateCustomEffect(effect); break; } if (user.Team != Team.None && user.Team != item.Team) { teamManagerForBanzai.OnUserLeave(user); user.Team = Team.None; avatarEffectsInventoryComponent.ActivateCustomEffect(0); break; } teamManagerForBanzai.OnUserLeave(user); if (avatarEffectsInventoryComponent.CurrentEffect == effect) avatarEffectsInventoryComponent.ActivateCustomEffect(0); user.Team = Team.None; break; } case Interaction.Jump: break; case Interaction.Pinata: { if (!user.IsWalking || item.ExtraData.Length <= 0) break; int num5 = int.Parse(item.ExtraData); if (num5 >= 100 || user.CurrentEffect != 158) break; int num6 = num5 + 1; item.ExtraData = num6.ToString(); item.UpdateState(); Yupi.GetGame() .GetAchievementManager() .ProgressUserAchievement(user.GetClient(), "ACH_PinataWhacker", 1); if (num6 == 100) { Yupi.GetGame().GetPinataHandler().DeliverRandomPinataItem(user, _userRoom, item); Yupi.GetGame() .GetAchievementManager() .ProgressUserAchievement(user.GetClient(), "ACH_PinataBreaker", 1); } break; } case Interaction.TileStackMagic: case Interaction.Poster: break; case Interaction.Tent: case Interaction.BedTent: if (user.LastItem == item.Id) break; if (!user.IsBot && !user.OnCampingTent) { ServerMessage serverMessage22 = new ServerMessage(); serverMessage22.Init( LibraryParser.OutgoingRequest("UpdateFloorItemExtraDataMessageComposer")); serverMessage22.AppendString(item.Id.ToString()); serverMessage22.AppendInteger(0); serverMessage22.AppendString("1"); user.GetClient().SendMessage(serverMessage22); user.OnCampingTent = true; user.LastItem = item.Id; } break; case Interaction.RunWaySage: { int num7 = new Random().Next(1, 4); item.ExtraData = num7.ToString(); item.UpdateState(); break; } case Interaction.Shower: case Interaction.ChairState: case Interaction.PressurePad: { item.ExtraData = "1"; item.UpdateState(); break; } case Interaction.BanzaiTele: { if (user.IsWalking) _userRoom.GetGameItemHandler().OnTeleportRoomUserEnter(user, item); break; } case Interaction.FreezeYellowGate: case Interaction.FreezeRedGate: case Interaction.FreezeGreenGate: case Interaction.FreezeBlueGate: { if (cycleGameItems) { int num4 = (int) (item.Team + 39); TeamManager teamManagerForFreeze = user.GetClient().GetHabbo().CurrentRoom.GetTeamManagerForFreeze(); AvatarEffectComponent avatarEffectsInventoryComponent2 = user.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent(); if (user.Team != item.Team) { if (teamManagerForFreeze.CanEnterOnTeam(item.Team)) { if (user.Team != Team.None) teamManagerForFreeze.OnUserLeave(user); user.Team = item.Team; teamManagerForFreeze.AddUser(user); if (avatarEffectsInventoryComponent2.CurrentEffect != num4) avatarEffectsInventoryComponent2.ActivateCustomEffect(num4); } } else { teamManagerForFreeze.OnUserLeave(user); if (avatarEffectsInventoryComponent2.CurrentEffect == num4) avatarEffectsInventoryComponent2.ActivateCustomEffect(0); user.Team = Team.None; } ServerMessage serverMessage33 = new ServerMessage( LibraryParser.OutgoingRequest("UserIsPlayingFreezeMessageComposer")); serverMessage33.AppendBool(user.Team != Team.None); user.GetClient().SendMessage(serverMessage33); } break; } } if (item.GetBaseItem().InteractionType == Interaction.BedTent) user.OnCampingTent = true; user.LastItem = item.Id; } if (user.IsSitting && user.TeleportEnabled) { user.Z -= 0.35; user.UpdateNeeded = true; } if (cycleGameItems) { _userRoom.GetSoccer().OnUserWalk(user); _userRoom.GetBanzai().OnUserWalk(user); _userRoom.GetFreeze().OnUserWalk(user); } } catch (Exception e) { ServerLogManager.HandleException(e, "RoomUserManager.cs:UpdateUserStatus"); } }
/// <summary> /// Removes the user from room. /// </summary> /// <param name="session">The session.</param> /// <param name="notifyClient">if set to <c>true</c> [notify client].</param> /// <param name="notifyKick">if set to <c>true</c> [notify kick].</param> internal void RemoveUserFromRoom(GameClient session, bool notifyClient, bool notifyKick) { try { if (session == null || session.GetHabbo() == null || _userRoom == null) return; uint userId = session.GetHabbo().Id; session.GetHabbo().GetAvatarEffectsInventoryComponent().OnRoomExit(); //using (var queryReactor = Yupi.GetDatabaseManager().GetQueryReactor()) // queryReactor.RunFastQuery("UPDATE users_rooms_visits SET exit_timestamp = '" + Yupi.GetUnixTimeStamp() + "' WHERE room_id = '" + _room.RoomId + "' AND user_id = '" + session.GetHabbo().Id + "' ORDER BY entry_timestamp DESC LIMIT 1"); RoomUser roomUserByHabbo = GetRoomUserByHabbo(userId); if (roomUserByHabbo == null) return; if (notifyKick) { Room room = Yupi.GetGame().GetRoomManager().GetRoom(roomUserByHabbo.RoomId); DynamicRoomModel model = room.GetGameMap().Model; roomUserByHabbo.MoveTo(model.DoorX, model.DoorY); roomUserByHabbo.CanWalk = false; session.GetMessageHandler() .GetResponse() .Init(LibraryParser.OutgoingRequest("RoomErrorMessageComposer")); session.GetMessageHandler().GetResponse().AppendInteger(4008); session.GetMessageHandler().SendResponse(); session.GetMessageHandler() .GetResponse() .Init(LibraryParser.OutgoingRequest("OutOfRoomMessageComposer")); session.GetMessageHandler().GetResponse().AppendShort(2); session.GetMessageHandler().SendResponse(); } else if (notifyClient) { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("UserIsPlayingFreezeMessageComposer")); serverMessage.AppendBool(roomUserByHabbo.Team != Team.None); roomUserByHabbo.GetClient().SendMessage(serverMessage); session.GetMessageHandler() .GetResponse() .Init(LibraryParser.OutgoingRequest("OutOfRoomMessageComposer")); session.GetMessageHandler().GetResponse().AppendShort(2); session.GetMessageHandler().SendResponse(); } if (roomUserByHabbo.Team != Team.None) { _userRoom.GetTeamManagerForBanzai().OnUserLeave(roomUserByHabbo); _userRoom.GetTeamManagerForFreeze().OnUserLeave(roomUserByHabbo); } if (roomUserByHabbo.RidingHorse) { roomUserByHabbo.RidingHorse = false; RoomUser horse = GetRoomUserByVirtualId((int) roomUserByHabbo.HorseId); if (horse != null) { horse.RidingHorse = false; horse.HorseId = 0u; } } if (roomUserByHabbo.IsLyingDown || roomUserByHabbo.IsSitting) { roomUserByHabbo.IsSitting = false; roomUserByHabbo.IsLyingDown = false; } RemoveRoomUser(roomUserByHabbo); if (session.GetHabbo() != null && !roomUserByHabbo.IsSpectator) { if (roomUserByHabbo.CurrentItemEffect != ItemEffectType.None) roomUserByHabbo.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().CurrentEffect = -1; if (session.GetHabbo() != null) { if (_userRoom.HasActiveTrade(session.GetHabbo().Id)) _userRoom.TryStopTrade(session.GetHabbo().Id); session.GetHabbo().CurrentRoomId = 0; if (session.GetHabbo().GetMessenger() != null) session.GetHabbo().GetMessenger().OnStatusChanged(true); } using (IQueryAdapter queryreactor2 = Yupi.GetDatabaseManager().GetQueryReactor()) if (session.GetHabbo() != null) queryreactor2.RunFastQuery(string.Concat( "UPDATE users_rooms_visits SET exit_timestamp = '", Yupi.GetUnixTimeStamp(), "' WHERE room_id = '", _userRoom.RoomId, "' AND user_id = '", userId, "' ORDER BY exit_timestamp DESC LIMIT 1")); } UsersByUserId.Remove(roomUserByHabbo.UserId); if (session.GetHabbo() != null) UsersByUserName.Remove(session.GetHabbo().UserName.ToLower()); roomUserByHabbo.Dispose(); } catch (Exception ex) { ServerLogManager.LogCriticalException($"Error during removing user from room:{ex}"); } }
internal void UserRoomTimeCycles(RoomUser roomUsers) { if (!roomUsers.IsAsleep && (roomUsers.IdleTime >= 600) && !roomUsers.IsBot && !roomUsers.IsPet) { roomUsers.IsAsleep = true; ServerMessage sleepEffectMessage = new ServerMessage(LibraryParser.OutgoingRequest("RoomUserIdleMessageComposer")); sleepEffectMessage.AppendInteger(roomUsers.VirtualId); sleepEffectMessage.AppendBool(true); _userRoom.SendMessage(sleepEffectMessage); } if (!roomUsers.IsOwner() && (roomUsers.IdleTime >= 300) && !roomUsers.IsBot && !roomUsers.IsPet) { try { GameClient ownerAchievementMessage = Yupi.GetGame().GetClientManager().GetClientByUserId((uint) _userRoom.RoomData.OwnerId); if (ownerAchievementMessage != null) Yupi.GetGame() .GetAchievementManager() .ProgressUserAchievement(ownerAchievementMessage, "ACH_RoomDecoHosting", 1, true); } catch (Exception) { // ignored } } }
/// <summary> /// Serializes the tool. /// </summary> /// <param name="session">The session.</param> /// <returns>ServerMessage.</returns> internal ServerMessage SerializeTool(GameClient session) { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("LoadModerationToolMessageComposer")); serverMessage.AppendInteger(Tickets.Count); foreach (SupportTicket current in Tickets) current.Serialize(serverMessage); serverMessage.AppendInteger(UserMessagePresets.Count); foreach (string current2 in UserMessagePresets) serverMessage.AppendString(current2); IEnumerable<ModerationTemplate> enumerable = (from x in ModerationTemplates.Values where x.Category == -1 select x).ToArray(); serverMessage.AppendInteger(enumerable.Count()); using (IEnumerator<ModerationTemplate> enumerator3 = enumerable.GetEnumerator()) { bool first = true; while (enumerator3.MoveNext()) { ModerationTemplate template = enumerator3.Current; IEnumerable<ModerationTemplate> enumerable2 = (from x in ModerationTemplates.Values where x.Category == (long) (ulong) template.Id select x) .ToArray(); serverMessage.AppendString(template.CName); serverMessage.AppendBool(first); serverMessage.AppendInteger(enumerable2.Count()); foreach (ModerationTemplate current3 in enumerable2) { serverMessage.AppendString(current3.Caption); serverMessage.AppendString(current3.BanMessage); serverMessage.AppendInteger(current3.BanHours); serverMessage.AppendInteger(Yupi.BoolToInteger(current3.AvatarBan)); serverMessage.AppendInteger(Yupi.BoolToInteger(current3.Mute)); serverMessage.AppendInteger(Yupi.BoolToInteger(current3.TradeLock)); serverMessage.AppendString(current3.WarningMessage); serverMessage.AppendBool(true); } first = false; } } // but = button serverMessage.AppendBool(true); //ticket_queue_but serverMessage.AppendBool(session.GetHabbo().HasFuse("fuse_chatlogs")); //chatlog_but serverMessage.AppendBool(session.GetHabbo().HasFuse("fuse_alert")); //message_but serverMessage.AppendBool(true); //modaction_but serverMessage.AppendBool(session.GetHabbo().HasFuse("fuse_ban")); //ban_but serverMessage.AppendBool(true); serverMessage.AppendBool(session.GetHabbo().HasFuse("fuse_kick")); //kick_but serverMessage.AppendInteger(RoomMessagePresets.Count); foreach (string current4 in RoomMessagePresets) serverMessage.AppendString(current4); return serverMessage; }
/// <summary> /// Serializes the user chatlog. /// </summary> /// <param name="userId">The user identifier.</param> /// <returns>ServerMessage.</returns> internal static ServerMessage SerializeUserChatlog(uint userId) { ServerMessage result; using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor()) { commitableQueryReactor.SetQuery($"SELECT DISTINCT room_id FROM users_chatlogs WHERE user_id = '{userId}' ORDER BY timestamp DESC LIMIT 4"); DataTable table = commitableQueryReactor.GetTable(); ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ModerationToolUserChatlogMessageComposer")); serverMessage.AppendInteger(userId); serverMessage.AppendString(Yupi.GetGame().GetClientManager().GetNameById(userId)); if (table != null) { serverMessage.AppendInteger(table.Rows.Count); IEnumerator enumerator = table.Rows.GetEnumerator(); try { while (enumerator.MoveNext()) { DataRow dataRow = (DataRow) enumerator.Current; commitableQueryReactor.SetQuery($"SELECT user_id,timestamp,message FROM users_chatlogs WHERE room_id = {dataRow["room_id"]} AND user_id = {userId} ORDER BY timestamp DESC LIMIT 30"); DataTable table2 = commitableQueryReactor.GetTable(); RoomData roomData = Yupi.GetGame().GetRoomManager().GenerateRoomData((uint) dataRow["room_id"]); if (table2 != null) { serverMessage.AppendByte(1); serverMessage.AppendShort(2); serverMessage.AppendString("roomName"); serverMessage.AppendByte(2); serverMessage.AppendString(roomData == null ? "This room was deleted" : roomData.Name); serverMessage.AppendString("roomId"); serverMessage.AppendByte(1); serverMessage.AppendInteger((uint) dataRow["room_id"]); serverMessage.AppendShort(table2.Rows.Count); IEnumerator enumerator2 = table2.Rows.GetEnumerator(); try { while (enumerator2.MoveNext()) { DataRow dataRow2 = (DataRow) enumerator2.Current; Habbo habboForId = Yupi.GetHabboById((uint) dataRow2["user_id"]); Yupi.UnixToDateTime((double) dataRow2["timestamp"]); if (habboForId == null) return null; serverMessage.AppendInteger( (int) (Yupi.GetUnixTimeStamp() - (double) dataRow2["timestamp"])); serverMessage.AppendInteger(habboForId.Id); serverMessage.AppendString(habboForId.UserName); serverMessage.AppendString(dataRow2["message"].ToString()); serverMessage.AppendBool(false); } continue; } finally { IDisposable disposable = enumerator2 as IDisposable; disposable?.Dispose(); } } serverMessage.AppendByte(1); serverMessage.AppendShort(0); serverMessage.AppendShort(0); } result = serverMessage; return result; } finally { IDisposable disposable2 = enumerator as IDisposable; disposable2?.Dispose(); } } serverMessage.AppendInteger(0); result = serverMessage; } return result; }
/// <summary> /// Composes the item. /// </summary> /// <param name="item">The item.</param> /// <param name="message">The message.</param> internal static void ComposeItem(CatalogItem item, ServerMessage message) { message.AppendInteger(item.Id); string displayName = item.Name; if (PetTypeManager.ItemIsPet(item.Name)) displayName = PetTypeManager.GetHabboPetType(item.Name); message.AppendString(displayName, true); message.AppendBool(false); message.AppendInteger(item.CreditsCost); if (item.DiamondsCost > 0) { message.AppendInteger(item.DiamondsCost); message.AppendInteger(105); } else { message.AppendInteger(item.DucketsCost); message.AppendInteger(0); } message.AppendBool(item.GetFirstBaseItem().AllowGift); switch (item.Name) { case "g0 group_product": message.AppendInteger(0); break; case "room_ad_plus_badge": message.AppendInteger(1); message.AppendString("b"); message.AppendString("RADZZ"); break; default: if (item.Name.StartsWith("builders_club_addon_") || item.Name.StartsWith("builders_club_time_")) message.AppendInteger(0); else if (item.Badge == "") message.AppendInteger(item.Items.Count); else { message.AppendInteger(item.Items.Count + 1); message.AppendString("b"); message.AppendString(item.Badge); } break; } foreach (Item baseItem in item.Items.Keys) { if (item.Name == "g0 group_product" || item.Name.StartsWith("builders_club_addon_") || item.Name.StartsWith("builders_club_time_")) break; if (item.Name == "room_ad_plus_badge") { message.AppendString(""); message.AppendInteger(0); } else { message.AppendString(baseItem.Type.ToString()); message.AppendInteger(baseItem.SpriteId); if (item.Name.Contains("wallpaper_single") || item.Name.Contains("floor_single") || item.Name.Contains("landscape_single")) { string[] array = item.Name.Split('_'); message.AppendString(array[2]); } else if (item.Name.StartsWith("bot_") || baseItem.InteractionType == Interaction.MusicDisc || item.GetFirstBaseItem().Name == "poster") message.AppendString(item.ExtraData); else if (item.Name.StartsWith("poster_")) { string[] array2 = item.Name.Split('_'); message.AppendString(array2[1]); } else if (item.Name.StartsWith("poster ")) { string[] array3 = item.Name.Split(' '); message.AppendString(array3[1]); } else if (item.SongId > 0u && baseItem.InteractionType == Interaction.MusicDisc) message.AppendString(item.ExtraData); else message.AppendString(string.Empty); message.AppendInteger(item.Items[baseItem]); message.AppendBool(item.IsLimited); if (!item.IsLimited) continue; message.AppendInteger(item.LimitedStack); message.AppendInteger(item.LimitedStack - item.LimitedSelled); } } message.AppendInteger(item.ClubOnly ? 1 : 0); if (item.IsLimited || item.FirstAmount != 1) { message.AppendBool(false); return; } message.AppendBool(item.HaveOffer && !item.IsLimited); }
/// <summary> /// Composes the club purchase page. /// </summary> /// <param name="session">The session.</param> /// <param name="windowId">The window identifier.</param> /// <returns>ServerMessage.</returns> internal static ServerMessage ComposeClubPurchasePage(GameClient session, int windowId) { ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("CatalogueClubPageMessageComposer")); List<CatalogItem> habboClubItems = Yupi.GetGame().GetCatalogManager().HabboClubItems; message.AppendInteger(habboClubItems.Count); foreach (CatalogItem item in habboClubItems) { message.AppendInteger(item.Id); message.AppendString(item.Name); message.AppendBool(false); message.AppendInteger(item.CreditsCost); if (item.DiamondsCost > 0) { message.AppendInteger(item.DiamondsCost); message.AppendInteger(105); } else { message.AppendInteger(item.DucketsCost); message.AppendInteger(0); } message.AppendBool(true); string[] fuckingArray = item.Name.Split('_'); double dayTime = 31; if (item.Name.Contains("DAY")) dayTime = int.Parse(fuckingArray[3]); else if (item.Name.Contains("MONTH")) { int monthTime = int.Parse(fuckingArray[3]); dayTime = monthTime*31; } else if (item.Name.Contains("YEAR")) { int yearTimeOmg = int.Parse(fuckingArray[3]); dayTime = yearTimeOmg*31*12; } DateTime newExpiryDate = DateTime.Now.AddDays(dayTime); if (session.GetHabbo().GetSubscriptionManager().HasSubscription) newExpiryDate = Yupi.UnixToDateTime(session.GetHabbo().GetSubscriptionManager().GetSubscription().ExpireTime) .AddDays(dayTime); message.AppendInteger((int) dayTime/31); message.AppendInteger((int) dayTime); message.AppendBool(false); message.AppendInteger((int) dayTime); message.AppendInteger(newExpiryDate.Year); message.AppendInteger(newExpiryDate.Month); message.AppendInteger(newExpiryDate.Day); } message.AppendInteger(windowId); return message; }
/// <summary> /// Serializes the club. /// </summary> internal void SerializeClub() { GameClient client = GetClient(); ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("SubscriptionStatusMessageComposer")); serverMessage.AppendString("club_habbo"); if (client.GetHabbo().GetSubscriptionManager().HasSubscription) { double num = client.GetHabbo().GetSubscriptionManager().GetSubscription().ExpireTime; double num2 = num - Yupi.GetUnixTimeStamp(); int num3 = (int) Math.Ceiling(num2/86400.0); int i = (int) Math.Ceiling((Yupi.GetUnixTimeStamp() - (double) client.GetHabbo().GetSubscriptionManager().GetSubscription().ActivateTime)/ 86400.0); int num4 = num3/31; if (num4 >= 1) num4--; serverMessage.AppendInteger(num3 - num4*31); serverMessage.AppendInteger(1); serverMessage.AppendInteger(num4); serverMessage.AppendInteger(1); serverMessage.AppendBool(true); serverMessage.AppendBool(true); serverMessage.AppendInteger(i); serverMessage.AppendInteger(i); serverMessage.AppendInteger(10); } else { serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); serverMessage.AppendBool(false); serverMessage.AppendBool(false); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); } client.SendMessage(serverMessage); ServerMessage serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("UserClubRightsMessageComposer")); serverMessage2.AppendInteger(GetSubscriptionManager().HasSubscription ? 2 : 0); serverMessage2.AppendInteger(Rank); serverMessage2.AppendBool(Rank >= Convert.ToUInt32(Yupi.GetDbConfig().DbData["ambassador.minrank"])); client.SendMessage(serverMessage2); }
/// <summary> /// Serializes the search results. /// </summary> /// <param name="searchQuery">The search query.</param> /// <returns>ServerMessage.</returns> public static ServerMessage SerializeSearchResults(string searchQuery) { bool containsOwner = false; bool containsGroup = false; string originalQuery = searchQuery; if (searchQuery.StartsWith("owner:")) { searchQuery = searchQuery.Replace("owner:", string.Empty); containsOwner = true; } else if (searchQuery.StartsWith("group:")) { searchQuery = searchQuery.Replace("group:", string.Empty); containsGroup = true; } List<RoomData> rooms = new List<RoomData>(); if (!containsOwner) { bool initForeach = false; KeyValuePair<RoomData, uint>[] activeRooms = Yupi.GetGame().GetRoomManager().GetActiveRooms(); try { if (activeRooms != null && activeRooms.Any()) initForeach = true; } catch { initForeach = false; } if (initForeach) { foreach (KeyValuePair<RoomData, uint> rms in activeRooms) { if (rms.Key.Name.ToLower().Contains(searchQuery.ToLower()) && rooms.Count <= 50) rooms.Add(rms.Key); else break; } } } if (rooms.Count < 50 || containsOwner || containsGroup) { DataTable dTable; using (IQueryAdapter dbClient = Yupi.GetDatabaseManager().GetQueryReactor()) { if (containsOwner) { dbClient.SetQuery("SELECT rooms_data.* FROM rooms_data LEFT OUTER JOIN users ON rooms_data.owner = users.id WHERE users.username = @query AND rooms_data.roomtype = 'private' LIMIT 50"); dbClient.AddParameter("query", searchQuery); dTable = dbClient.GetTable(); } else if (containsGroup) { dbClient.SetQuery("SELECT * FROM rooms_data JOIN groups_data ON rooms_data.id = groups_data.room_id WHERE groups_data.group_name LIKE @query AND roomtype = 'private' LIMIT 50"); dbClient.AddParameter("query", "%" + searchQuery + "%"); dTable = dbClient.GetTable(); } else { dbClient.SetQuery("SELECT * FROM rooms_data WHERE caption = @query AND roomtype = 'private' LIMIT " + (50 - rooms.Count)); dbClient.AddParameter("query", searchQuery); dTable = dbClient.GetTable(); } } if (dTable != null) { foreach (RoomData rData in dTable.Rows.Cast<DataRow>().Select(row => Yupi.GetGame() .GetRoomManager() .FetchRoomData(Convert.ToUInt32(row["id"]), row)).Where(rData => !rooms.Contains(rData))) rooms.Add(rData); } } ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("NavigatorListingsMessageComposer")); message.AppendInteger(8); message.AppendString(originalQuery); message.AppendInteger(rooms.Count); foreach (RoomData room in rooms) room.Serialize(message); message.AppendBool(false); return message; }
/// <summary> /// Purchases the ok. /// </summary> /// <returns>ServerMessage.</returns> internal static ServerMessage PurchaseOk(uint itemId, string itemName, uint creditsCost, Dictionary<Item, uint> items = null, int clubLevel = 1, uint diamondsCost = 0, uint activityPointsCost = 0, bool isLimited = false, uint limitedStack = 0, uint limitedSelled = 0) { ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("PurchaseOKMessageComposer")); message.AppendInteger(itemId); message.AppendString(itemName); message.AppendBool(false); message.AppendInteger(creditsCost); message.AppendInteger(diamondsCost); message.AppendInteger(activityPointsCost); message.AppendBool(true); message.AppendInteger(items?.Count ?? 0); if (items != null) { foreach (KeyValuePair<Item, uint> itemDic in items) { Item item = itemDic.Key; message.AppendString(item.Type.ToString()); if (item.Type == 'b') { message.AppendString(item.PublicName); continue; } message.AppendInteger(item.SpriteId); message.AppendString(item.PublicName); message.AppendInteger(itemDic.Value); //productCount message.AppendBool(isLimited); if (!isLimited) continue; message.AppendInteger(limitedStack); message.AppendInteger(limitedSelled); } } message.AppendInteger(clubLevel); //clubLevel message.AppendBool(false); //window.visible? return message; }
/// <summary> /// Serializes the room tool. /// </summary> /// <param name="data">The data.</param> /// <returns>ServerMessage.</returns> internal static ServerMessage SerializeRoomTool(RoomData data) { Room room = Yupi.GetGame().GetRoomManager().GetRoom(data.Id); ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ModerationRoomToolMessageComposer")); serverMessage.AppendInteger(data.Id); serverMessage.AppendInteger(data.UsersNow); if (room != null) serverMessage.AppendBool(room.GetRoomUserManager().GetRoomUserByHabbo(data.Owner) != null); else serverMessage.AppendBool(false); serverMessage.AppendInteger(room?.RoomData.OwnerId ?? 0); serverMessage.AppendString(data.Owner); serverMessage.AppendBool(room != null); serverMessage.AppendString(data.Name); serverMessage.AppendString(data.Description); serverMessage.AppendInteger(data.TagCount); foreach (string current in data.Tags) serverMessage.AppendString(current); serverMessage.AppendBool(false); return serverMessage; }
/// <summary> /// Composes the page. /// </summary> /// <param name="page">The page.</param> /// <returns>ServerMessage.</returns> internal static ServerMessage ComposePage(CatalogPage page) { ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("CataloguePageMessageComposer")); message.AppendInteger(page.PageId); switch (page.Layout) { case "frontpage": message.AppendString("NORMAL"); message.AppendString("frontpage4"); message.AppendInteger(2); message.AppendString(page.LayoutHeadline); message.AppendString(page.LayoutTeaser); message.AppendInteger(2); message.AppendString(page.Text1); message.AppendString(page.Text2); message.AppendInteger(0); message.AppendInteger(-1); message.AppendBool(false); break; case "roomads": message.AppendString("NORMAL"); message.AppendString("roomads"); message.AppendInteger(2); message.AppendString("events_header"); message.AppendString(""); message.AppendInteger(2); message.AppendString(page.Text1); message.AppendString(""); break; case "builders_club_frontpage_normal": message.AppendString("NORMAL"); message.AppendString("builders_club_frontpage"); message.AppendInteger(0); message.AppendInteger(1); message.AppendString(page.LayoutHeadline); message.AppendInteger(3); message.AppendInteger(8554); message.AppendString("builders_club_1_month"); message.AppendString(""); message.AppendInteger(2560000); message.AppendInteger(2560000); message.AppendInteger(1024); message.AppendInteger(0); message.AppendInteger(0); message.AppendBool(false); message.AppendInteger(8606); message.AppendString("builders_club_14_days"); message.AppendString(""); message.AppendInteger(2560000); message.AppendInteger(2560000); message.AppendInteger(1024); message.AppendInteger(0); message.AppendInteger(0); message.AppendBool(false); message.AppendInteger(8710); message.AppendString("builders_club_31_days"); message.AppendString(""); message.AppendInteger(2560000); message.AppendInteger(2560000); message.AppendInteger(1024); message.AppendInteger(0); message.AppendInteger(0); message.AppendBool(false); break; case "bots": message.AppendString("NORMAL"); message.AppendString("bots"); message.AppendInteger(2); message.AppendString(page.LayoutHeadline); message.AppendString(page.LayoutTeaser); message.AppendInteger(3); message.AppendString(page.Text1); message.AppendString(page.Text2); message.AppendString(page.TextDetails); break; case "badge_display": message.AppendString("NORMAL"); message.AppendString("badge_display"); message.AppendInteger(2); message.AppendString(page.LayoutHeadline); message.AppendString(page.LayoutTeaser); message.AppendInteger(3); message.AppendString(page.Text1); message.AppendString(page.Text2); message.AppendString(page.TextDetails); break; case "info_loyalty": case "info_duckets": message.AppendString("NORMAL"); message.AppendString(page.Layout); message.AppendInteger(1); message.AppendString(page.LayoutHeadline); message.AppendInteger(1); message.AppendString(page.Text1); break; case "sold_ltd_items": message.AppendString("NORMAL"); message.AppendString("sold_ltd_items"); message.AppendInteger(2); message.AppendString(page.LayoutHeadline); message.AppendString(page.LayoutTeaser); message.AppendInteger(3); message.AppendString(page.Text1); message.AppendString(page.Text2); message.AppendString(page.TextDetails); break; case "recycler_info": message.AppendString("NORMAL"); message.AppendString(page.Layout); message.AppendInteger(2); message.AppendString(page.LayoutHeadline); message.AppendString(page.LayoutTeaser); message.AppendInteger(3); message.AppendString(page.Text1); message.AppendString(page.Text2); message.AppendString(page.TextDetails); break; case "recycler_prizes": message.AppendString("NORMAL"); message.AppendString("recycler_prizes"); message.AppendInteger(1); message.AppendString("catalog_recycler_headline3"); message.AppendInteger(1); message.AppendString(page.Text1); break; case "spaces_new": case "spaces": message.AppendString("NORMAL"); message.AppendString("spaces_new"); message.AppendInteger(1); message.AppendString(page.LayoutHeadline); message.AppendInteger(1); message.AppendString(page.Text1); break; case "recycler": message.AppendString("NORMAL"); message.AppendString("recycler"); message.AppendInteger(2); message.AppendString(page.LayoutHeadline); message.AppendString(page.LayoutTeaser); message.AppendInteger(1); message.AppendString(page.Text1); break; case "trophies": message.AppendString("NORMAL"); message.AppendString("trophies"); message.AppendInteger(1); message.AppendString(page.LayoutHeadline); message.AppendInteger(2); message.AppendString(page.Text1); message.AppendString(page.TextDetails); break; case "pets": case "pets2": case "pets3": message.AppendString("NORMAL"); message.AppendString(page.Layout); message.AppendInteger(2); message.AppendString(page.LayoutHeadline); message.AppendString(page.LayoutTeaser); message.AppendInteger(4); message.AppendString(page.Text1); message.AppendString(page.Text2); message.AppendString(page.TextDetails); message.AppendString(page.TextTeaser); break; case "soundmachine": message.AppendString("NORMAL"); message.AppendString(page.Layout); message.AppendInteger(2); message.AppendString(page.LayoutHeadline); message.AppendString(page.LayoutTeaser); message.AppendInteger(2); message.AppendString(page.Text1); message.AppendString(page.TextDetails); break; case "vip_buy": message.AppendString("NORMAL"); message.AppendString(page.Layout); message.AppendInteger(2); message.AppendString(page.LayoutHeadline); message.AppendString(page.LayoutTeaser); message.AppendInteger(0); break; case "guild_custom_furni": message.AppendString("NORMAL"); message.AppendString("guild_custom_furni"); message.AppendInteger(3); message.AppendString(page.LayoutHeadline); message.AppendString(""); message.AppendString(""); message.AppendInteger(3); message.AppendString(page.Text1); message.AppendString(page.TextDetails); message.AppendString(page.Text2); break; case "guild_frontpage": message.AppendString("NORMAL"); message.AppendString("guild_frontpage"); message.AppendInteger(2); message.AppendString(page.LayoutHeadline); message.AppendString(page.LayoutTeaser); message.AppendInteger(3); message.AppendString(page.Text1); message.AppendString(page.TextDetails); message.AppendString(page.Text2); break; case "guild_forum": message.AppendString("NORMAL"); message.AppendString("guild_forum"); message.AppendInteger(0); message.AppendInteger(2); message.AppendString(page.Text1); message.AppendString(page.Text2); break; case "club_gifts": message.AppendString("NORMAL"); message.AppendString("club_gifts"); message.AppendInteger(1); message.AppendString(page.LayoutHeadline); message.AppendInteger(1); message.AppendString(page.Text1); break; case "default_3x3": message.AppendString("NORMAL"); message.AppendString(page.Layout); message.AppendInteger(3); message.AppendString(page.LayoutHeadline); message.AppendString(page.LayoutTeaser); message.AppendString(page.LayoutSpecial); message.AppendInteger(3); message.AppendString(page.Text1); message.AppendString(page.TextDetails); message.AppendString(page.TextTeaser); break; default: message.AppendString("NORMAL"); message.AppendString(page.Layout); message.AppendInteger(3); message.AppendString(page.LayoutHeadline); message.AppendString(page.LayoutTeaser); message.AppendString(page.LayoutSpecial); message.AppendInteger(4); message.AppendString(page.Text1); message.AppendString(page.Text2); message.AppendString(page.TextTeaser); message.AppendString(page.TextDetails); break; case "builders_3x3": message.AppendString("BUILDERS_CLUB"); message.AppendString("default_3x3"); message.AppendInteger(3); message.AppendString(page.LayoutHeadline); message.AppendString(page.LayoutTeaser); message.AppendString(page.LayoutSpecial); message.AppendInteger(3); message.AppendString(page.Text1); message.AppendString(page.TextDetails.Replace("[10]", Convert.ToChar(10).ToString()) .Replace("[13]", Convert.ToChar(13).ToString())); message.AppendString(page.TextTeaser.Replace("[10]", Convert.ToChar(10).ToString()) .Replace("[13]", Convert.ToChar(13).ToString())); break; case "builders_3x3_color": message.AppendString("BUILDERS_CLUB"); message.AppendString("default_3x3_color_grouping"); message.AppendInteger(3); message.AppendString(page.LayoutHeadline); message.AppendString(page.LayoutTeaser); message.AppendString(page.LayoutSpecial); message.AppendInteger(3); message.AppendString(page.Text1); message.AppendString(page.TextDetails.Replace("[10]", Convert.ToChar(10).ToString()) .Replace("[13]", Convert.ToChar(13).ToString())); message.AppendString(page.TextTeaser.Replace("[10]", Convert.ToChar(10).ToString()) .Replace("[13]", Convert.ToChar(13).ToString())); break; case "builders_club_frontpage": message.AppendString("BUILDERS_CLUB"); message.AppendString("builders_club_frontpage"); message.AppendInteger(0); message.AppendInteger(1); message.AppendString(page.LayoutHeadline); message.AppendInteger(3); message.AppendInteger(8554); message.AppendString("builders_club_1_month"); message.AppendString(""); message.AppendInteger(2560000); message.AppendInteger(2560000); message.AppendInteger(1024); message.AppendInteger(0); message.AppendInteger(0); message.AppendBool(false); message.AppendInteger(8606); message.AppendString("builders_club_14_days"); message.AppendString(""); message.AppendInteger(2560000); message.AppendInteger(2560000); message.AppendInteger(1024); message.AppendInteger(0); message.AppendInteger(0); message.AppendBool(false); message.AppendInteger(8710); message.AppendString("builders_club_31_days"); message.AppendString(""); message.AppendInteger(2560000); message.AppendInteger(2560000); message.AppendInteger(1024); message.AppendInteger(0); message.AppendInteger(0); message.AppendBool(false); break; case "builders_club_addons": message.AppendString("BUILDERS_CLUB"); message.AppendString("builders_club_addons"); message.AppendInteger(0); message.AppendInteger(1); message.AppendString(page.LayoutHeadline); break; case "builders_club_addons_normal": message.AppendString("NORMAL"); message.AppendString("builders_club_addons"); message.AppendInteger(0); message.AppendInteger(1); message.AppendString(page.LayoutHeadline); break; } if (page.Layout.StartsWith("frontpage") || page.Layout == "vip_buy" || page.Layout == "recycler") { message.AppendInteger(0); } else { message.AppendInteger(page.Items.Count); foreach (CatalogItem item in page.Items.Values) ComposeItem(item, message); } message.AppendInteger(-1); message.AppendBool(false); return message; }
/// <summary> /// Serializes the user information. /// </summary> /// <param name="userId">The user identifier.</param> /// <returns>ServerMessage.</returns> /// <exception cref="System.NullReferenceException">User not found in database.</exception> internal static ServerMessage SerializeUserInfo(uint userId) { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ModerationToolUserToolMessageComposer")); using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor()) { if (commitableQueryReactor != null) { commitableQueryReactor.SetQuery( "SELECT id, username, mail, look, trade_lock, trade_lock_expire, rank, ip_last, " + "IFNULL(cfhs, 0) cfhs, IFNULL(cfhs_abusive, 0) cfhs_abusive, IFNULL(cautions, 0) cautions, IFNULL(bans, 0) bans, " + "IFNULL(reg_timestamp, 0) reg_timestamp, IFNULL(login_timestamp, 0) login_timestamp " + $"FROM users left join users_info on (users.id = users_info.user_id) WHERE id = '{userId}' LIMIT 1" ); DataRow row = commitableQueryReactor.GetRow(); uint id = Convert.ToUInt32(row["id"]); serverMessage.AppendInteger(id); serverMessage.AppendString(row["username"].ToString()); serverMessage.AppendString(row["look"].ToString()); double regTimestamp = (double) row["reg_timestamp"]; double loginTimestamp = (double) row["login_timestamp"]; int unixTimestamp = Yupi.GetUnixTimeStamp(); serverMessage.AppendInteger( (int) (regTimestamp > 0 ? Math.Ceiling((unixTimestamp - regTimestamp)/60.0) : regTimestamp)); serverMessage.AppendInteger( (int) (loginTimestamp > 0 ? Math.Ceiling((unixTimestamp - loginTimestamp)/60.0) : loginTimestamp)); serverMessage.AppendBool(true); serverMessage.AppendInteger(Convert.ToInt32(row["cfhs"])); serverMessage.AppendInteger(Convert.ToInt32(row["cfhs_abusive"])); serverMessage.AppendInteger(Convert.ToInt32(row["cautions"])); serverMessage.AppendInteger(Convert.ToInt32(row["bans"])); serverMessage.AppendInteger(0); uint rank = (uint) row["rank"]; serverMessage.AppendString(row["trade_lock"].ToString() == "1" ? Yupi.UnixToDateTime(int.Parse(row["trade_lock_expire"].ToString())).ToLongDateString() : "Not trade-locked"); serverMessage.AppendString(rank < 6 ? row["ip_last"].ToString() : "127.0.0.1"); serverMessage.AppendInteger(id); serverMessage.AppendInteger(0); serverMessage.AppendString($"E-Mail: {row["mail"]}"); serverMessage.AppendString($"Rank ID: {rank}"); } } return serverMessage; }