/// <summary> /// Serializes the group information. /// </summary> /// <param name="group">The group.</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(Guild group, ServerMessage response, GameClient session, Room room, bool newWindow = false) { if (room == null || group == null) { return; } var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); var dateTime2 = dateTime.AddSeconds(group.CreateTime); response.Init(LibraryParser.OutgoingRequest("GroupDataMessageComposer")); response.AppendInteger(group.Id); response.AppendBool(true); response.AppendInteger(2); response.AppendString(group.Name); response.AppendString(group.Description); response.AppendString(group.Badge); response.AppendInteger(0); response.AppendString((Plus.GetGame().GetRoomManager().GenerateRoomData(group.RoomId) == null) ? "No room found.." : Plus.GetGame().GetRoomManager().GenerateRoomData(group.RoomId).Name); response.AppendInteger((group.CreatorId == session.GetHabbo().Id) ? 3 : (group.Requests.Contains(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(string.Format("{0}-{1}-{2}", dateTime2.Day, dateTime2.Month, dateTime2.Year)); response.AppendBool(group.CreatorId == session.GetHabbo().Id); response.AppendBool(group.Admins.ContainsKey(session.GetHabbo().Id)); response.AppendString((Plus.GetHabboById(group.CreatorId) == null) ? string.Empty : Plus.GetHabboById(group.CreatorId).UserName); response.AppendBool(newWindow); response.AppendBool(group.AdminOnlyDeco == 1u); response.AppendInteger(group.Requests.Count); response.AppendBool(group.HasForum); room.SendMessage(response); }
/// <summary> /// Closes the ticket. /// </summary> /// <param name="session">The session.</param> /// <param name="ticketId">The ticket identifier.</param> /// <param name="result">The result.</param> internal void CloseTicket(GameClient session, uint ticketId, int result) { SupportTicket ticket = this.GetTicket(ticketId); if (ticket == null || ticket.Status != TicketStatus.Picked || ticket.ModeratorId != session.GetHabbo().Id) { return; } GameClient clientByUserId = Plus.GetGame().GetClientManager().GetClientByUserId(ticket.SenderId); int i; TicketStatus newStatus; switch (result) { case 1: i = 1; newStatus = TicketStatus.Invalid; goto IL_9E; case 2: i = 2; newStatus = TicketStatus.Abusive; using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.RunFastQuery(string.Format("UPDATE users_info SET cfhs_abusive = cfhs_abusive + 1 WHERE user_id = {0}", ticket.SenderId)); goto IL_9E; } } i = 0; newStatus = TicketStatus.Resolved; IL_9E: if (clientByUserId != null && (ticket.Type != 3 && ticket.Type != 4)) { foreach (SupportTicket current2 in Tickets.FindAll(current => current.ReportedId == ticket.ReportedId && current.Status == TicketStatus.Picked)) { current2.Delete(true); SendTicketToModerators(current2); current2.Close(newStatus, true); } clientByUserId.GetMessageHandler().GetResponse().Init(LibraryParser.OutgoingRequest("ModerationToolUpdateIssueMessageComposer")); clientByUserId.GetMessageHandler().GetResponse().AppendInteger(1); clientByUserId.GetMessageHandler().GetResponse().AppendInteger(ticket.TicketId); clientByUserId.GetMessageHandler().GetResponse().AppendInteger(ticket.ModeratorId); clientByUserId.GetMessageHandler() .GetResponse() .AppendString((Plus.GetHabboById(ticket.ModeratorId) != null) ? Plus.GetHabboById(ticket.ModeratorId).UserName : "******"); clientByUserId.GetMessageHandler().GetResponse().AppendBool(false); clientByUserId.GetMessageHandler().GetResponse().AppendInteger(0); clientByUserId.GetMessageHandler().GetResponse().Init(LibraryParser.OutgoingRequest("ModerationTicketResponseMessageComposer")); clientByUserId.GetMessageHandler().GetResponse().AppendInteger(i); clientByUserId.GetMessageHandler().SendResponse(); } using (IQueryAdapter queryreactor2 = Plus.GetDatabaseManager().GetQueryReactor()) { queryreactor2.RunFastQuery(string.Format("UPDATE users_stats SET tickets_answered = tickets_answered+1 WHERE id={0} LIMIT 1", session.GetHabbo().Id)); } }
internal void Serialize(ref ServerMessage message) { var habbo = Plus.GetHabboById(UserId); message.AppendInteger(Plus.DifferenceInMilliSeconds(TimeStamp, DateTime.Now)); message.AppendInteger(UserId); message.AppendString(habbo == null ? "*User not found*" : habbo.UserName); message.AppendString(Message); message.AppendBool(GlobalMessage); }
/// <summary> /// Picks the specified p moderator identifier. /// </summary> /// <param name="pModeratorId">The p moderator identifier.</param> /// <param name="updateInDb">if set to <c>true</c> [update in database].</param> internal void Pick(uint pModeratorId, bool updateInDb) { this.Status = TicketStatus.Picked; this.ModeratorId = pModeratorId; this._modName = Plus.GetHabboById(pModeratorId).UserName; if (!updateInDb) { return; } using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.RunFastQuery(string.Concat(new object[] { "UPDATE moderation_tickets SET status = 'picked', moderator_id = ", pModeratorId, ", timestamp = '", Plus.GetUnixTimeStamp(), "' WHERE id = ", this.TicketId })); } }
/// <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 queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery(string.Format("SELECT room_id FROM users_chatlogs WHERE user_id = {0} ORDER BY timestamp DESC LIMIT 1", userId)); DataTable table = queryReactor.GetTable(); var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ModerationToolUserChatlogMessageComposer")); serverMessage.AppendInteger(userId); serverMessage.AppendString(Plus.GetGame().GetClientManager().GetNameById(userId)); if (table != null) { serverMessage.AppendInteger(table.Rows.Count); IEnumerator enumerator = table.Rows.GetEnumerator(); try { while (enumerator.MoveNext()) { var dataRow = (DataRow)enumerator.Current; queryReactor.SetQuery(string.Concat(new object[] { "SELECT user_id,timestamp,message FROM users_chatlogs WHERE room_id = ", (uint)dataRow["room_id"], " AND user_id = ", userId, " ORDER BY timestamp DESC LIMIT 500" })); DataTable table2 = queryReactor.GetTable(); RoomData roomData = Plus.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()) { var dataRow2 = (DataRow)enumerator2.Current; Habbo habboForId = Plus.GetHabboById((uint)dataRow2["user_id"]); Plus.UnixToDateTime((double)dataRow2["timestamp"]); if (habboForId == null) { return(null); } serverMessage.AppendInteger(((int)(Plus.GetUnixTimeStamp() - (double)dataRow2["timestamp"]))); serverMessage.AppendInteger(habboForId.Id); serverMessage.AppendString(habboForId.UserName); serverMessage.AppendString(dataRow2["message"].ToString()); serverMessage.AppendBool(false); } continue; } finally { var disposable = enumerator2 as IDisposable; if (disposable != null) { disposable.Dispose(); } } } serverMessage.AppendByte(1); serverMessage.AppendShort(0); serverMessage.AppendShort(0); } goto IL_29B; } finally { var disposable2 = enumerator as IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } } serverMessage.AppendInteger(0); IL_29B: result = serverMessage; } return(result); }
/// <summary> /// Serializes the group members. /// </summary> /// <param name="response">The response.</param> /// <param name="group">The group.</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, Guild group, uint reqType, GameClient session, string searchVal = "", int page = 0) { if (group == null || session == null) { return(null); } if (page < 1) { page = 0; } var list = Split(GetGroupUsersByString(group, searchVal, reqType)); response.AppendInteger(group.Id); response.AppendString(HabboHotel.Roleplay.Jobs.JobManager.JobData[(int)group.Id].Name); response.AppendInteger(HabboHotel.Roleplay.Jobs.JobManager.JobData[(int)group.Id].Headquarters); response.AppendString(HabboHotel.Roleplay.Jobs.JobManager.JobData[(int)group.Id].Badge); switch (reqType) { case 0u: response.AppendInteger(group.Members.Count); response.AppendInteger(list[page].Count); using (var enumerator = list[page].GetEnumerator()) { while (enumerator.MoveNext()) { var current = enumerator.Current; var habboForId = Plus.GetHabboById(current.Id); if (habboForId == null) { response.AppendInteger(0); response.AppendInteger(0); response.AppendString(string.Empty); response.AppendString(string.Empty); response.AppendString(string.Empty); } else { response.AppendInteger((current.Rank == 2) ? 0 : ((current.Rank == 1) ? 1 : 2)); response.AppendInteger(habboForId.Id); response.AppendString(habboForId.UserName); response.AppendString(habboForId.Look); response.AppendString(string.Empty); } } goto AppendRest; } case 1u: break; case 2u: { var list2 = Split(GetGroupRequestsByString(group, searchVal, reqType)); response.AppendInteger(group.Requests.Count); if (group.Requests.Count > 0) { response.AppendInteger(list2[page].Count); using (var enumerator2 = list2[page].GetEnumerator()) { while (enumerator2.MoveNext()) { var current2 = enumerator2.Current; var habboForId2 = Plus.GetHabboById(current2); if (habboForId2 == null) { response.AppendInteger(0); response.AppendInteger(0); response.AppendString(string.Empty); response.AppendString(string.Empty); response.AppendString(string.Empty); } else { response.AppendInteger(3); response.AppendInteger(habboForId2.Id); response.AppendString(habboForId2.UserName); response.AppendString(habboForId2.Look); response.AppendString(string.Empty); } } goto AppendRest; } } response.AppendInteger(0); goto AppendRest; } default: goto AppendRest; } response.AppendInteger(group.Admins.Count); if (group.Admins.Count > 0) { response.AppendInteger(list[page].Count); using (var enumerator3 = list[page].GetEnumerator()) { while (enumerator3.MoveNext()) { var current3 = enumerator3.Current; var habboForId3 = Plus.GetHabboById(current3.Id); if (habboForId3 == null) { response.AppendInteger(0); response.AppendInteger(0); response.AppendString(string.Empty); response.AppendString(string.Empty); response.AppendString(string.Empty); } else { response.AppendInteger((current3.Rank == 2) ? 0 : ((current3.Rank == 1) ? 1 : 2)); response.AppendInteger(habboForId3.Id); response.AppendString(habboForId3.UserName); response.AppendString(habboForId3.Look); response.AppendString(string.Empty); } } goto AppendRest; } } response.AppendInteger(0); AppendRest: response.AppendBool(session.GetHabbo().Id == group.CreatorId); response.AppendInteger(14); response.AppendInteger(page); response.AppendInteger(reqType); response.AppendString(searchVal); return(response); }