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
Emulator Command Delay Issue
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="Supermario" data-source="post: 404219" data-attributes="member: 65433"><p>Hi,</p><p></p><p>I saw Sage tutorial about emulator command delays (<a href="https://devbest.com/threads/creating-emulator-commands-with-delays.81492" target="_blank">https://devbest.com/threads/creating-emulator-commands-with-delays.81492</a>) but I have some issues. The delay works, but it breaks my cool down code, and I have no idea why. Here is my HugCommand.cs code.</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></p><p>using Plus.HabboHotel.Rooms;</p><p>using Plus.HabboHotel.GameClients;</p><p>using Plus.Communication.Packets.Outgoing.Rooms.Chat;</p><p>using System.Threading.Tasks;</p><p></p><p>namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun</p><p>{</p><p> class HugCommand : IChatCommand</p><p> {</p><p> public string PermissionRequired</p><p> {</p><p> get { return "command_hug"; }</p><p> }</p><p> public string Parameters</p><p> {</p><p> get { return "%username%"; }</p><p> }</p><p> public string Description</p><p> {</p><p> get { return "Hug another user."; }</p><p> }</p><p> public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)</p><p> {</p><p> if (!Room.rpEnabled)</p><p> {</p><p> Session.SendWhisper("Oops, it appears that the room owner has disabled the ability to use rp commands in this room.");</p><p> return;</p><p> }</p><p> if (Params.Length == 1)</p><p> {</p><p> Session.SendWhisper("Please enter the username of the person you want to Hug.");</p><p> return;</p><p> }</p><p> GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);</p><p> if (TargetClient == null)</p><p> {</p><p> Session.SendWhisper("The user was not found in the room, maybe they're offline.");</p><p> return;</p><p> }</p><p> RoomUser TargetUser = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id);</p><p> if (TargetUser == null)</p><p> {</p><p> Session.SendWhisper("An error occured while finding that user, maybe they're offline or not in this room.");</p><p> }</p><p> if (TargetClient.GetHabbo().Username == Session.GetHabbo().Username)</p><p> {</p><p> Session.SendWhisper("You cannot Hug yourself!");</p><p> return;</p><p> }</p><p></p><p> RoomUser ThisUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);</p><p> if (ThisUser == null)</p><p> return;</p><p></p><p> if (!((Math.Abs(TargetUser.X - ThisUser.X) >= 2) || (Math.Abs(TargetUser.Y - ThisUser.Y) >= 2)))</p><p> {</p><p> TimeSpan Cooldown = DateTime.Now - Session.GetHabbo().HugCoolDown;</p><p> if (Cooldown.TotalSeconds >= 30)</p><p> {</p><p> Task.Run(async delegate</p><p> {</p><p> Room.SendMessage(new ShoutComposer(ThisUser.VirtualId, "| *Hugs " + Params[1] + "* |", 0, ThisUser.LastBubble = 16));</p><p> await Task.Delay(1000);</p><p> Room.SendMessage(new ShoutComposer(TargetUser.VirtualId, "| *Is hugged and feeling loved* |", 0, ThisUser.LastBubble = 16));</p><p> await Task.Delay(1000);</p><p> TargetUser.ApplyEffect(168);</p><p> await Task.Delay(4000);</p><p> ThisUser.ApplyEffect(0);</p><p> ThisUser.UpdateNeeded = true;</p><p> TargetUser.ApplyEffect(0);</p><p> TargetUser.UpdateNeeded = true;</p><p> Session.GetHabbo().HugCoolDown = DateTime.Now;</p><p> });</p><p> }</p><p> else</p><p> {</p><p> int num = (int)(30 - Cooldown.TotalSeconds);</p><p> Session.SendWhisper("Cooldown Mode: " + num + " seconds left until you can do that!", 0);</p><p> return;</p><p> }</p><p> }</p><p> else</p><p> {</p><p> Session.SendWhisper("You're too far away! please try getting closer.");</p><p> return;</p><p> }</p><p> }</p><p> }</p><p>}[/CODE]</p><p>[doublepost=1490107592,1489934472][/doublepost]bump</p></blockquote><p></p>
[QUOTE="Supermario, post: 404219, member: 65433"] Hi, I saw Sage tutorial about emulator command delays ([URL]https://devbest.com/threads/creating-emulator-commands-with-delays.81492[/URL]) but I have some issues. The delay works, but it breaks my cool down code, and I have no idea why. Here is my HugCommand.cs code. [CODE]using System; using System.Linq; using System.Text; using System.Collections.Generic; using Plus.HabboHotel.Rooms; using Plus.HabboHotel.GameClients; using Plus.Communication.Packets.Outgoing.Rooms.Chat; using System.Threading.Tasks; namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun { class HugCommand : IChatCommand { public string PermissionRequired { get { return "command_hug"; } } public string Parameters { get { return "%username%"; } } public string Description { get { return "Hug another user."; } } public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { if (!Room.rpEnabled) { Session.SendWhisper("Oops, it appears that the room owner has disabled the ability to use rp commands in this room."); return; } if (Params.Length == 1) { Session.SendWhisper("Please enter the username of the person you want to Hug."); return; } GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]); if (TargetClient == null) { Session.SendWhisper("The user was not found in the room, maybe they're offline."); return; } RoomUser TargetUser = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id); if (TargetUser == null) { Session.SendWhisper("An error occured while finding that user, maybe they're offline or not in this room."); } if (TargetClient.GetHabbo().Username == Session.GetHabbo().Username) { Session.SendWhisper("You cannot Hug yourself!"); return; } RoomUser ThisUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id); if (ThisUser == null) return; if (!((Math.Abs(TargetUser.X - ThisUser.X) >= 2) || (Math.Abs(TargetUser.Y - ThisUser.Y) >= 2))) { TimeSpan Cooldown = DateTime.Now - Session.GetHabbo().HugCoolDown; if (Cooldown.TotalSeconds >= 30) { Task.Run(async delegate { Room.SendMessage(new ShoutComposer(ThisUser.VirtualId, "| *Hugs " + Params[1] + "* |", 0, ThisUser.LastBubble = 16)); await Task.Delay(1000); Room.SendMessage(new ShoutComposer(TargetUser.VirtualId, "| *Is hugged and feeling loved* |", 0, ThisUser.LastBubble = 16)); await Task.Delay(1000); TargetUser.ApplyEffect(168); await Task.Delay(4000); ThisUser.ApplyEffect(0); ThisUser.UpdateNeeded = true; TargetUser.ApplyEffect(0); TargetUser.UpdateNeeded = true; Session.GetHabbo().HugCoolDown = DateTime.Now; }); } else { int num = (int)(30 - Cooldown.TotalSeconds); Session.SendWhisper("Cooldown Mode: " + num + " seconds left until you can do that!", 0); return; } } else { Session.SendWhisper("You're too far away! please try getting closer."); return; } } } }[/CODE] [doublepost=1490107592,1489934472][/doublepost]bump [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
Emulator Command Delay Issue
Top