Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Releases
Server Releases
[RELEASE] [PlusEMU] View PM Command
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="JayC" data-source="post: 408732" data-attributes="member: 36373"><p>Someone asked for this, and I had no idea this was already released... So I did my own version of this not actually knowing, I won't steal your thunder but here is how I did it:</p><p></p><p>[CODE]using System;</p><p>using System.Linq;</p><p>using System.Text;</p><p>using System.Collections.Generic;</p><p>using Plus.Communication.Packets.Outgoing.Notifications;</p><p>using Plus.HabboHotel.GameClients;</p><p></p><p>namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator</p><p>{</p><p> class pmViewCommand : IChatCommand</p><p> {</p><p> public string PermissionRequired</p><p> {</p><p> get { return "command_viewpm"; }</p><p> }</p><p></p><p> public string Parameters</p><p> {</p><p> get { return "%From% %To%"; }</p><p> }</p><p></p><p> public string Description</p><p> {</p><p> get { return "Get the logs between 2 users"; }</p><p> }</p><p></p><p> public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)</p><p> {</p><p> if (Params.Length == 1)</p><p> {</p><p> Session.SendWhisper("Please enter the username\'s of the user\'s you wish to see logs for.");</p><p> return;</p><p> }</p><p></p><p> GameClient TargetClientOne = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);</p><p> GameClient TargetClientTwo = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[2]);</p><p></p><p> if (TargetClientOne == null || TargetClientTwo == null)</p><p> {</p><p> Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online.");</p><p> return;</p><p> }</p><p></p><p> if (TargetClientOne.GetHabbo() == null || TargetClientTwo.GetHabbo() == null)</p><p> {</p><p> Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online.");</p><p> return;</p><p> }</p><p></p><p> if (TargetClientOne.GetHabbo().Username == Session.GetHabbo().Username || TargetClientTwo.GetHabbo().Username == Session.GetHabbo().Username)</p><p> {</p><p> Session.SendWhisper("You cannot log check yourself.");</p><p> return;</p><p> }</p><p></p><p> string Message = CommandManager.MergeParams(Params, 2);</p><p></p><p> StringBuilder List = new StringBuilder();</p><p> List.Append("Viewing Last 15 Private Messages:\n=======================================================\n");</p><p> foreach (List<string> pmMessage in TargetClientOne.GetHabbo().GetMessenger().GetMessagesTo(TargetClientTwo.GetHabbo().Id))</p><p> {</p><p> System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);</p><p> dtDateTime = dtDateTime.AddSeconds(Double.Parse(pmMessage[1])).ToLocalTime();</p><p> List.Append(TargetClientOne.GetHabbo().Username + "--> " + TargetClientTwo.GetHabbo().Username + ": " + pmMessage[0] + " @" + dtDateTime + "\n\n");</p><p> }</p><p> Session.SendMessage(new MOTDNotificationComposer(List.ToString()));</p><p></p><p> }</p><p> }</p><p>}</p><p>[/CODE]</p><p></p><p>And this goes under HabboMessenger.cs:</p><p>[CODE]public List<List<string>> GetMessagesTo(int UserId)</p><p> {</p><p> List<List<string>> allMessages = new List<List<string>>();</p><p> DataTable GetMessages = null;</p><p> using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> dbClient.SetQuery("SELECT message,timestamp FROM `chatlogs_console` WHERE `to_id` = @id AND `from_id` = @from ORDER BY `timestamp` DESC LIMIT 15");</p><p> dbClient.AddParameter("id", UserId);</p><p> dbClient.AddParameter("from", this._userId);</p><p> GetMessages = dbClient.getTable();</p><p></p><p> if (GetMessages != null)</p><p> {</p><p> foreach (DataRow Row in GetMessages.Rows)</p><p> {</p><p> List<string> toMessage = new List<string>();</p><p> toMessage.Add(Convert.ToString(Row["message"]));</p><p> toMessage.Add(Convert.ToString(Row["timestamp"]));</p><p> allMessages.Add(toMessage);</p><p> }</p><p></p><p> </p><p> }</p><p> }</p><p> return allMessages;</p><p> }[/CODE]</p><p>[doublepost=1493937333,1493937197][/doublepost]</p><p>Also, Great feedback. Only thing to point out is caching is only good if you're emulator never shuts off; otherwise all logs are lost <img src="/styles/default/xenforo/smilies/emojione/smile.png" class="smilie" loading="lazy" alt=":)" title="Smile :)" data-shortname=":)" /> Grabbing as many records as he did, I don't find helpful. I would limit it to something like I did (15)</p></blockquote><p></p>
[QUOTE="JayC, post: 408732, member: 36373"] Someone asked for this, and I had no idea this was already released... So I did my own version of this not actually knowing, I won't steal your thunder but here is how I did it: [CODE]using System; using System.Linq; using System.Text; using System.Collections.Generic; using Plus.Communication.Packets.Outgoing.Notifications; using Plus.HabboHotel.GameClients; namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator { class pmViewCommand : IChatCommand { public string PermissionRequired { get { return "command_viewpm"; } } public string Parameters { get { return "%From% %To%"; } } public string Description { get { return "Get the logs between 2 users"; } } public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { if (Params.Length == 1) { Session.SendWhisper("Please enter the username\'s of the user\'s you wish to see logs for."); return; } GameClient TargetClientOne = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]); GameClient TargetClientTwo = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[2]); if (TargetClientOne == null || TargetClientTwo == null) { Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online."); return; } if (TargetClientOne.GetHabbo() == null || TargetClientTwo.GetHabbo() == null) { Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online."); return; } if (TargetClientOne.GetHabbo().Username == Session.GetHabbo().Username || TargetClientTwo.GetHabbo().Username == Session.GetHabbo().Username) { Session.SendWhisper("You cannot log check yourself."); return; } string Message = CommandManager.MergeParams(Params, 2); StringBuilder List = new StringBuilder(); List.Append("Viewing Last 15 Private Messages:\n=======================================================\n"); foreach (List<string> pmMessage in TargetClientOne.GetHabbo().GetMessenger().GetMessagesTo(TargetClientTwo.GetHabbo().Id)) { System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); dtDateTime = dtDateTime.AddSeconds(Double.Parse(pmMessage[1])).ToLocalTime(); List.Append(TargetClientOne.GetHabbo().Username + "--> " + TargetClientTwo.GetHabbo().Username + ": " + pmMessage[0] + " @" + dtDateTime + "\n\n"); } Session.SendMessage(new MOTDNotificationComposer(List.ToString())); } } } [/CODE] And this goes under HabboMessenger.cs: [CODE]public List<List<string>> GetMessagesTo(int UserId) { List<List<string>> allMessages = new List<List<string>>(); DataTable GetMessages = null; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT message,timestamp FROM `chatlogs_console` WHERE `to_id` = @id AND `from_id` = @from ORDER BY `timestamp` DESC LIMIT 15"); dbClient.AddParameter("id", UserId); dbClient.AddParameter("from", this._userId); GetMessages = dbClient.getTable(); if (GetMessages != null) { foreach (DataRow Row in GetMessages.Rows) { List<string> toMessage = new List<string>(); toMessage.Add(Convert.ToString(Row["message"])); toMessage.Add(Convert.ToString(Row["timestamp"])); allMessages.Add(toMessage); } } } return allMessages; }[/CODE] [doublepost=1493937333,1493937197][/doublepost] Also, Great feedback. Only thing to point out is caching is only good if you're emulator never shuts off; otherwise all logs are lost :) Grabbing as many records as he did, I don't find helpful. I would limit it to something like I did (15) [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Releases
Server Releases
[RELEASE] [PlusEMU] View PM Command
Top