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="Seriosk" data-source="post: 397601" data-attributes="member: 72056"><p>Firstly, take this as constructive criticism Jake, hopefully you can progress with these few tips <img src="/styles/default/xenforo/smilies/emojione/smile.png" class="smilie" loading="lazy" alt=":)" title="Smile :)" data-shortname=":)" /></p><p><strong></strong></p><p><strong>Using Utilities</strong></p><p>Okay, I have a few things to point out here, lets call it constructive criticism. In this code below you shouldn't be coding methods that Plus has already implemented. Also your unix timestamp method shouldn't be placed inside a command file, its always good to place methods that may be used by multiple things in a Utilities file. You can learn what Utilities are <a href="http://lmgtfy.com/?q=What+is+a+Utility+class%3F" target="_blank">here</a></p><p></p><p>Lets pretend this situation happened. You had put that method in 20 different places because you needed it for 20 different things. What happens when you need to change that method? do you go back to all 20 and change them? Well with what you're doing you would have to. It's always good to have 1 method in 1 place that you only have to change once.</p><p></p><p><strong>Naming Conventions</strong></p><p>Your naming conventions are totally out of the standard C# naming conventions here, you don't have to follow them but it is known as good practice by other developers if you do follow them. At least you made both methods private which is good.</p><p></p><p><strong>Private Methods</strong></p><p>Private methods can be private static if they don't use any of the classes objects, you can read more about this <a href="http://lmgtfy.com/?q=When+do+I+use+private+static+in+C%23%3F" target="_blank">here</a> this also goes for fields and other things, not just methods.</p><p></p><p><strong>Caching the chatlogs</strong></p><p>Why make your emulator go to all that work of getting 100 records when you could easily load them from a string list that you have previously populated with the chatlogs. This is known as caching, you can learn more about caching <a href="http://lmgtfy.com/?q=What+is+Caching" target="_blank">here</a></p><p></p><p>Example:</p><p>[CODE]</p><p>List<string> _chatlogs;</p><p>[/CODE]</p><p>(If plus doesn't already do this)</p><p></p><p>Plus Emulator also may even already have a method for this, I am not too sure.</p><p>On a plus note well done, you have come a long way. Good Tutorial.</p><p>[SPOILER="Your code"]</p><p>[CODE]</p><p>private DateTime UnixTimeStampToDateTime(double unixTimeStamp)</p><p>{</p><p> // Unix timestamp is seconds past epoch</p><p> System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);</p><p> dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();</p><p> return dtDateTime;</p><p>}</p><p></p><p>private string getUsernameFromId(int userId)</p><p>{</p><p> if (PlusEnvironment.GetHabboById(userId) != null)</p><p> return PlusEnvironment.GetHabboById(userId).Username;</p><p></p><p> using (IQueryAdapter db = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> db.SetQuery("SELECT `username` FROM `users` WHERE `id` = @id");</p><p> db.AddParameter("id", userId);</p><p> db.RunQuery();</p><p> return db.getString();</p><p> }</p><p>}</p><p>[/CODE]</p><p>[/SPOILER]</p></blockquote><p></p>
[QUOTE="Seriosk, post: 397601, member: 72056"] Firstly, take this as constructive criticism Jake, hopefully you can progress with these few tips :) [B] Using Utilities[/B] Okay, I have a few things to point out here, lets call it constructive criticism. In this code below you shouldn't be coding methods that Plus has already implemented. Also your unix timestamp method shouldn't be placed inside a command file, its always good to place methods that may be used by multiple things in a Utilities file. You can learn what Utilities are [URL='http://lmgtfy.com/?q=What+is+a+Utility+class%3F']here[/URL] Lets pretend this situation happened. You had put that method in 20 different places because you needed it for 20 different things. What happens when you need to change that method? do you go back to all 20 and change them? Well with what you're doing you would have to. It's always good to have 1 method in 1 place that you only have to change once. [B]Naming Conventions[/B] Your naming conventions are totally out of the standard C# naming conventions here, you don't have to follow them but it is known as good practice by other developers if you do follow them. At least you made both methods private which is good. [B]Private Methods[/B] Private methods can be private static if they don't use any of the classes objects, you can read more about this [URL='http://lmgtfy.com/?q=When+do+I+use+private+static+in+C%23%3F']here[/URL] this also goes for fields and other things, not just methods. [B]Caching the chatlogs[/B] Why make your emulator go to all that work of getting 100 records when you could easily load them from a string list that you have previously populated with the chatlogs. This is known as caching, you can learn more about caching [URL='http://lmgtfy.com/?q=What+is+Caching']here[/URL] Example: [CODE] List<string> _chatlogs; [/CODE] (If plus doesn't already do this) Plus Emulator also may even already have a method for this, I am not too sure. On a plus note well done, you have come a long way. Good Tutorial. [SPOILER="Your code"] [CODE] 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] [/SPOILER] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Releases
Server Releases
[RELEASE] [PlusEMU] View PM Command
Top