internal static ServerMessage SerializeUserChatlog(uint UserId) { ServerMessage result; using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor()) { queryreactor.setQuery("SELECT DISTINCT room_id FROM chatlogs WHERE user_id = " + UserId + " ORDER BY timestamp DESC LIMIT 4"); DataTable table = queryreactor.getTable(); ServerMessage serverMessage = new ServerMessage(Outgoing.ModerationToolUserChatlogMessageComposer); serverMessage.AppendUInt(UserId); serverMessage.AppendString(CyberEnvironment.GetGame().GetClientManager().GetNameById(UserId)); if (table != null) { serverMessage.AppendInt32(table.Rows.Count); IEnumerator enumerator = table.Rows.GetEnumerator(); try { while (enumerator.MoveNext()) { DataRow dataRow = (DataRow)enumerator.Current; queryreactor.setQuery(string.Concat(new object[] { "SELECT user_id,timestamp,message FROM chatlogs WHERE room_id = ", (uint)dataRow["room_id"], " AND user_id = ", UserId, " ORDER BY timestamp DESC LIMIT 30" })); DataTable table2 = queryreactor.getTable(); RoomData roomData = CyberEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)dataRow["room_id"]); if (table2 != null) { serverMessage.AppendByte(1); serverMessage.AppendShort(2); serverMessage.AppendString("roomName"); serverMessage.AppendByte(2); if (roomData == null) { serverMessage.AppendString("This room was deleted"); } else { serverMessage.AppendString(roomData.Name); } serverMessage.AppendString("roomId"); serverMessage.AppendByte(1); serverMessage.AppendUInt((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 = CyberEnvironment.getHabboForId((uint)dataRow2["user_id"]); CyberEnvironment.UnixToDateTime((double)dataRow2["timestamp"]); if (habboForId == null) { result = null; return result; } serverMessage.AppendInt32(checked((int)unchecked((double)CyberEnvironment.GetUnixTimestamp() - (double)dataRow2["timestamp"]))); serverMessage.AppendUInt(habboForId.Id); serverMessage.AppendString(habboForId.Username); serverMessage.AppendString(dataRow2["message"].ToString()); serverMessage.AppendBoolean(false); } continue; } finally { IDisposable disposable = enumerator2 as IDisposable; if (disposable != null) { disposable.Dispose(); } } } serverMessage.AppendByte(1); serverMessage.AppendShort(0); serverMessage.AppendShort(0); } goto IL_29B; } finally { IDisposable disposable2 = enumerator as IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } } serverMessage.AppendInt32(0); IL_29B: result = serverMessage; } return result; }
internal static ServerMessage SerializeRoomChatlog(uint roomID) { // NEW CHATLOGS [March 2014] Coded by Finn // Please don't remove credits, this took me some time to do... :( // Credits to Itachi for the structure's "context" enigma :D ServerMessage Message = new ServerMessage(); RoomData Room = CyberEnvironment.GetGame().GetRoomManager().GenerateRoomData(roomID); if (Room == null) { throw new NullReferenceException("No room found."); } Message.Init(Outgoing.ModerationToolRoomChatlogMessageComposer); Message.AppendByte(1); Message.AppendShort(2); Message.AppendString("roomName"); Message.AppendByte(2); Message.AppendString(Room.Name); Message.AppendString("roomId"); Message.AppendByte(1); Message.AppendUInt(Room.Id); var TempChatlogs = Room.RoomChat.Reverse().Take(60); Message.AppendShort(TempChatlogs.Count()); foreach (Chatlog current in TempChatlogs) { Habbo Habbo = CyberEnvironment.getHabboForId(current.UserId); DateTime Date = CyberEnvironment.UnixToDateTime(current.Timestamp); if (Habbo == null) { Message.AppendInt32((DateTime.Now - Date).Seconds); Message.AppendUInt(current.UserId); Message.AppendString("*User not found*"); Message.AppendString(current.Message); Message.AppendBoolean(true); } else { Message.AppendInt32((DateTime.Now - Date).Seconds); Message.AppendUInt(Habbo.Id); Message.AppendString(Habbo.Username); Message.AppendString(current.Message); Message.AppendBoolean(false); // Text is bold } } TempChatlogs = null; return Message; }
internal void GetGroupForumThreadRoot() { uint GroupId = Request.PopWiredUInt(); int StartIndex = Request.PopWiredInt32(); int EndIndex = Request.PopWiredInt32(); // igual siempre será 20. Guild Group = CyberEnvironment.GetGame().GetGroupManager().GetGroup(GroupId); if (Group == null || !Group.HasForum) { return; } using (IQueryAdapter dbClient = CyberEnvironment.GetDatabaseManager().getQueryReactor()) { dbClient.setQuery("SELECT * FROM group_forum_posts WHERE group_id = '" + GroupId + "' AND parent_id = 0 ORDER BY timestamp DESC;"); DataTable Table = dbClient.getTable(); if (Table == null) { ServerMessage Méssich = new ServerMessage(Outgoing.GroupForumThreadRootMessageComposer); Méssich.AppendUInt(GroupId); Méssich.AppendInt32(0); Méssich.AppendInt32(0); Session.SendMessage(Méssich); return; } int b = (Table.Rows.Count <= 20) ? Table.Rows.Count : 20; List<GroupForumPost> Threads = new List<GroupForumPost>(); int i = 1; while (i <= b) { DataRow Row = Table.Rows[i - 1]; if (Row == null) { b--; continue; } GroupForumPost thread = new GroupForumPost(Row); Threads.Add(thread); i++; } Threads = Threads.OrderByDescending(x => x.Pinned).ToList(); ServerMessage Message = new ServerMessage(Outgoing.GroupForumThreadRootMessageComposer); Message.AppendUInt(GroupId); Message.AppendInt32(StartIndex); Message.AppendInt32(b); foreach (GroupForumPost Thread in Threads) { Message.AppendUInt(Thread.Id); Message.AppendUInt(Thread.PosterId); Message.AppendString(Thread.PosterName); Message.AppendString(Thread.Subject); Message.AppendBoolean(Thread.Pinned); Message.AppendBoolean(Thread.Locked); Message.AppendInt32((CyberEnvironment.GetUnixTimestamp() - Thread.Timestamp)); Message.AppendInt32(Thread.MessageCount + 1); Message.AppendInt32(0); Message.AppendInt32(0);//readtimes? Message.AppendInt32(0); Message.AppendString(""); Message.AppendInt32((CyberEnvironment.GetUnixTimestamp() - Thread.Timestamp)); Message.AppendByte((Thread.Hidden) ? 10 : 1); Message.AppendInt32(0); Message.AppendString(Thread.Hider); Message.AppendInt32(0);//Unknown, but unused. Parece ID } Session.SendMessage(Message); } }
public void OnTrigger(GameClient Session, RoomItem Item, int Request, bool HasRights) { if (Session == null || Item == null) { return; } if (!HasRights) { return; } string ExtraInfo = ""; bool flag = false; int i = 0; List<RoomItem> list = new List<RoomItem>(); string ExtraString = ""; string ExtraString2 = ""; using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor()) { queryreactor.setQuery("SELECT * FROM wired_items WHERE id=@id LIMIT 1"); queryreactor.addParameter("id", Item.Id); DataRow row = queryreactor.getRow(); if (row != null) { ExtraInfo = row["string"].ToString(); i = (int)row["delay"] / 500; flag = (row["bool"].ToString() == "1"); ExtraString = row["extra_string"].ToString(); ExtraString2 = row["extra_string_2"].ToString(); string[] array = row["items"].ToString().Split(new char[] { ';' }); for (int j = 0; j < array.Length; j++) { string s = array[j]; uint pId = 0u; if (uint.TryParse(s, out pId)) { RoomItem item = Item.GetRoom().GetRoomItemHandler().GetItem(pId); if (item != null && !list.Contains(item)) { list.Add(item); } } } } } switch (Item.GetBaseItem().InteractionType) { case InteractionType.triggertimer: { ServerMessage serverMessage = new ServerMessage(Outgoing.WiredTriggerMessageComposer); serverMessage.AppendBoolean(false); serverMessage.AppendInt32(5); serverMessage.AppendInt32(list.Count); foreach (RoomItem current in list) { serverMessage.AppendUInt(current.Id); } serverMessage.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage.AppendUInt(Item.Id); serverMessage.AppendString(ExtraInfo); serverMessage.AppendInt32(1); serverMessage.AppendInt32(1); serverMessage.AppendInt32(1); serverMessage.AppendInt32(3); serverMessage.AppendInt32(0); serverMessage.AppendInt32(0); Session.SendMessage(serverMessage); return; } case InteractionType.triggerroomenter: { ServerMessage serverMessage2 = new ServerMessage(Outgoing.WiredTriggerMessageComposer); serverMessage2.AppendBoolean(false); serverMessage2.AppendInt32(0); serverMessage2.AppendInt32(list.Count); foreach (RoomItem current2 in list) { serverMessage2.AppendUInt(current2.Id); } serverMessage2.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage2.AppendUInt(Item.Id); serverMessage2.AppendString(ExtraInfo); serverMessage2.AppendInt32(0); serverMessage2.AppendInt32(0); serverMessage2.AppendInt32(7); serverMessage2.AppendInt32(0); serverMessage2.AppendInt32(0); serverMessage2.AppendInt32(0); Session.SendMessage(serverMessage2); return; } case InteractionType.triggergameend: { ServerMessage serverMessage3 = new ServerMessage(Outgoing.WiredTriggerMessageComposer); serverMessage3.AppendBoolean(false); serverMessage3.AppendInt32(0); serverMessage3.AppendInt32(list.Count); foreach (RoomItem current3 in list) { serverMessage3.AppendUInt(current3.Id); } serverMessage3.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage3.AppendUInt(Item.Id); serverMessage3.AppendString(ExtraInfo); serverMessage3.AppendInt32(0); serverMessage3.AppendInt32(0); serverMessage3.AppendInt32(8); serverMessage3.AppendInt32(0); serverMessage3.AppendInt32(0); serverMessage3.AppendInt32(0); Session.SendMessage(serverMessage3); return; } case InteractionType.triggergamestart: { ServerMessage serverMessage4 = new ServerMessage(Outgoing.WiredTriggerMessageComposer); serverMessage4.AppendBoolean(false); serverMessage4.AppendInt32(0); serverMessage4.AppendInt32(list.Count); foreach (RoomItem current4 in list) { serverMessage4.AppendUInt(current4.Id); } serverMessage4.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage4.AppendUInt(Item.Id); serverMessage4.AppendString(ExtraInfo); serverMessage4.AppendInt32(0); serverMessage4.AppendInt32(0); serverMessage4.AppendInt32(8); serverMessage4.AppendInt32(0); serverMessage4.AppendInt32(0); serverMessage4.AppendInt32(0); Session.SendMessage(serverMessage4); return; } case InteractionType.triggerlongrepeater: { ServerMessage serverMessage = new ServerMessage(Outgoing.WiredTriggerMessageComposer); serverMessage.AppendBoolean(false); serverMessage.AppendInt32(5); serverMessage.AppendInt32(0); serverMessage.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage.AppendUInt(Item.Id); serverMessage.AppendString(""); serverMessage.AppendInt32(1); serverMessage.AppendInt32(i / 10);//fix serverMessage.AppendInt32(0); serverMessage.AppendInt32(12); serverMessage.AppendInt32(0); Session.SendMessage(serverMessage); return; } case InteractionType.triggerrepeater: { ServerMessage serverMessage5 = new ServerMessage(Outgoing.WiredTriggerMessageComposer); serverMessage5.AppendBoolean(false); serverMessage5.AppendInt32(5); serverMessage5.AppendInt32(list.Count); foreach (RoomItem current5 in list) { serverMessage5.AppendUInt(current5.Id); } serverMessage5.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage5.AppendUInt(Item.Id); serverMessage5.AppendString(ExtraInfo); serverMessage5.AppendInt32(1); serverMessage5.AppendInt32(i); serverMessage5.AppendInt32(0); serverMessage5.AppendInt32(6); serverMessage5.AppendInt32(0); serverMessage5.AppendInt32(0); Session.SendMessage(serverMessage5); return; } case InteractionType.triggeronusersay: { ServerMessage serverMessage6 = new ServerMessage(Outgoing.WiredTriggerMessageComposer); serverMessage6.AppendBoolean(false); serverMessage6.AppendInt32(0); serverMessage6.AppendInt32(list.Count); foreach (RoomItem current6 in list) { serverMessage6.AppendUInt(current6.Id); } serverMessage6.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage6.AppendUInt(Item.Id); serverMessage6.AppendString(ExtraInfo); serverMessage6.AppendInt32(0); serverMessage6.AppendInt32(0); serverMessage6.AppendInt32(0); serverMessage6.AppendInt32(0); serverMessage6.AppendInt32(0); serverMessage6.AppendInt32(0); Session.SendMessage(serverMessage6); return; } case InteractionType.triggerscoreachieved: { ServerMessage serverMessage7 = new ServerMessage(Outgoing.WiredTriggerMessageComposer); serverMessage7.AppendBoolean(false); serverMessage7.AppendInt32(5); serverMessage7.AppendInt32(0); serverMessage7.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage7.AppendUInt(Item.Id); serverMessage7.AppendString(""); serverMessage7.AppendInt32(1); serverMessage7.AppendInt32((String.IsNullOrWhiteSpace(ExtraInfo)) ? 100 : int.Parse(ExtraInfo)); serverMessage7.AppendInt32(0); serverMessage7.AppendInt32(10); serverMessage7.AppendInt32(0); serverMessage7.AppendInt32(0); Session.SendMessage(serverMessage7); return; } case InteractionType.triggerstatechanged: { ServerMessage serverMessage8 = new ServerMessage(Outgoing.WiredTriggerMessageComposer); serverMessage8.AppendBoolean(false); serverMessage8.AppendInt32(5); serverMessage8.AppendInt32(list.Count); foreach (RoomItem current8 in list) { serverMessage8.AppendUInt(current8.Id); } serverMessage8.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage8.AppendUInt(Item.Id); serverMessage8.AppendString(ExtraInfo); serverMessage8.AppendInt32(0); serverMessage8.AppendInt32(0); serverMessage8.AppendInt32(1); serverMessage8.AppendInt32(i); serverMessage8.AppendInt32(0); serverMessage8.AppendInt32(0); Session.SendMessage(serverMessage8); return; } case InteractionType.triggerwalkonfurni: { ServerMessage serverMessage9 = new ServerMessage(Outgoing.WiredTriggerMessageComposer); serverMessage9.AppendBoolean(false); serverMessage9.AppendInt32(5); serverMessage9.AppendInt32(list.Count); foreach (RoomItem current9 in list) { serverMessage9.AppendUInt(current9.Id); } serverMessage9.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage9.AppendUInt(Item.Id); serverMessage9.AppendString(ExtraInfo); serverMessage9.AppendInt32(0); serverMessage9.AppendInt32(0); serverMessage9.AppendInt32(1); serverMessage9.AppendInt32(0); serverMessage9.AppendInt32(0); serverMessage9.AppendInt32(0); Session.SendMessage(serverMessage9); return; } case InteractionType.actionmuteuser: { ServerMessage serverMessage18 = new ServerMessage(Outgoing.WiredEffectMessageComposer); serverMessage18.AppendBoolean(false); serverMessage18.AppendInt32(5); serverMessage18.AppendInt32(0); serverMessage18.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage18.AppendUInt(Item.Id); serverMessage18.AppendString(ExtraInfo); serverMessage18.AppendInt32(1); serverMessage18.AppendInt32(i); serverMessage18.AppendInt32(0); serverMessage18.AppendInt32(20); serverMessage18.AppendInt32(0); serverMessage18.AppendInt32(0); Session.SendMessage(serverMessage18); return; } case InteractionType.triggerwalkofffurni: { ServerMessage serverMessage10 = new ServerMessage(Outgoing.WiredTriggerMessageComposer); serverMessage10.AppendBoolean(false); serverMessage10.AppendInt32(5); serverMessage10.AppendInt32(list.Count); foreach (RoomItem current10 in list) { serverMessage10.AppendUInt(current10.Id); } serverMessage10.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage10.AppendUInt(Item.Id); serverMessage10.AppendString(ExtraInfo); serverMessage10.AppendInt32(0); serverMessage10.AppendInt32(0); serverMessage10.AppendInt32(1); serverMessage10.AppendInt32(0); serverMessage10.AppendInt32(0); serverMessage10.AppendInt32(0); serverMessage10.AppendInt32(0); Session.SendMessage(serverMessage10); return; } case InteractionType.actiongivescore: { // Por hacer. ServerMessage serverMessage11 = new ServerMessage(Outgoing.WiredEffectMessageComposer); serverMessage11.AppendBoolean(false); serverMessage11.AppendInt32(5); serverMessage11.AppendInt32(0); serverMessage11.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage11.AppendUInt(Item.Id); serverMessage11.AppendString(""); serverMessage11.AppendInt32(2); if (String.IsNullOrWhiteSpace(ExtraInfo)) { serverMessage11.AppendInt32(10); // Puntos a dar serverMessage11.AppendInt32(1); // Numero de veces por equipo } else { string[] Integers = ExtraInfo.Split(','); serverMessage11.AppendInt32(int.Parse(Integers[0])); // Puntos a dar serverMessage11.AppendInt32(int.Parse(Integers[1])); // Numero de veces por equipo } serverMessage11.AppendInt32(0); serverMessage11.AppendInt32(6); serverMessage11.AppendInt32(0); serverMessage11.AppendInt32(0); serverMessage11.AppendInt32(0); Session.SendMessage(serverMessage11); return; } case InteractionType.conditiongroupmember: case InteractionType.conditionnotgroupmember: { ServerMessage Message = new ServerMessage(Outgoing.WiredConditionMessageComposer); Message.AppendBoolean(false); Message.AppendInt32(5); Message.AppendInt32(0); Message.AppendInt32(Item.GetBaseItem().SpriteId); Message.AppendUInt(Item.Id); Message.AppendString(""); Message.AppendInt32(0); Message.AppendInt32(0); Message.AppendInt32(10); Session.SendMessage(Message); return; } case InteractionType.conditionitemsmatches: case InteractionType.conditionitemsdontmatch: { ServerMessage serverMessage21 = new ServerMessage(Outgoing.WiredConditionMessageComposer); serverMessage21.AppendBoolean(false); serverMessage21.AppendInt32(5); serverMessage21.AppendInt32(list.Count); foreach (RoomItem current20 in list) { serverMessage21.AppendUInt(current20.Id); } serverMessage21.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage21.AppendUInt(Item.Id); serverMessage21.AppendString(ExtraString2); serverMessage21.AppendInt32(3); if (String.IsNullOrWhiteSpace(ExtraInfo)) { serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(0); } else { string[] boolz = ExtraInfo.Split(','); foreach (string Stringy in boolz) { if (Stringy.ToLower() == "true") { serverMessage21.AppendInt32(1); } else { serverMessage21.AppendInt32(0); } } } serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(0); Session.SendMessage(serverMessage21); return; } case InteractionType.actionposreset: { ServerMessage serverMessage12 = new ServerMessage(Outgoing.WiredEffectMessageComposer); serverMessage12.AppendBoolean(false); serverMessage12.AppendInt32(5); serverMessage12.AppendInt32(list.Count); foreach (RoomItem current12 in list) { serverMessage12.AppendUInt(current12.Id); } serverMessage12.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage12.AppendUInt(Item.Id); serverMessage12.AppendString(ExtraString2); serverMessage12.AppendInt32(3); if (String.IsNullOrWhiteSpace(ExtraInfo)) { serverMessage12.AppendInt32(0); serverMessage12.AppendInt32(0); serverMessage12.AppendInt32(0); } else { string[] boolz = ExtraInfo.Split(','); foreach (string Stringy in boolz) { if (Stringy.ToLower() == "true") { serverMessage12.AppendInt32(1); } else { serverMessage12.AppendInt32(0); } } } serverMessage12.AppendInt32(0); serverMessage12.AppendInt32(3); serverMessage12.AppendInt32(i); // Delay serverMessage12.AppendInt32(0); Session.SendMessage(serverMessage12); return; } case InteractionType.actionmoverotate: { ServerMessage serverMessage13 = new ServerMessage(Outgoing.WiredEffectMessageComposer); serverMessage13.AppendBoolean(false); serverMessage13.AppendInt32(5); serverMessage13.AppendInt32(list.Count); foreach (RoomItem current13 in list) { serverMessage13.AppendUInt(current13.Id); } serverMessage13.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage13.AppendUInt(Item.Id); serverMessage13.AppendString(ExtraInfo); serverMessage13.AppendInt32(2); serverMessage13.AppendInt32(int.Parse(ExtraInfo.Split(new char[] { ';' })[1])); serverMessage13.AppendInt32(int.Parse(ExtraInfo.Split(new char[] { ';' })[0])); serverMessage13.AppendInt32(0); serverMessage13.AppendInt32(4); serverMessage13.AppendInt32(i); serverMessage13.AppendInt32(0); serverMessage13.AppendInt32(0); Session.SendMessage(serverMessage13); return; } case InteractionType.actionresettimer: { ServerMessage serverMessage14 = new ServerMessage(Outgoing.WiredEffectMessageComposer); serverMessage14.AppendBoolean(false); serverMessage14.AppendInt32(5); serverMessage14.AppendInt32(list.Count); foreach (RoomItem current14 in list) { serverMessage14.AppendUInt(current14.Id); } serverMessage14.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage14.AppendUInt(Item.Id); serverMessage14.AppendString(ExtraInfo); serverMessage14.AppendInt32(0); serverMessage14.AppendInt32(0); serverMessage14.AppendInt32(0); serverMessage14.AppendInt32(0); serverMessage14.AppendInt32(0); serverMessage14.AppendInt32(0); Session.SendMessage(serverMessage14); return; } case InteractionType.actionshowmessage: case InteractionType.actionkickuser: { ServerMessage serverMessage15 = new ServerMessage(Outgoing.WiredEffectMessageComposer); serverMessage15.AppendBoolean(false); serverMessage15.AppendInt32(0); serverMessage15.AppendInt32(list.Count); foreach (RoomItem current15 in list) { serverMessage15.AppendUInt(current15.Id); } serverMessage15.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage15.AppendUInt(Item.Id); serverMessage15.AppendString(ExtraInfo); serverMessage15.AppendInt32(0); serverMessage15.AppendInt32(0); serverMessage15.AppendInt32(7); serverMessage15.AppendInt32(0); serverMessage15.AppendInt32(0); serverMessage15.AppendInt32(0); Session.SendMessage(serverMessage15); return; } case InteractionType.actionteleportto: { ServerMessage serverMessage16 = new ServerMessage(Outgoing.WiredEffectMessageComposer); serverMessage16.AppendBoolean(false); serverMessage16.AppendInt32(5); serverMessage16.AppendInt32(list.Count); foreach (RoomItem current16 in list) { serverMessage16.AppendUInt(current16.Id); } serverMessage16.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage16.AppendUInt(Item.Id); serverMessage16.AppendString(ExtraInfo); serverMessage16.AppendInt32(0); serverMessage16.AppendInt32(8); serverMessage16.AppendInt32(0); serverMessage16.AppendInt32(i); serverMessage16.AppendInt32(0); serverMessage16.AppendByte(2); Session.SendMessage(serverMessage16); return; } case InteractionType.actiontogglestate: { ServerMessage serverMessage17 = new ServerMessage(Outgoing.WiredEffectMessageComposer); serverMessage17.AppendBoolean(false); serverMessage17.AppendInt32(5); serverMessage17.AppendInt32(list.Count); foreach (RoomItem current17 in list) { serverMessage17.AppendUInt(current17.Id); } serverMessage17.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage17.AppendUInt(Item.Id); serverMessage17.AppendString(ExtraInfo); serverMessage17.AppendInt32(0); serverMessage17.AppendInt32(8); serverMessage17.AppendInt32(0); serverMessage17.AppendInt32(i); serverMessage17.AppendInt32(0); serverMessage17.AppendInt32(0); Session.SendMessage(serverMessage17); return; } case InteractionType.actiongivereward: { ServerMessage serverMessage18 = new ServerMessage(Outgoing.WiredEffectMessageComposer); serverMessage18.AppendBoolean(false); serverMessage18.AppendInt32(5); serverMessage18.AppendInt32(0); serverMessage18.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage18.AppendUInt(Item.Id); serverMessage18.AppendString(ExtraInfo); serverMessage18.AppendInt32(3); serverMessage18.AppendInt32((ExtraString == "") ? 0 : int.Parse(ExtraString)); serverMessage18.AppendInt32(flag ? 1 : 0); serverMessage18.AppendInt32((ExtraString2 == "") ? 0 : int.Parse(ExtraString2)); serverMessage18.AppendInt32(0); serverMessage18.AppendInt32(17); serverMessage18.AppendInt32(0); serverMessage18.AppendInt32(0); Session.SendMessage(serverMessage18); return; } case InteractionType.conditionhowmanyusersinroom: case InteractionType.conditionnegativehowmanyusers: { ServerMessage serverMessage19 = new ServerMessage(Outgoing.WiredConditionMessageComposer); serverMessage19.AppendBoolean(false); serverMessage19.AppendInt32(5); serverMessage19.AppendInt32(0); serverMessage19.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage19.AppendUInt(Item.Id); serverMessage19.AppendString(""); serverMessage19.AppendInt32(2); if (String.IsNullOrWhiteSpace(ExtraInfo)) { serverMessage19.AppendInt32(1); serverMessage19.AppendInt32(50); } else { foreach (string Integers in ExtraInfo.Split(',')) { serverMessage19.AppendInt32(int.Parse(Integers)); } } serverMessage19.AppendBoolean(false); serverMessage19.AppendInt32(0); serverMessage19.AppendInt32(1290); Session.SendMessage(serverMessage19); return; } case InteractionType.conditionfurnishaveusers: case InteractionType.conditionstatepos: case InteractionType.conditiontriggeronfurni: case InteractionType.conditionfurnihasfurni: case InteractionType.conditionfurnitypematches: case InteractionType.conditionfurnihasnotfurni: case InteractionType.conditionfurnishavenotusers: case InteractionType.conditionfurnitypedontmatch: case InteractionType.conditiontriggerernotonfurni: { ServerMessage serverMessage19 = new ServerMessage(Outgoing.WiredConditionMessageComposer); serverMessage19.AppendBoolean(false); serverMessage19.AppendInt32(5); serverMessage19.AppendInt32(list.Count); foreach (RoomItem current18 in list) { serverMessage19.AppendUInt(current18.Id); } serverMessage19.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage19.AppendUInt(Item.Id); serverMessage19.AppendInt32(0); serverMessage19.AppendInt32(0); serverMessage19.AppendInt32(0); serverMessage19.AppendBoolean(false); serverMessage19.AppendBoolean(true); Session.SendMessage(serverMessage19); return; } case InteractionType.conditiontimelessthan: case InteractionType.conditiontimemorethan: { ServerMessage serverMessage21 = new ServerMessage(Outgoing.WiredConditionMessageComposer); serverMessage21.AppendBoolean(false); serverMessage21.AppendInt32(5); serverMessage21.AppendInt32(list.Count); foreach (RoomItem current20 in list) { serverMessage21.AppendUInt(current20.Id); } serverMessage21.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage21.AppendUInt(Item.Id); serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(0); Session.SendMessage(serverMessage21); return; } case InteractionType.conditionuserwearingeffect: case InteractionType.conditionusernotwearingeffect: { int effect = 0; int.TryParse(ExtraInfo, out effect); ServerMessage serverMessage21 = new ServerMessage(Outgoing.WiredConditionMessageComposer); serverMessage21.AppendBoolean(false); serverMessage21.AppendInt32(5); serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage21.AppendUInt(Item.Id); serverMessage21.AppendString(""); serverMessage21.AppendInt32(1); serverMessage21.AppendInt32(effect); serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(12); Session.SendMessage(serverMessage21); return; } case InteractionType.conditionuserwearingbadge: case InteractionType.conditionusernotwearingbadge: { ServerMessage serverMessage21 = new ServerMessage(Outgoing.WiredConditionMessageComposer); serverMessage21.AppendBoolean(false); serverMessage21.AppendInt32(5); serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage21.AppendUInt(Item.Id); serverMessage21.AppendString(ExtraInfo); serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(11); Session.SendMessage(serverMessage21); return; } case InteractionType.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(Outgoing.WiredConditionMessageComposer); serverMessage21.AppendBoolean(false); serverMessage21.AppendInt32(5); serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage21.AppendUInt(Item.Id); serverMessage21.AppendString(ExtraInfo); serverMessage21.AppendInt32(2); serverMessage21.AppendInt32(date1); serverMessage21.AppendInt32(date2); serverMessage21.AppendInt32(0); serverMessage21.AppendInt32(24); Session.SendMessage(serverMessage21); return; } case InteractionType.arrowplate: case InteractionType.pressurepad: case InteractionType.ringplate: case InteractionType.colortile: case InteractionType.colorwheel: case InteractionType.floorswitch1: case InteractionType.floorswitch2: case InteractionType.firegate: case InteractionType.glassfoor: break; case InteractionType.specialrandom: { ServerMessage serverMessage24 = new ServerMessage(Outgoing.WiredEffectMessageComposer); serverMessage24.AppendBoolean(false); serverMessage24.AppendInt32(5); serverMessage24.AppendInt32(list.Count); foreach (RoomItem current23 in list) { serverMessage24.AppendUInt(current23.Id); } serverMessage24.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage24.AppendUInt(Item.Id); serverMessage24.AppendString(ExtraInfo); serverMessage24.AppendInt32(0); serverMessage24.AppendInt32(8); serverMessage24.AppendInt32(0); serverMessage24.AppendInt32(0); serverMessage24.AppendInt32(0); serverMessage24.AppendInt32(0); Session.SendMessage(serverMessage24); return; } case InteractionType.specialunseen: { ServerMessage serverMessage25 = new ServerMessage(Outgoing.WiredEffectMessageComposer); serverMessage25.AppendBoolean(false); serverMessage25.AppendInt32(5); serverMessage25.AppendInt32(list.Count); foreach (RoomItem current24 in list) { serverMessage25.AppendUInt(current24.Id); } serverMessage25.AppendInt32(Item.GetBaseItem().SpriteId); serverMessage25.AppendUInt(Item.Id); serverMessage25.AppendString(ExtraInfo); serverMessage25.AppendInt32(0); serverMessage25.AppendInt32(8); serverMessage25.AppendInt32(0); serverMessage25.AppendInt32(0); serverMessage25.AppendInt32(0); serverMessage25.AppendInt32(0); Session.SendMessage(serverMessage25); return; } default: return; } }
internal void ReadForumThread() { uint GroupId = Request.PopWiredUInt(); uint ThreadId = Request.PopWiredUInt(); int StartIndex = Request.PopWiredInt32(); int EndIndex = Request.PopWiredInt32(); Guild Group = CyberEnvironment.GetGame().GetGroupManager().GetGroup(GroupId); if (Group == null || !Group.HasForum) { return; } using (IQueryAdapter dbClient = CyberEnvironment.GetDatabaseManager().getQueryReactor()) { dbClient.setQuery("SELECT * FROM group_forum_posts WHERE group_id = '" + GroupId + "' AND parent_id = '" + ThreadId + "' OR id = '" + ThreadId + "' ORDER BY timestamp ASC;"); DataTable Table = dbClient.getTable(); if (Table == null) { return; } int b = (Table.Rows.Count <= 20) ? Table.Rows.Count : 20; List<GroupForumPost> posts = new List<GroupForumPost>(); int i = 1; while (i <= b) { DataRow Row = Table.Rows[i - 1]; if (Row == null) { b--; continue; } GroupForumPost thread = new GroupForumPost(Row); if (thread.ParentId == 0 && thread.Hidden) { return;// } posts.Add(thread); i++; } ServerMessage Message = new ServerMessage(Outgoing.GroupForumReadThreadMessageComposer); Message.AppendUInt(GroupId); Message.AppendUInt(ThreadId); Message.AppendInt32(StartIndex); Message.AppendInt32(b); int indx = 0; foreach (GroupForumPost Post in posts) { Message.AppendInt32(indx++ - 1); Message.AppendInt32(indx - 1); Message.AppendUInt(Post.PosterId); Message.AppendString(Post.PosterName); Message.AppendString(Post.PosterLook); Message.AppendInt32((CyberEnvironment.GetUnixTimestamp() - Post.Timestamp)); Message.AppendString(Post.PostContent); Message.AppendByte(0); Message.AppendInt32(0); Message.AppendString(Post.Hider); Message.AppendInt32(0);//Unknown, but unused. Parece ID } Session.SendMessage(Message); } }
internal void AlterForumThreadState() { uint GroupId = Request.PopWiredUInt(); uint ThreadId = Request.PopWiredUInt(); int StateToSet = Request.PopWiredInt32(); using (IQueryAdapter dbClient = CyberEnvironment.GetDatabaseManager().getQueryReactor()) { dbClient.setQuery("SELECT * FROM group_forum_posts WHERE group_id = '" + GroupId + "' AND id = '" + ThreadId + "' LIMIT 1;"); DataRow Row = dbClient.getRow(); Guild Group = CyberEnvironment.GetGame().GetGroupManager().GetGroup(GroupId); if (Row != null) { if ((uint)Row["poster_id"] == Session.GetHabbo().Id || Group.Admins.ContainsKey(Session.GetHabbo().Id)) { dbClient.setQuery("UPDATE group_forum_posts SET hidden = @hid WHERE id = " + ThreadId + ";"); dbClient.addParameter("hid", (StateToSet == 10) ? "1" : "0"); dbClient.runQuery(); } } GroupForumPost Thread = new GroupForumPost(Row); ServerMessage Notif = new ServerMessage(Outgoing.SuperNotificationMessageComposer); Notif.AppendString((StateToSet == 10) ? "forums.thread.hidden" : "forums.thread.restored"); Notif.AppendInt32(0); Session.SendMessage(Notif); if (Thread.ParentId != 0) { return; } ServerMessage Message = new ServerMessage(Outgoing.GroupForumThreadUpdateMessageComposer); Message.AppendUInt(GroupId); Message.AppendUInt(Thread.Id); Message.AppendUInt(Thread.PosterId); Message.AppendString(Thread.PosterName); Message.AppendString(Thread.Subject); Message.AppendBoolean(Thread.Pinned); Message.AppendBoolean(Thread.Locked); Message.AppendInt32((CyberEnvironment.GetUnixTimestamp() - Thread.Timestamp)); Message.AppendInt32(Thread.MessageCount + 1); Message.AppendInt32(0); Message.AppendInt32(0);//readtimes? Message.AppendInt32(0); Message.AppendString(""); Message.AppendInt32((CyberEnvironment.GetUnixTimestamp() - Thread.Timestamp)); Message.AppendByte(StateToSet); Message.AppendInt32(0); Message.AppendString(Thread.Hider); Message.AppendInt32(0);//Unknown, but unused. Parece ID Session.SendMessage(Message); } }
internal void PublishForumThread() { if ((CyberEnvironment.GetUnixTimestamp() - Session.GetHabbo().lastSqlQuery) < 20) { Session.SendNotif("Please wait 20 seconds before publishing the next post!"); return; } uint GroupId = Request.PopWiredUInt(); uint ThreadId = Request.PopWiredUInt(); string Subject = Request.PopFixedString(); string Content = Request.PopFixedString(); Guild Group = CyberEnvironment.GetGame().GetGroupManager().GetGroup(GroupId); if (Group == null || !Group.HasForum) { return; } int Timestamp = CyberEnvironment.GetUnixTimestamp(); using (IQueryAdapter dbClient = CyberEnvironment.GetDatabaseManager().getQueryReactor()) { if (ThreadId != 0) { dbClient.setQuery("SELECT * FROM group_forum_posts WHERE id = " + ThreadId); DataRow Row = dbClient.getRow(); GroupForumPost Post = new GroupForumPost(Row); if (Post.Locked || Post.Hidden) { Session.SendNotif("¡No puedes publicar a este tema porque está oculto y/o bloqueado! Por favor, haz clic en 'Cancelar'."); return; } } this.Session.GetHabbo().lastSqlQuery = CyberEnvironment.GetUnixTimestamp(); dbClient.setQuery("INSERT INTO group_forum_posts (group_id, parent_id, timestamp, poster_id, poster_name, poster_look, subject, post_content) VALUES (@gid, @pard, @ts, @pid, @pnm, @plk, @subjc, @content)"); dbClient.addParameter("gid", GroupId); dbClient.addParameter("pard", ThreadId); dbClient.addParameter("ts", Timestamp); dbClient.addParameter("pid", Session.GetHabbo().Id); dbClient.addParameter("pnm", Session.GetHabbo().Username); dbClient.addParameter("plk", Session.GetHabbo().Look); dbClient.addParameter("subjc", Subject); dbClient.addParameter("content", Content); ThreadId = (uint)dbClient.getInteger(); } Group.ForumScore += 0.25; Group.ForumLastPosterName = Session.GetHabbo().Username; Group.ForumLastPosterId = Session.GetHabbo().Id; Group.ForumLastPosterTimestamp = Timestamp; Group.ForumMessagesCount++; Group.UpdateForum(); if (ThreadId == 0) { ServerMessage Message = new ServerMessage(Outgoing.GroupForumNewThreadMessageComposer); Message.AppendUInt(GroupId); Message.AppendUInt(ThreadId); Message.AppendUInt(Session.GetHabbo().Id); Message.AppendString(Subject); Message.AppendString(Content); Message.AppendBoolean(false); Message.AppendBoolean(false); Message.AppendInt32((CyberEnvironment.GetUnixTimestamp() - Timestamp)); Message.AppendInt32(1); Message.AppendInt32(0); Message.AppendInt32(0);//readtimes? Message.AppendInt32(1); Message.AppendString(""); Message.AppendInt32((CyberEnvironment.GetUnixTimestamp() - Timestamp)); Message.AppendByte(1); Message.AppendInt32(1); Message.AppendString(""); Message.AppendInt32(0);//Unknown, but unused. Parece ID Session.SendMessage(Message); } else { ServerMessage Message = new ServerMessage(Outgoing.GroupForumNewResponseMessageComposer); Message.AppendUInt(GroupId); Message.AppendUInt(ThreadId); Message.AppendUInt(Group.ForumMessagesCount);//something quick Message.AppendInt32(0);//something quick Message.AppendUInt(Session.GetHabbo().Id); Message.AppendString(Session.GetHabbo().Username); Message.AppendString(Session.GetHabbo().Look); Message.AppendInt32((CyberEnvironment.GetUnixTimestamp() - Timestamp)); Message.AppendString(Content); Message.AppendByte(0); Message.AppendInt32(0); Message.AppendString(""); Message.AppendInt32(0);//Unknown, but unused. Parece ID Session.SendMessage(Message); } }
internal void OnHeightmapUpdate(List<Point> oldCoords, List<Point> newCoords) { ServerMessage Message = new ServerMessage(Outgoing.UpdateFurniStackMapMessageComposer); Message.AppendByte((byte)(oldCoords.Count + newCoords.Count)); foreach (Point Coord in oldCoords) { Message.AppendByte((byte)Coord.X); Message.AppendByte((byte)Coord.Y); Message.AppendShort((short)(room.GetGameMap().SqAbsoluteHeight(Coord.X, Coord.Y) * 256)); } foreach (Point nCoord in newCoords) { Message.AppendByte((byte)nCoord.X); Message.AppendByte((byte)nCoord.Y); Message.AppendShort((short)(room.GetGameMap().SqAbsoluteHeight(nCoord.X, nCoord.Y) * 256)); } room.SendMessage(Message); }
internal void OnHeightmapUpdate(ICollection affectedTiles) { ServerMessage Message = new ServerMessage(Outgoing.UpdateFurniStackMapMessageComposer); Message.AppendByte((byte)affectedTiles.Count); foreach (Point Coord in affectedTiles) { Message.AppendByte((byte)Coord.X); Message.AppendByte((byte)Coord.Y); Message.AppendShort((short)(room.GetGameMap().SqAbsoluteHeight(Coord.X, Coord.Y) * 256)); } room.SendMessage(Message); }