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 Q&A
PlusEmulator Command Cooldowns
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="Velaski" data-source="post: 386144" data-attributes="member: 61835"><p>I remember a good friend Jordan posting this somewhere. Havent got visual studio rn, but I'll have a crack.</p><p></p><p>In RoomUser.cs, add:</p><p>[CODE]public static DateTime CommandExecuted;[/CODE]</p><p></p><p>In you're commands:</p><p></p><p>[CODE]TimeSpan Cooldown = DateTime.Now - RoomUser.CommandExecuted;</p><p> if (Cooldown.Seconds >= 5)</p><p> {</p><p> //PUT EVERYTHING UNDER public void(Execute idk) Here</p><p> RoomUser.CommandExecuted = DateTime.Now;</p><p> }</p><p></p><p> else</p><p> {</p><p> int num = checked(5 - Cooldown.Seconds);</p><p> Session.SendWhisper("Cooldown! You must wait 5 seconds until you can do that!");</p><p> </p><p> }</p><p> }[/CODE]</p><p></p><p>Where it says "//PUT EVERYTHING UNDER public void(Execute idk) Here" You'll see under your public void Execute in your command.</p><p>This :</p><p>[CODE]public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)</p><p> {</p><p>Put it here.</p><p>}</p><p></p><p>[/CODE]</p><p></p><p></p><p>If you still don't understand, heres an example of a simple rko command</p><p>[CODE]class RKOCommand : IChatCommand</p><p> {</p><p> public string PermissionRequired</p><p> {</p><p> get { return "command_rko"; }</p><p> }</p><p></p><p> public string Parameters</p><p> {</p><p> get { return "%target%"; }</p><p> }</p><p></p><p> public string Description</p><p> {</p><p> get { return "RKO a user."; }</p><p> }</p><p></p><p> public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)</p><p> {</p><p></p><p></p><p>TimeSpan Cooldown = DateTime.Now - RoomUser.CommandExecuted;</p><p> if (Cooldown.Seconds >= 5)</p><p> {</p><p></p><p></p><p> if (Params.Length == 1)</p><p> {</p><p> Session.SendWhisper("Please enter a username");</p><p> return;</p><p> }</p><p> GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);</p><p></p><p> RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id);</p><p></p><p> RoomUser ThisUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);</p><p> if (User == null)</p><p>{</p><p>Session.SendWhisper("Error in command execution");</p><p> return;</p><p>}</p><p> if (TargetClient == null)</p><p> </p><p>{</p><p>Session.SendWhisper("Target not found");</p><p> return;</p><p>}</p><p> if (TargetClient.GetHabbo().CurrentRoomId == Session.GetHabbo().CurrentRoomId && (Math.Abs(ThisUser.X - User.X) < 3 && Math.Abs(ThisUser.Y - User.Y) < 3))</p><p> {</p><p> Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "*RKO OUTTA NOWHERE ON " + TargetClient.GetHabbo().Username + "*", 0, User.LastBubble));</p><p> Room.SendMessage(new ChatComposer(User.VirtualId, "*feels the viper effect well*", 0, User.LastBubble));</p><p> }</p><p></p><p> if (!User.Statusses.ContainsKey("sit"))</p><p> {</p><p> if ((User.RotBody % 2) == 0)</p><p> {</p><p> if (User == null)</p><p> return;</p><p></p><p> try</p><p> {</p><p> User.Statusses.Add("sit", "1.0");</p><p> User.Z -= 0.35;</p><p> User.isSitting = true;</p><p> User.UpdateNeeded = true;</p><p> }</p><p> catch { }</p><p> }</p><p> else</p><p> {</p><p> User.RotBody--;</p><p> User.Statusses.Add("sit", "1.0");</p><p> User.Z -= 0.35;</p><p> User.isSitting = true;</p><p> User.UpdateNeeded = true;</p><p> }</p><p> }</p><p></p><p> RoomUser.CommandExecuted = DateTime.Now;</p><p> }</p><p></p><p> else</p><p> {</p><p> int num = checked(5 - Cooldown.Seconds);</p><p> Session.SendWhisper("Cooldown! You must wait 5 seconds until you can do that!");</p><p> </p><p> }</p><p> }</p><p></p><p> }</p><p> }</p><p>}[/CODE]</p><p></p><p>[USER=59038]@Altercationz[/USER] thanks for this.</p></blockquote><p></p>
[QUOTE="Velaski, post: 386144, member: 61835"] I remember a good friend Jordan posting this somewhere. Havent got visual studio rn, but I'll have a crack. In RoomUser.cs, add: [CODE]public static DateTime CommandExecuted;[/CODE] In you're commands: [CODE]TimeSpan Cooldown = DateTime.Now - RoomUser.CommandExecuted; if (Cooldown.Seconds >= 5) { //PUT EVERYTHING UNDER public void(Execute idk) Here RoomUser.CommandExecuted = DateTime.Now; } else { int num = checked(5 - Cooldown.Seconds); Session.SendWhisper("Cooldown! You must wait 5 seconds until you can do that!"); } }[/CODE] Where it says "//PUT EVERYTHING UNDER public void(Execute idk) Here" You'll see under your public void Execute in your command. This : [CODE]public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { Put it here. } [/CODE] If you still don't understand, heres an example of a simple rko command [CODE]class RKOCommand : IChatCommand { public string PermissionRequired { get { return "command_rko"; } } public string Parameters { get { return "%target%"; } } public string Description { get { return "RKO a user."; } } public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { TimeSpan Cooldown = DateTime.Now - RoomUser.CommandExecuted; if (Cooldown.Seconds >= 5) { if (Params.Length == 1) { Session.SendWhisper("Please enter a username"); return; } GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]); RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id); RoomUser ThisUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id); if (User == null) { Session.SendWhisper("Error in command execution"); return; } if (TargetClient == null) { Session.SendWhisper("Target not found"); return; } if (TargetClient.GetHabbo().CurrentRoomId == Session.GetHabbo().CurrentRoomId && (Math.Abs(ThisUser.X - User.X) < 3 && Math.Abs(ThisUser.Y - User.Y) < 3)) { Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "*RKO OUTTA NOWHERE ON " + TargetClient.GetHabbo().Username + "*", 0, User.LastBubble)); Room.SendMessage(new ChatComposer(User.VirtualId, "*feels the viper effect well*", 0, User.LastBubble)); } if (!User.Statusses.ContainsKey("sit")) { if ((User.RotBody % 2) == 0) { if (User == null) return; try { User.Statusses.Add("sit", "1.0"); User.Z -= 0.35; User.isSitting = true; User.UpdateNeeded = true; } catch { } } else { User.RotBody--; User.Statusses.Add("sit", "1.0"); User.Z -= 0.35; User.isSitting = true; User.UpdateNeeded = true; } } RoomUser.CommandExecuted = DateTime.Now; } else { int num = checked(5 - Cooldown.Seconds); Session.SendWhisper("Cooldown! You must wait 5 seconds until you can do that!"); } } } } }[/CODE] [USER=59038]@Altercationz[/USER] thanks for this. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
PlusEmulator Command Cooldowns
Top