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
Really simple and awesome RP cooldown system
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: 410829" data-attributes="member: 72056"><p>Lol.. not really awesome BUT..</p><p></p><p>Hello. Many of you may of seen, or even coded a cool-down for an RP or hotel command. But what happens when the cool-down gets too large, and the user could just reload the client and bypass it? That is where this comes in.. it stores it in the database, so even if the emulator went down, the user would still have a cooldown on their head. </p><p></p><p>It works via Date Times so it knows exactly when it was added, which results in it knowing exactly when it expires. With this tiny tiny tiny pretty useless library you can set cool downs for hours, days, weeks, anything you like.</p><p></p><p>I've seen emulators such as Rage, Habbo, Fabbo, Holo all do horrible cooldown systems, but this system actually seems really easy to use, and its amazing how small it is, along with its amazing simplicity of using it.</p><p></p><p>It's coded in pretty good standards, so it should be fine... It's in my opinion far better than any other cooldown system I have seen released on this forum. And before people starting commenting "its useless", maybe.. but I just coded it for simple usage, I just shared it for people looking for the same thing.</p><p></p><p>SQL:</p><p>[CODE]DROP TABLE IF EXISTS `user_roleplay_cooldowns`;</p><p>CREATE TABLE `user_roleplay_cooldowns` (</p><p> `user_id` int(11) DEFAULT NULL,</p><p> `cooldown_name` varchar(255) DEFAULT NULL,</p><p> `cooldown_added` varchar(255) DEFAULT NULL,</p><p> `cooldown_duration` int(11) DEFAULT NULL</p><p>) ENGINE=InnoDB DEFAULT CHARSET=latin1;[/CODE]</p><p></p><p>C#:</p><p>[CODE]namespace Plus.Roleplay.Handlers</p><p>{</p><p> using System;</p><p></p><p> internal class RoleplayCooldownHandler</p><p> {</p><p> public bool UserHasCooldown(int userId, string cooldownName)</p><p> {</p><p> using (var databaseConnection = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> databaseConnection.SetQuery("SELECT * FROM `rise_user_roleplay_cooldowns` WHERE `user_id` = @userId AND `cooldown_name` = @cooldownName");</p><p> databaseConnection.AddParameter("userId", userId);</p><p> databaseConnection.AddParameter("cooldownName", cooldownName);</p><p></p><p> var cooldownRow = databaseConnection.GetRow();</p><p></p><p> if (cooldownRow == null)</p><p> {</p><p> return false;</p><p> }</p><p></p><p> var dateTimeAdded = DateTime.Parse(Convert.ToString(cooldownRow["cooldown_added"]));</p><p> var span = DateTime.Now - dateTimeAdded;</p><p> var duration = Convert.ToInt32(cooldownRow["cooldown_duration"]);</p><p></p><p> return !(span.TotalSeconds >= duration);</p><p> }</p><p> }</p><p></p><p> public void AddCooldown(int userId, string cooldownName, int cooldownDuration)</p><p> {</p><p> using (var databaseConnection = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> databaseConnection.SetQuery("INSERT INTO `rise_user_roleplay_cooldowns` (`user_id`, `cooldown_name`, `cooldown_added`, `cooldown_duration`) VALUES (@userId, @cooldownName, @cooldownAdded, @cooldownDuration)");</p><p> databaseConnection.AddParameter("userId", userId);</p><p> databaseConnection.AddParameter("cooldownName", cooldownName);</p><p> databaseConnection.AddParameter("cooldownAdded", DateTime.Now.ToString());</p><p> databaseConnection.AddParameter("cooldownDuration", cooldownDuration);</p><p> databaseConnection.RunQuery();</p><p> }</p><p> }</p><p> }</p><p>}[/CODE]</p></blockquote><p></p>
[QUOTE="Seriosk, post: 410829, member: 72056"] Lol.. not really awesome BUT.. Hello. Many of you may of seen, or even coded a cool-down for an RP or hotel command. But what happens when the cool-down gets too large, and the user could just reload the client and bypass it? That is where this comes in.. it stores it in the database, so even if the emulator went down, the user would still have a cooldown on their head. It works via Date Times so it knows exactly when it was added, which results in it knowing exactly when it expires. With this tiny tiny tiny pretty useless library you can set cool downs for hours, days, weeks, anything you like. I've seen emulators such as Rage, Habbo, Fabbo, Holo all do horrible cooldown systems, but this system actually seems really easy to use, and its amazing how small it is, along with its amazing simplicity of using it. It's coded in pretty good standards, so it should be fine... It's in my opinion far better than any other cooldown system I have seen released on this forum. And before people starting commenting "its useless", maybe.. but I just coded it for simple usage, I just shared it for people looking for the same thing. SQL: [CODE]DROP TABLE IF EXISTS `user_roleplay_cooldowns`; CREATE TABLE `user_roleplay_cooldowns` ( `user_id` int(11) DEFAULT NULL, `cooldown_name` varchar(255) DEFAULT NULL, `cooldown_added` varchar(255) DEFAULT NULL, `cooldown_duration` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;[/CODE] C#: [CODE]namespace Plus.Roleplay.Handlers { using System; internal class RoleplayCooldownHandler { public bool UserHasCooldown(int userId, string cooldownName) { using (var databaseConnection = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { databaseConnection.SetQuery("SELECT * FROM `rise_user_roleplay_cooldowns` WHERE `user_id` = @userId AND `cooldown_name` = @cooldownName"); databaseConnection.AddParameter("userId", userId); databaseConnection.AddParameter("cooldownName", cooldownName); var cooldownRow = databaseConnection.GetRow(); if (cooldownRow == null) { return false; } var dateTimeAdded = DateTime.Parse(Convert.ToString(cooldownRow["cooldown_added"])); var span = DateTime.Now - dateTimeAdded; var duration = Convert.ToInt32(cooldownRow["cooldown_duration"]); return !(span.TotalSeconds >= duration); } } public void AddCooldown(int userId, string cooldownName, int cooldownDuration) { using (var databaseConnection = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { databaseConnection.SetQuery("INSERT INTO `rise_user_roleplay_cooldowns` (`user_id`, `cooldown_name`, `cooldown_added`, `cooldown_duration`) VALUES (@userId, @cooldownName, @cooldownAdded, @cooldownDuration)"); databaseConnection.AddParameter("userId", userId); databaseConnection.AddParameter("cooldownName", cooldownName); databaseConnection.AddParameter("cooldownAdded", DateTime.Now.ToString()); databaseConnection.AddParameter("cooldownDuration", cooldownDuration); databaseConnection.RunQuery(); } } } }[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Releases
Really simple and awesome RP cooldown system
Top