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
Server Releases
Welcome Bot
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: 428191" data-attributes="member: 59038"><p>Alright,</p><p>Clearly I should of thought this out before releasing it.</p><p>I have now placed this on a timer which will elapse and remove the bot from the room once it's finished it's task.</p><p>I changed the way it checks if the user has already made a room, it'll still check if the user has 0 rooms but it will also check if the user has had the "Welcome bot deployed" which will be set as a bool 0/1 in the database indicating if the bot has been sent and greeted and rewarded the specific user.</p><p>I won't be using this myself which means I didn't cache "WelcomeBotDeployed" I just made it as a public bool not caching anything for demonstration purposes, If you're going to use this code I assume you know how to do that yourself (If not i added some step by step comments in the code itself, I will not be providing any further help with this as I've done most of the work for you since original release)</p><p></p><p>Below is the new codes, the timer itself and what happens when it has elapsed.</p><p>[CODE]</p><p>internal void WelcomeBot()</p><p> {</p><p> if (WelcomeTask != null)</p><p> {</p><p> WelcomeTask.Dispose();</p><p> }</p><p></p><p> if (WelcomeTimer != null)</p><p> {</p><p> WelcomeTimer.Dispose();</p><p> }</p><p></p><p> if (this.UsersRooms.Count < 0 && WelcomeBotDeployed)</p><p> {</p><p> return; // User has created a room already / or had the bot deployed.</p><p> }</p><p> else</p><p> {</p><p> WelcomeBotDeployed = true; // set in database forever. bool (0/1)</p><p></p><p> // Execute.</p><p> Room NewRoom = this.CurrentRoom;</p><p> Bot Noob = null;</p><p> int X = 3 - 10;</p><p> int Y = 3 - 10;</p><p></p><p> // Bot Id Randomizer.</p><p> Random Random = new Random();</p><p> int BotId = Random.Next(1, 9999);</p><p></p><p> List<RandomSpeech> Speech = new List<RandomSpeech>();</p><p></p><p> RoomUser Bot = NewRoom.GetRoomUserManager().DeployBot(new RoomBot(BotId, this.CurrentRoomId, "bartender", "freeroam", "Disguised", "Welcome!", Noob.Figure, X, Y, 0, 4, 0, 0, 0, 0, ref Speech, "", 0, Noob.OwnerId, false, 0, false, 0), null);</p><p> Bot.Chat("Welcome to the hotel!", false, 0);</p><p> // Have the bot do whatever else here.</p><p></p><p> WelcomeTimer = new System.Timers.Timer();</p><p> WelcomeTimer.AutoReset = false;</p><p> WelcomeTimer.Elapsed += WelcomeBot_Elapsed;</p><p> WelcomeTimer.Interval = 60000; // time until the bot is kicked.</p><p></p><p> WelcomeTask = new System.Threading.Tasks.Task(WelcomeTimer.Start);</p><p> WelcomeTask.Start();</p><p> }</p><p> }[/CODE]</p><p></p><p>[CODE]</p><p>private void WelcomeBot_Elapsed(object sender, System.Timers.ElapsedEventArgs e)</p><p> {</p><p> if (GetClient() == null)</p><p> {</p><p> WelcomeTask.Dispose();</p><p> WelcomeTimer.Dispose();</p><p> return;</p><p> }</p><p></p><p> Room Room = this.CurrentRoom;</p><p> foreach (RoomUser User in Room.GetRoomUserManager().GetUserList().ToList())</p><p> {</p><p> if (User == null || !User.IsBot) // make sure you're removing the bot.</p><p> continue;</p><p></p><p> RoomUser Bot = null;</p><p> if (!Room.GetRoomUserManager().TryGetBot(User.BotData.Id, out Bot))</p><p> return;</p><p></p><p> Room.GetRoomUserManager().RemoveBot(Bot.VirtualId, true);</p><p> // end the timer and task.</p><p> WelcomeTask.Dispose();</p><p> WelcomeTimer.Dispose();</p><p> }</p><p> }[/CODE]</p><p></p><p>In the EnterRoom Method, "CheckFirstRoom" can be replaced with</p><p>[CODE]WelcomeBot();[/CODE] and you must put</p><p>[CODE]</p><p>public Timer WelcomeTimer;</p><p>public Task WelcomeTask;[/CODE] in Habbo.cs</p><p> and it's simple as that.</p><p></p><p>Enjoy.</p></blockquote><p></p>
[QUOTE="Altercationz, post: 428191, member: 59038"] Alright, Clearly I should of thought this out before releasing it. I have now placed this on a timer which will elapse and remove the bot from the room once it's finished it's task. I changed the way it checks if the user has already made a room, it'll still check if the user has 0 rooms but it will also check if the user has had the "Welcome bot deployed" which will be set as a bool 0/1 in the database indicating if the bot has been sent and greeted and rewarded the specific user. I won't be using this myself which means I didn't cache "WelcomeBotDeployed" I just made it as a public bool not caching anything for demonstration purposes, If you're going to use this code I assume you know how to do that yourself (If not i added some step by step comments in the code itself, I will not be providing any further help with this as I've done most of the work for you since original release) Below is the new codes, the timer itself and what happens when it has elapsed. [CODE] internal void WelcomeBot() { if (WelcomeTask != null) { WelcomeTask.Dispose(); } if (WelcomeTimer != null) { WelcomeTimer.Dispose(); } if (this.UsersRooms.Count < 0 && WelcomeBotDeployed) { return; // User has created a room already / or had the bot deployed. } else { WelcomeBotDeployed = true; // set in database forever. bool (0/1) // Execute. Room NewRoom = this.CurrentRoom; Bot Noob = null; int X = 3 - 10; int Y = 3 - 10; // Bot Id Randomizer. Random Random = new Random(); int BotId = Random.Next(1, 9999); List<RandomSpeech> Speech = new List<RandomSpeech>(); RoomUser Bot = NewRoom.GetRoomUserManager().DeployBot(new RoomBot(BotId, this.CurrentRoomId, "bartender", "freeroam", "Disguised", "Welcome!", Noob.Figure, X, Y, 0, 4, 0, 0, 0, 0, ref Speech, "", 0, Noob.OwnerId, false, 0, false, 0), null); Bot.Chat("Welcome to the hotel!", false, 0); // Have the bot do whatever else here. WelcomeTimer = new System.Timers.Timer(); WelcomeTimer.AutoReset = false; WelcomeTimer.Elapsed += WelcomeBot_Elapsed; WelcomeTimer.Interval = 60000; // time until the bot is kicked. WelcomeTask = new System.Threading.Tasks.Task(WelcomeTimer.Start); WelcomeTask.Start(); } }[/CODE] [CODE] private void WelcomeBot_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (GetClient() == null) { WelcomeTask.Dispose(); WelcomeTimer.Dispose(); return; } Room Room = this.CurrentRoom; foreach (RoomUser User in Room.GetRoomUserManager().GetUserList().ToList()) { if (User == null || !User.IsBot) // make sure you're removing the bot. continue; RoomUser Bot = null; if (!Room.GetRoomUserManager().TryGetBot(User.BotData.Id, out Bot)) return; Room.GetRoomUserManager().RemoveBot(Bot.VirtualId, true); // end the timer and task. WelcomeTask.Dispose(); WelcomeTimer.Dispose(); } }[/CODE] In the EnterRoom Method, "CheckFirstRoom" can be replaced with [CODE]WelcomeBot();[/CODE] and you must put [CODE] public Timer WelcomeTimer; public Task WelcomeTask;[/CODE] in Habbo.cs and it's simple as that. Enjoy. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Releases
Server Releases
Welcome Bot
Top