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="JynX" data-source="post: 396966" data-attributes="member: 66193"><p>Hello DevBest, I had a few people ask me if I had a command to add the ability to view a user's PM so I decided to code this and just release it to the public for anyone and everyone to use. This doesn't require hardly ANY knowledge of C# <span style="font-size: 9px">Note: You need to actually have a brain to add this..</span></p><p><span style="font-size: 9px"></span></p><p><span style="font-size: 15px">It looks like this:</span></p><p><span style="font-size: 15px"><img src="http://image.prntscr.com/image/67c20c6396e842de8469f60152b52772.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /> </span></p><p></p><p><span style="font-size: 12px">Anyways, here's the code for it (Add this to Plus.HabboHotel.Rooms.Chat.Commands.Moderator):</span></p><p><span style="font-size: 12px">[CODE]</span></p><p><span style="font-size: 12px">using System;</span></p><p><span style="font-size: 12px">using System.Linq;</span></p><p><span style="font-size: 12px">using System.Text;</span></p><p><span style="font-size: 12px">using System.Collections.Generic;</span></p><p><span style="font-size: 12px">using System.Data;</span></p><p><span style="font-size: 12px">using Plus.HabboHotel.GameClients;</span></p><p><span style="font-size: 12px">using Plus.HabboHotel.Rooms;</span></p><p><span style="font-size: 12px">using Plus.Communication.Packets.Outgoing.Users;</span></p><p><span style="font-size: 12px">using Plus.Communication.Packets.Outgoing.Rooms.Avatar;</span></p><p><span style="font-size: 12px">using System.Threading;</span></p><p><span style="font-size: 12px">using System.Threading.Tasks;</span></p><p><span style="font-size: 12px">using Plus.Communication.Packets.Outgoing.Rooms.Chat;</span></p><p><span style="font-size: 12px">using Plus.HabboHotel.Items;</span></p><p><span style="font-size: 12px">using Plus.HabboHotel.Catalog;</span></p><p><span style="font-size: 12px">using Plus.Communication.Packets.Outgoing.Inventory.Furni;</span></p><p><span style="font-size: 12px">using Plus.Database.Interfaces;</span></p><p><span style="font-size: 12px">using Plus.Communication.Packets.Outgoing.Notifications;</span></p><p><span style="font-size: 12px">using Plus.Communication.Packets.Outgoing.Rooms.Engine;</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator</span></p><p><span style="font-size: 12px">{</span></p><p><span style="font-size: 12px"> class ViewPrivateMessageCommand : IChatCommand</span></p><p><span style="font-size: 12px"> {</span></p><p><span style="font-size: 12px"> public string PermissionRequired</span></p><p><span style="font-size: 12px"> {</span></p><p><span style="font-size: 12px"> get { return "command_view_pms"; }</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> public string Parameters</span></p><p><span style="font-size: 12px"> {</span></p><p><span style="font-size: 12px"> get { return "%username%"; }</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> public string Description</span></p><p><span style="font-size: 12px"> {</span></p><p><span style="font-size: 12px"> get { return "Lets you view recent PMs from and to a user."; }</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)</span></p><p><span style="font-size: 12px"> {</span></p><p><span style="font-size: 12px"> if (Params.Length == 1)</span></p><p><span style="font-size: 12px"> {</span></p><p><span style="font-size: 12px"> Session.SendWhisper("Please enter the username of the user you wish to view private messages of.");</span></p><p><span style="font-size: 12px"> return;</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);</span></p><p><span style="font-size: 12px"> if (TargetClient == null)</span></p><p><span style="font-size: 12px"> {</span></p><p><span style="font-size: 12px"> Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online.");</span></p><p><span style="font-size: 12px"> return;</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> if (TargetClient.GetHabbo() == null)</span></p><p><span style="font-size: 12px"> {</span></p><p><span style="font-size: 12px"> Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online.");</span></p><p><span style="font-size: 12px"> return;</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"> StringBuilder b = new StringBuilder();</span></p><p><span style="font-size: 12px"> b.Append("Private messages - " + TargetClient.GetHabbo().Username + "\n\n");</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> using (IQueryAdapter db = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</span></p><p><span style="font-size: 12px"> {</span></p><p><span style="font-size: 12px"> db.SetQuery("SELECT * FROM `chatlogs_console` WHERE `from_id` = @id OR `to_id` = @id ORDER BY id DESC LIMIT 100");</span></p><p><span style="font-size: 12px"> db.AddParameter("id", TargetClient.GetHabbo().Id);</span></p><p><span style="font-size: 12px"> db.RunQuery();</span></p><p><span style="font-size: 12px"> DataTable t = db.getTable();</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> foreach (DataRow r in t.Rows)</span></p><p><span style="font-size: 12px"> {</span></p><p><span style="font-size: 12px"> b.Append(UnixTimeStampToDateTime((double)PlusEnvironment.GetUnixTimestamp()) + "\n");</span></p><p><span style="font-size: 12px"> b.Append(getUsernameFromId(Convert.ToInt32(r["from_id"])) + " to " + getUsernameFromId(Convert.ToInt32(r["to_id"])) + ": " + Convert.ToString(r["message"]) + "\n\n");</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> Session.SendMessage(new MOTDNotificationComposer(b.ToString()));</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> private DateTime UnixTimeStampToDateTime(double unixTimeStamp)</span></p><p><span style="font-size: 12px"> {</span></p><p><span style="font-size: 12px"> // Unix timestamp is seconds past epoch</span></p><p><span style="font-size: 12px"> System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);</span></p><p><span style="font-size: 12px"> dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();</span></p><p><span style="font-size: 12px"> return dtDateTime;</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> private string getUsernameFromId(int userId)</span></p><p><span style="font-size: 12px"> {</span></p><p><span style="font-size: 12px"> if (PlusEnvironment.GetHabboById(userId) != null)</span></p><p><span style="font-size: 12px"> return PlusEnvironment.GetHabboById(userId).Username;</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> using (IQueryAdapter db = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</span></p><p><span style="font-size: 12px"> {</span></p><p><span style="font-size: 12px"> db.SetQuery("SELECT `username` FROM `users` WHERE `id` = @id");</span></p><p><span style="font-size: 12px"> db.AddParameter("id", userId);</span></p><p><span style="font-size: 12px"> db.RunQuery();</span></p><p><span style="font-size: 12px"> return db.getString();</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px">}</span></p><p><span style="font-size: 12px">[/CODE]</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">Then open up your command manager (CommandManager.cs) and find this:</span></p><p><span style="font-size: 12px">[CODE]</span></p><p><span style="font-size: 12px">this.Register("ipban", new IPBanCommand());</span></p><p><span style="font-size: 12px">[/CODE]</span></p><p><span style="font-size: 12px">Under that add this: </span></p><p><span style="font-size: 12px">[CODE]</span></p><p><span style="font-size: 12px">this.Register("viewpm", new ViewPrivateMessageCommand());</span></p><p><span style="font-size: 12px">[/CODE]</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">Then run this query in your database (replace the STAFF ID with the minimum staff rank allowed to have this command):</span></p><p><span style="font-size: 12px">[CODE]</span></p><p><span style="font-size: 12px">INSERT INTO `permissions_commands` VALUES ('command_view_pms', 'STAFF ID', '0');</span></p><p><span style="font-size: 12px">[/CODE]</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">There you go, <a href="http://prntscr.com/e1ojbg" target="_blank">debug</a> the solution and you're good to go.</span></p><p><span style="font-size: 12px">Your welcome,</span></p><p><span style="font-size: 12px">Jake Adams.</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">Edit: Added a screenshot.</span></p></blockquote><p></p>
[QUOTE="JynX, post: 396966, member: 66193"] Hello DevBest, I had a few people ask me if I had a command to add the ability to view a user's PM so I decided to code this and just release it to the public for anyone and everyone to use. This doesn't require hardly ANY knowledge of C# [SIZE=1]Note: You need to actually have a brain to add this.. [/SIZE] [SIZE=4]It looks like this: [IMG]http://image.prntscr.com/image/67c20c6396e842de8469f60152b52772.png[/IMG] [/SIZE] [SIZE=3]Anyways, here's the code for it (Add this to Plus.HabboHotel.Rooms.Chat.Commands.Moderator): [CODE] using System; using System.Linq; using System.Text; using System.Collections.Generic; using System.Data; using Plus.HabboHotel.GameClients; using Plus.HabboHotel.Rooms; using Plus.Communication.Packets.Outgoing.Users; using Plus.Communication.Packets.Outgoing.Rooms.Avatar; using System.Threading; using System.Threading.Tasks; using Plus.Communication.Packets.Outgoing.Rooms.Chat; using Plus.HabboHotel.Items; using Plus.HabboHotel.Catalog; using Plus.Communication.Packets.Outgoing.Inventory.Furni; using Plus.Database.Interfaces; using Plus.Communication.Packets.Outgoing.Notifications; using Plus.Communication.Packets.Outgoing.Rooms.Engine; namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator { class ViewPrivateMessageCommand : IChatCommand { public string PermissionRequired { get { return "command_view_pms"; } } public string Parameters { get { return "%username%"; } } public string Description { get { return "Lets you view recent PMs from and to a user."; } } public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { if (Params.Length == 1) { Session.SendWhisper("Please enter the username of the user you wish to view private messages of."); return; } GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]); if (TargetClient == null) { Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online."); return; } if (TargetClient.GetHabbo() == null) { Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online."); return; } StringBuilder b = new StringBuilder(); b.Append("Private messages - " + TargetClient.GetHabbo().Username + "\n\n"); using (IQueryAdapter db = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { db.SetQuery("SELECT * FROM `chatlogs_console` WHERE `from_id` = @id OR `to_id` = @id ORDER BY id DESC LIMIT 100"); db.AddParameter("id", TargetClient.GetHabbo().Id); db.RunQuery(); DataTable t = db.getTable(); foreach (DataRow r in t.Rows) { b.Append(UnixTimeStampToDateTime((double)PlusEnvironment.GetUnixTimestamp()) + "\n"); b.Append(getUsernameFromId(Convert.ToInt32(r["from_id"])) + " to " + getUsernameFromId(Convert.ToInt32(r["to_id"])) + ": " + Convert.ToString(r["message"]) + "\n\n"); } } Session.SendMessage(new MOTDNotificationComposer(b.ToString())); } private DateTime UnixTimeStampToDateTime(double unixTimeStamp) { // Unix timestamp is seconds past epoch System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime(); return dtDateTime; } private string getUsernameFromId(int userId) { if (PlusEnvironment.GetHabboById(userId) != null) return PlusEnvironment.GetHabboById(userId).Username; using (IQueryAdapter db = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { db.SetQuery("SELECT `username` FROM `users` WHERE `id` = @id"); db.AddParameter("id", userId); db.RunQuery(); return db.getString(); } } } } [/CODE] Then open up your command manager (CommandManager.cs) and find this: [CODE] this.Register("ipban", new IPBanCommand()); [/CODE] Under that add this: [CODE] this.Register("viewpm", new ViewPrivateMessageCommand()); [/CODE] Then run this query in your database (replace the STAFF ID with the minimum staff rank allowed to have this command): [CODE] INSERT INTO `permissions_commands` VALUES ('command_view_pms', 'STAFF ID', '0'); [/CODE] There you go, [URL='http://prntscr.com/e1ojbg']debug[/URL] the solution and you're good to go. Your welcome, Jake Adams. Edit: Added a screenshot.[/SIZE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Releases
Server Releases
[RELEASE] [PlusEMU] View PM Command
Top