Junior Spellweaver
- Joined
- May 15, 2014
- Messages
- 165
- Reaction score
- 34
Requirements: Visual Studio.
Hello you all! I'm writing this tutorial because I saw that on another forum alot of people wanted to use a smokeweed commands that someone posted. Though it wasn't properly done, because it used thread.sleep to create a timer, which isn't the right way. I read on some post by Spotify where he said that tasks should be used instead so I started reading up on it. I came up with this result. If I'm doing it the wrong way, then I'm open to constructive criticism. Don't hate please
Let's get right into it shall we?
To start with open up "Plus Emulator.sln" located in the root of the emulator. Aka when you firstly open up the folder.
First off you want to head over to CommandManager.cs located in, HabboHotel/Rooms/Chat/Commands/CommandManager.cs,
Look for this:
Under that add this:
http://i.imgur.com/HoZ9Bqo.png
Now you're done with this part. Head over to HabboHotel/Rooms/Chat/Commands/User and create a new .cs file. If you're using Visual Studio right click on the folder and hover Add then create a new Class. Name it "SmokeWeedCommand.cs".
Just replace everything with this:
Now all that's left is to headover to the database and choose permission_commands. There you make a new field and name it "command_smokeweed". You set group_id to 0 and subscription_id to 0.
http://i.imgur.com/6KN49Q1.png
If you did all of that then you shouldn't have any problems and the command should work just fine.
Hello you all! I'm writing this tutorial because I saw that on another forum alot of people wanted to use a smokeweed commands that someone posted. Though it wasn't properly done, because it used thread.sleep to create a timer, which isn't the right way. I read on some post by Spotify where he said that tasks should be used instead so I started reading up on it. I came up with this result. If I'm doing it the wrong way, then I'm open to constructive criticism. Don't hate please
Let's get right into it shall we?
To start with open up "Plus Emulator.sln" located in the root of the emulator. Aka when you firstly open up the folder.
First off you want to head over to CommandManager.cs located in, HabboHotel/Rooms/Chat/Commands/CommandManager.cs,
Look for this:
Code:
[/COLOR]
[COLOR=#474B51] private void RegisterUser()[/COLOR]
[COLOR=#474B51] {[/COLOR]
[COLOR=#474B51]
Code:
this.Register("smokeweed", new SmokeWeedCommand());
Now you're done with this part. Head over to HabboHotel/Rooms/Chat/Commands/User and create a new .cs file. If you're using Visual Studio right click on the folder and hover Add then create a new Class. Name it "SmokeWeedCommand.cs".
You must be registered to see links
Just replace everything with this:
Code:
using System;[/COLOR]
[COLOR=#474B51]using System.Collections.Generic;[/COLOR]
[COLOR=#474B51]using System.Linq;[/COLOR]
[COLOR=#474B51]using System.Text;[/COLOR]
[COLOR=#474B51]using System.Threading.Tasks;[/COLOR]
[COLOR=#474B51]using Plus.HabboHotel.GameClients;[/COLOR]
[COLOR=#474B51]using Plus.Communication.Packets.Outgoing.Rooms.Chat;[/COLOR]
[COLOR=#474B51]
[/COLOR]
[COLOR=#474B51]namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun[/COLOR]
[COLOR=#474B51]{[/COLOR]
[COLOR=#474B51] class SmokeWeedCommand : IChatCommand[/COLOR]
[COLOR=#474B51] {[/COLOR]
[COLOR=#474B51] public string PermissionRequired[/COLOR]
[COLOR=#474B51] {[/COLOR]
[COLOR=#474B51] get { return "command_smokeweed"; }[/COLOR]
[COLOR=#474B51]
[/COLOR]
[COLOR=#474B51] }[/COLOR]
[COLOR=#474B51]
[/COLOR]
[COLOR=#474B51] public string Parameters[/COLOR]
[COLOR=#474B51] {[/COLOR]
[COLOR=#474B51] get { return ""; }[/COLOR]
[COLOR=#474B51]
[/COLOR]
[COLOR=#474B51] }[/COLOR]
[COLOR=#474B51]
[/COLOR]
[COLOR=#474B51] public string Description[/COLOR]
[COLOR=#474B51] {[/COLOR]
[COLOR=#474B51] get { return "Get as stoned as Snoop Dog"; }[/COLOR]
[COLOR=#474B51] }[/COLOR]
[COLOR=#474B51]
[/COLOR]
[COLOR=#474B51] public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)[/COLOR]
[COLOR=#474B51] {[/COLOR]
[COLOR=#474B51] RoomUser ThisUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);[/COLOR]
[COLOR=#474B51] if (ThisUser == null)[/COLOR]
[COLOR=#474B51] return;[/COLOR]
[COLOR=#474B51]
[/COLOR]
[COLOR=#474B51] Task.Run(async delegate[/COLOR]
[COLOR=#474B51] {[/COLOR]
[COLOR=#474B51] Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "*" + Session.GetHabbo().Username + ", rolls a spliff*", 0, ThisUser.LastBubble));[/COLOR]
[COLOR=#474B51] await Task.Delay(1000);[/COLOR]
[COLOR=#474B51] Session.GetHabbo().Effects().ApplyEffect(26);[/COLOR]
[COLOR=#474B51] Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "*" + Session.GetHabbo().Username + ", Lights up the joint*", 0, ThisUser.LastBubble));[/COLOR]
[COLOR=#474B51] await Task.Delay(500);[/COLOR]
[COLOR=#474B51] Session.GetHabbo().Effects().ApplyEffect(0);[/COLOR]
[COLOR=#474B51] await Task.Delay(1000);[/COLOR]
[COLOR=#474B51] Session.GetHabbo().Effects().ApplyEffect(53);[/COLOR]
[COLOR=#474B51] Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "*" + Session.GetHabbo().Username + ", Smokes the beautiful joint*", 0, ThisUser.LastBubble));[/COLOR]
[COLOR=#474B51] await Task.Delay(5000);[/COLOR]
[COLOR=#474B51] Session.GetHabbo().Effects().ApplyEffect(0);[/COLOR]
[COLOR=#474B51] });[/COLOR]
[COLOR=#474B51] }[/COLOR]
[COLOR=#474B51] }[/COLOR]
[COLOR=#474B51]}[/COLOR]
[COLOR=#474B51]
http://i.imgur.com/6KN49Q1.png
If you did all of that then you shouldn't have any problems and the command should work just fine.