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
Plus Emu Custom Commands Not Working..
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="Altercationz" data-source="post: 383777" data-attributes="member: 59038"><p>The hug command was parsing out the room user, and not the username, below is the fixed code.</p><p>[CODE]</p><p>using System;</p><p>using Plus.HabboHotel.Rooms;</p><p>using Plus.HabboHotel.GameClients;</p><p>using Plus.Communication.Packets.Outgoing.Rooms.Chat;</p><p></p><p>namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun</p><p>{</p><p> class Hug : 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 (Params.Length == 1)</p><p> {</p><p> Session.SendWhisper("You must enter a username!");</p><p> return;</p><p> }</p><p></p><p> GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);</p><p> if (TargetClient == null)</p><p> {</p><p> Session.SendWhisper("That user cannot be found, maybe they're offline or not in the room.");</p><p> return;</p><p> }</p><p></p><p> RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);</p><p> if (User == null)</p><p> {</p><p> Session.SendWhisper("The user cannot be found, maybe they're offline or not in the room.");</p><p> return;</p><p> }</p><p> RoomUser User2 = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Username);</p><p> if (User2 == null)</p><p> return;</p><p></p><p> if (!((Math.Abs(User.X - User2.X) >= 2 && (Math.Abs(User.Y - User2.Y) >= 2))))</p><p> {</p><p></p><p> Room.SendMessage(new ChatComposer(User.VirtualId, "Hugs " + User2.GetClient().GetHabbo().Username + "*", 0, User.LastBubble));</p><p> User.ApplyEffect(9);</p><p> }</p><p> else</p><p> {</p><p> Session.SendWhisper("That user is too far away, try getting closer.");</p><p> return;</p><p> }</p><p> }</p><p> }</p><p>[/CODE]</p><p>[doublepost=1473222364,1473222266][/doublepost]When checking if the user is close enough, you must also prepare it as an else statement, fixed code:</p><p>[CODE]</p><p>class Punch : IChatCommand</p><p> {</p><p> public string Description</p><p> {</p><p> get</p><p> {</p><p> return "You can punch another";</p><p> }</p><p> }</p><p></p><p> public string Parameters</p><p> {</p><p> get</p><p> {</p><p> return "%username%";</p><p> }</p><p> }</p><p></p><p> public string PermissionRequired</p><p> {</p><p> get</p><p> {</p><p> return "can_punch";</p><p> }</p><p> }</p><p></p><p> public void Execute(GameClient Session, Room Room, string[] Params)</p><p> {</p><p> RoomUser user = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Username);</p><p> RoomUser target = Room.GetRoomUserManager().GetRoomUserByHabbo(Params[1].ToString());</p><p></p><p> if (target.GetClient() == null)</p><p> {</p><p> Session.SendWhisper("Enter an username please.");</p><p> return;</p><p> }</p><p> if (!((Math.Abs(target.X - user.X) >= 2) || (Math.Abs(target.Y - user.Y) >= 2)))</p><p> {</p><p> user.OnChat(0, "*Punched " + target.GetClient().GetHabbo().Username + " in the face*", true);</p><p> target.OnChat(0, "Dude!! That hurts!!", true);</p><p> user.GetClient().GetHabbo().Effects().ApplyEffect(53);</p><p> target.GetClient().GetHabbo().Effects().ApplyEffect(53);</p><p> }</p><p> else</p><p> {</p><p> Session.SendWhisper("You're too far away! try getting closer.");</p><p> return;</p><p> }</p><p> }</p><p> }</p><p>}</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="Altercationz, post: 383777, member: 59038"] The hug command was parsing out the room user, and not the username, below is the fixed code. [CODE] using System; using Plus.HabboHotel.Rooms; using Plus.HabboHotel.GameClients; using Plus.Communication.Packets.Outgoing.Rooms.Chat; namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun { class Hug : 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 (Params.Length == 1) { Session.SendWhisper("You must enter a username!"); return; } GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]); if (TargetClient == null) { Session.SendWhisper("That user cannot be found, maybe they're offline or not in the room."); return; } RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id); if (User == null) { Session.SendWhisper("The user cannot be found, maybe they're offline or not in the room."); return; } RoomUser User2 = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Username); if (User2 == null) return; if (!((Math.Abs(User.X - User2.X) >= 2 && (Math.Abs(User.Y - User2.Y) >= 2)))) { Room.SendMessage(new ChatComposer(User.VirtualId, "Hugs " + User2.GetClient().GetHabbo().Username + "*", 0, User.LastBubble)); User.ApplyEffect(9); } else { Session.SendWhisper("That user is too far away, try getting closer."); return; } } } [/CODE] [doublepost=1473222364,1473222266][/doublepost]When checking if the user is close enough, you must also prepare it as an else statement, fixed code: [CODE] class Punch : IChatCommand { public string Description { get { return "You can punch another"; } } public string Parameters { get { return "%username%"; } } public string PermissionRequired { get { return "can_punch"; } } public void Execute(GameClient Session, Room Room, string[] Params) { RoomUser user = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Username); RoomUser target = Room.GetRoomUserManager().GetRoomUserByHabbo(Params[1].ToString()); if (target.GetClient() == null) { Session.SendWhisper("Enter an username please."); return; } if (!((Math.Abs(target.X - user.X) >= 2) || (Math.Abs(target.Y - user.Y) >= 2))) { user.OnChat(0, "*Punched " + target.GetClient().GetHabbo().Username + " in the face*", true); target.OnChat(0, "Dude!! That hurts!!", true); user.GetClient().GetHabbo().Effects().ApplyEffect(53); target.GetClient().GetHabbo().Effects().ApplyEffect(53); } else { Session.SendWhisper("You're too far away! try getting closer."); return; } } } } [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
Plus Emu Custom Commands Not Working..
Top