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-07-23 17:14:55

soulrunner
Member
Joined: 2015-03-10
Posts: 185

[HELP] Arguments.

I am trying to get the bot to say what I have put after the command (!cmd <Extra bits that I want it to say>) but The code is not working. (knowing me I missed something big). Thanks in advance.

                case "say":
                    {
                        if (users.ContainsKey(m.GetInt(0)))
                        {
                            string message = m.GetString(1);
                            string username = users[m.GetInt(0)];
                            int pos2 = Array.IndexOf(owner, username);
                            string msg1 = message;
                            string[] arg = msg1.Split(' ');
                            switch (message)
                            { 
                                #region AddAdmin
                                case "!test":
                                case ".addadmin":
                                case "#addadmin":
                                    {
                                        say(arg[1]);
                                    }
                                    break;
                                    #endregion
                            }
                        }
                    }
                    break;
                    #endregion

l141.gif

Offline

#2 2015-07-23 17:47:22

Xfrogman43
Member
From: need to find a new home
Joined: 2015-02-15
Posts: 4,174

Re: [HELP] Arguments.

Not sure why you have the switch there.
You can always make an array of symbols then do:

if (message.StartsWith(array + "command"))
{
}

Or something like that.


zsbu6Xm.png thanks zoey aaaaaaaaaaaand thanks latif for the avatar

Offline

#3 2015-07-23 18:45:33

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

Re: [HELP] Arguments.

this is what I do:

case "say":
    string[] cmd = m.GetString(1).Split(' ');
    switch(cmd[0])
    {
        case ".cmd":
            con.Send("say", "Argument 1: \"" + cmd[1] + "\"");
            break;
    }

Offline

#4 2015-07-23 19:07:05

912468
Member
Joined: 2015-02-21
Posts: 212
Website

Re: [HELP] Arguments.

I guess the problem is that your seconde switch checks the whole message instead of only the command, I think you should use this code:

Code

Instead of the switch, you could also use an if-statement:

if-statement

vF0MA5o.png

Offline

#5 2015-07-23 19:18:13

soulrunner
Member
Joined: 2015-03-10
Posts: 185

Re: [HELP] Arguments.

Problem Fixed. Requesting thread lock.


l141.gif

Offline

#6 2015-07-23 19:28:34

Zoey2070
Moderation Team
From: Shakuras
Joined: 2015-02-15
Posts: 5,509

Re: [HELP] Arguments.

soulrunner wrote:

Problem Fixed. Requesting thread lock.

done


proc's discorb UnGdm07.gif stylish themes for forums/the game UnGdm07.gif
꧁꧂L O V E & C O R N꧁꧂   ᘛ⁐̤ᕐᐷ
danke bluecloud thank u raphe   Gq8tv9Z.gif [this section of my sig is dedicated to everything i've loved that's ever died]
? Hc0cu9u.gif         6yG4Efc.gif

Offline

Zoey20701437676114523819

Board footer

Powered by FluxBB

[ Started around 1734830001.0929 - Generated in 0.060 seconds, 10 queries executed - Memory usage: 1.46 MiB (Peak: 1.61 MiB) ]