[Help] Bot Problem

Status
Not open for further replies.

NickZeGamerX

Member
Apr 2, 2016
79
9
hello devbest user reading this, how do I fix this? :


You must be registered for see images attach

As you can see in the screenshot, the 3rd line (the one with yellow underline) does not get executed/sent or rather the Bot won't say it, But the bot does say it unless if add `another` line and the new line that is added won't have the bot say it :[

solid proof:
You must be registered for see images attach

When another line is added:
You must be registered for see images attach
 

Joe

Well-Known Member
Jun 10, 2012
4,172
1,955
Not sure why this was posted under Habbo Tutorials.

What emulator and build are you using? Couldn’t you copy and paste the last line twice would that work?
 

NickZeGamerX

Member
Apr 2, 2016
79
9
Not sure why this was posted under Habbo Tutorials.

What emulator and build are you using? Couldn’t you copy and paste the last line twice would that work?

Sorry about that, I wasn't paying attention.

But anyways, I am using PlusEmu Release 2
 
  • Like
Reactions: Joe

Karel

Member
May 15, 2019
80
13
Thank you for finding this haha :) I took a look at it and found the problem.

RoomBot.cs:
Code:
public RandomSpeech GetRandomSpeech()
        {
            var rand = new Random();

            if (RandomSpeech.Count < 1)
                return new RandomSpeech("", 0);
            return RandomSpeech[rand.Next(0, (RandomSpeech.Count) - 1)];
        }
When you remove the '- 1' it will work correctly!
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
Thank you for finding this haha :) I took a look at it and found the problem.

RoomBot.cs:
Code:
public RandomSpeech GetRandomSpeech()
        {
            var rand = new Random();

            if (RandomSpeech.Count < 1)
                return new RandomSpeech("", 0);
            return RandomSpeech[rand.Next(0, (RandomSpeech.Count) - 1)];
        }
When you remove the '- 1' it will work correctly!
The reason for this is because of Random.Next is exclusive of the upper bound. The count of your random speech list is 3 so you were looking between indexes 0-2 but it could only return 0 or 1. Nice find, added this solution into my source as well, never noticed it :) I would always add a blank line after, I thought it just required an empty line on the next one to account for that input.
 
  • Like
Reactions: Joe
Status
Not open for further replies.

Users who are viewing this thread

Top