+ Reply to Thread
Results 1 to 10 of 10

Thread: Best Solution For Chat Commands?

  1. #1
    Wire Amateur LeonBlade's Avatar
    Join Date
    Apr 2009
    Location
    Blossvale, NY
    Posts
    77

    Default Best Solution For Chat Commands?

    Heylo everyone...

    I got a quick question and need some help.
    I want to be able to say stuff in the game Chat and then use that as a "command" if you will.

    Right now I'm using something like this:
    [highlight=e2]
    if (owner():lastSaid() == "!on")
    {
    #on stuff here
    }
    [/highlight]

    Now I know this is definitely not the best way at all to do this...
    It will constantly check this every loop around if an interval is attached.

    So is there a way I can possibly only call the Expression when my chat has changed?

    I tried using:
    [highlight=e2]
    if (owner():lastSaidWhen() == LastSaid)
    {
    #already checked this message!
    }
    [/highlight]

    Is this the best approach?

    Thanks,
    LeonBlade
    Code:
    if (powerLevel > 9000) {
         print "IT'S OVER 9000!!!11";
    }
    Code:
    mov #status,1337

  2. #2
    Spucatum Tauri Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    6,009

    Default Re: Best Solution For Chat Commands?

    Code:
    runOnChat(1)
    if ( chatClk(owner()) ) {
      #Do all your chat stuff, remove owner() if you want it to run on any player.
    }
    My signature has a point.
    Quote Originally Posted by Squeakyneb View Post
    when l3ulletje says do it, do it.
    That

    Quote Originally Posted by Anticept View Post
    By the way, Bull is in charge.

  3. #3
    Wiremod Helper Donkie's Avatar
    Join Date
    May 2008
    Location
    Sweden
    Posts
    1,660

    Default Re: Best Solution For Chat Commands?

    Thanks to hunter(some number :P) he helped me with exactly this, what i got out is:
    [highlight=e2]
    runOnChat(1)
    if(chatclk()=owner():lastSpoke()) # You could have your own entity
    #there like Pod:lastSpoke()
    if(LS=="!mypos"){Do stuff} # LS is an string.
    }
    [/highlight]
    I think its owner():lastSpoke() like that, but i could have any fail in it.
    Get out. Seriously, do it.

  4. #4
    Wire Amateur Playzr's Avatar
    Join Date
    May 2007
    Location
    UK
    Posts
    93

    Default Re: Best Solution For Chat Commands?

    If you do it like this...

    Code:
    Said = owner():lastSaid():lower()
    if(Said:find("hello")){
        #do stuff
    }
    ...then you're converting it to lowercase, so its no longer case sensitive, and you can use the string to search for the word so the command doesnt have to be word for word, you can be more or less specific with your commands.

  5. #5
    Wire Amateur LeonBlade's Avatar
    Join Date
    Apr 2009
    Location
    Blossvale, NY
    Posts
    77

    Default Re: Best Solution For Chat Commands?

    Quote Originally Posted by Playzr View Post
    If you do it like this...

    Code:
    Said = owner():lastSaid():lower()
    if(Said:find("hello")){
        #do stuff
    }
    ...then you're converting it to lowercase, so its no longer case sensitive, and you can use the string to search for the word so the command doesnt have to be word for word, you can be more or less specific with your commands.
    Yeah I know I was thinking about that...
    Is there some sort of switch command in Expression I can use to make things easier?
    Last edited by LeonBlade; 06-02-2009 at 11:53 PM.
    Code:
    if (powerLevel > 9000) {
         print "IT'S OVER 9000!!!11";
    }
    Code:
    mov #status,1337

  6. #6
    Wiremod Helper Donkie's Avatar
    Join Date
    May 2008
    Location
    Sweden
    Posts
    1,660

    Default Re: Best Solution For Chat Commands?

    Switch command?
    Get out. Seriously, do it.

  7. #7
    Wire Amateur NightReaper's Avatar
    Join Date
    Jun 2007
    Location
    St.Awful
    Posts
    68

    Default Re: Best Solution For Chat Commands?

    I think he mean as in a conditional statement, like an if...elseif...else statement, but only comparing one value for many outcomes.

  8. #8
    Wire Amateur no_one's Avatar
    Join Date
    Mar 2009
    Posts
    88

    Post Re: Best Solution For Chat Commands?

    Quote Originally Posted by LeonBlade View Post
    Yeah I know I was thinking about that...
    Is there some sort of switch command in Expression I can use to make things easier?
    Do you mean like a toggle? Try this

    [highlight=e2]
    Command=owner():lastSaid()

    if (chatClk(owner())) # or you can do
    # if (chatClk() & lastSpoke()=owner()
    # NOT lastSaidWhen(), I believe that
    # gives you the time that you said something
    {
    if (Command="Switch")
    {
    Switch=!Switch
    }
    #other chat commands you want
    }

    if (Switch)
    {
    #Stuff
    }[/highlight]
    New to Expression 2? Read this: E2 Guide [WIP]
    Steam ID ► Easton741
    Connect Now!

  9. #9
    Wire Amateur NightReaper's Avatar
    Join Date
    Jun 2007
    Location
    St.Awful
    Posts
    68

    Default Re: Best Solution For Chat Commands?

    no, a toggle wouldn't be any use here. He means a Switch statement, something like this:

    PHP Code:
    switch (String)
        {
        case 
    "What\'s your name?":
            echo 
    "My name is ...";
            break;
        case 
    "What\'s your age?":
            echo 
    "My age Is ...";
            break;
        case 
    "What\'s your gender?":
            echo 
    "I\'m a ...";
            break;
        } 
    but thats PHP, he means one for E2

  10. #10
    Wire Amateur no_one's Avatar
    Join Date
    Mar 2009
    Posts
    88

    Default Re: Best Solution For Chat Commands?

    ohh thats easy

    [highlight=e2]
    Command=owner():lastSaid():lower()

    if (chatClk(owner()))
    {
    if (Command="Hello, how are you?")
    {
    concmd(say "I am fine. Nice weather we are having.")
    }
    #other chat commands you want
    }[/highlight]

    Make sure you have concmd turned on through your console. Although the wiki does not mention how to do that.
    New to Expression 2? Read this: E2 Guide [WIP]
    Steam ID ► Easton741
    Connect Now!

+ Reply to Thread

Similar Threads

  1. SOLUTION TO WEAK ADV DUPES!!!
    By Pyro-Fire in forum Wiremod General Chat
    Replies: 62
    Last Post: 07-07-2009, 06:24 AM
  2. Possible solution to old SVNs
    By kna in forum Wiremod General Chat
    Replies: 7
    Last Post: 04-18-2009, 02:36 PM
  3. Getting Find() and Chat Commands To Work
    By Alchemise in forum Expression 2 Discussion & Help
    Replies: 9
    Last Post: 03-24-2009, 10:37 AM
  4. Garrys for Mac? I may have a solution
    By willthemage in forum Off-Topic
    Replies: 7
    Last Post: 08-29-2008, 09:35 PM
  5. Ram doesnt work (I have solution, tho)
    By Pyro-Fire in forum Bug Reports
    Replies: 1
    Last Post: 08-23-2008, 04:08 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots