Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2015-09-06 00:40:06

shadowda
Member
From: somewhere probably.
Joined: 2015-02-19
Posts: 1,015

[question] bot using chat

Ok. so when i try to have a bot pm

con.Send("say", "/pm " + username + "Commands: !register, !stats, !help ");

it does nothing.

sometimes when in other places a con.Send("say", "/pm " + username + "what ever i want"); works

 if (m.Type == "say")
            {
                if (users.ContainsKey(m.GetInt(0)))
                {
                    string msg = m.GetString(1);
                    string username = users[m.GetInt(0)];
                    string[] split = msg.Split(' ');
                    string command = "";
                    string[] poss = new string[] { ".", "!", "%", "@", "#", "$" };
                    if (poss.Contains(split[0].Substring(0, 1)))
                    {
                        split[0] = split[0].Remove(0, 1);
                        msg = msg.Remove(0, 1);
                        command = split[0];
                    }
                    if (string.Compare(command, "stats") == 0)
                    {
                        if (username_textBox1.Text == username) //start of stats tree 
                        {
                            con.Send("say", "/pm " + username + "  Stats:" + " Class:" + class_textBox1.Text + " HP:" + health_textBox1.Text + " MP:" + magic_textBox1.Text + " att:" + attack_textBox1.Text + " def:" + defence_textBox1.Text);
                        }

both of these lines of code are basically the same. the only differences being

if (string.Compare(command, "stats") == 0)
con.Send("say", "/pm " + username + "  Stats:" + " Class:" + class_textBox1.Text + " HP:" + health_textBox1.Text + " MP:" + magic_textBox1.Text + " att:" + attack_textBox1.Text + " def:" + defence_textBox1.Text);

and the fack that the code shown above goes on for quite some time with

If()
{
}
else

the last problem is that you can not have two con.Sends in a row

con.Send("say", "/pm " + username + " Welcome to the rpg. If you die you must re-register");
con.Send("say", "/pm " + username + " say !help for help");

it would say the first one but never the second.

what can i do about all this?


color = #1E1E1E       

latest?cb=20150604065609

Offline

#2 2015-09-06 00:46:07

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: [question] bot using chat

con.Send("say", "/pm " + username + "Commands: !register, !stats, !help ");

You forgot a space, "Commands into " Commands

con.Send("say", "/pm " + username + " Welcome to the rpg. If you die you must re-register");
con.Send("say", "/pm " + username + " say !help for help");

Should be re-did to:

con.Send("say", "/pm " + username + " Welcome to the rpg. If you die you must re-register");
System.Threading.Thread.Sleep(100);
con.Send("say", "/pm " + username + " say !help for help");

Or, you can do using System.Threading; at the beginning and just do

Thread.Sleep(100);

Offline

#3 2015-09-06 15:53:21, last edited by shadowda (2015-09-06 16:00:29)

shadowda
Member
From: somewhere probably.
Joined: 2015-02-19
Posts: 1,015

Re: [question] bot using chat

ninjasupeatsninja wrote:
con.Send("say", "/pm " + username + " Welcome to the rpg. If you die you must re-register");
System.Threading.Thread.Sleep(100);
con.Send("say", "/pm " + username + " say !help for help");

Or, you can do using System.Threading; at the beginning and just do

Thread.Sleep(100);

did not work.

also, where do you mean exactly by beginning?

EDIT: i got it.

Thread.Sleep(100);

(100) was not enough time


color = #1E1E1E       

latest?cb=20150604065609

Offline

#4 2015-09-06 17:09:57

capasha
Member
Joined: 2015-02-21
Posts: 4,066

Re: [question] bot using chat

shadowda wrote:

did not work.

also, where do you mean exactly by beginning?

EDIT: i got it.

Thread.Sleep(100);

(100) was not enough time

Then change delay. Try 750.

Offline

Wooted by:

#5 2015-09-06 18:59:25

shadowda
Member
From: somewhere probably.
Joined: 2015-02-19
Posts: 1,015

Re: [question] bot using chat

capasha wrote:
shadowda wrote:

did not work.

also, where do you mean exactly by beginning?

EDIT: i got it.

Thread.Sleep(100);

(100) was not enough time

Then change delay. Try 750.

the minimum i need for it to work seems to be 550


color = #1E1E1E       

latest?cb=20150604065609

Offline

shadowda1441562365539193

Board footer

Powered by FluxBB

[ Started around 1732456880.9417 - Generated in 0.051 seconds, 12 queries executed - Memory usage: 1.47 MiB (Peak: 1.6 MiB) ]