Results 1 to 6 of 6
  1. #1
    MrBlueSL's Avatar
    Join Date
    Apr 2012
    Gender
    male
    Location
    Illinois
    Posts
    56
    Reputation
    10
    Thanks
    51
    My Mood
    Happy

    How to make single player commands?

    I have a mod class, and chat enabled in singleplayer, but for some reason when I type the command, nothing happens?
    Also, chat doesn't show up, but I can still type.

    Can anyone help me out?

    I'll PM you my source for the mod class, hopefully someone can take a look at it and help me out.

    Thanks in advanced!

  2. #2
    infinest's Avatar
    Join Date
    Feb 2012
    Gender
    male
    Posts
    163
    Reputation
    10
    Thanks
    2,929
    My Mood
    Tired
    Umm the chat isn't supposed to show up

    This is what i changed in my code to check the chattext before it get's sent.

    Code:
                        if (Main.inputTextEnter && Main.chatRelease)
                        {
                            if (Main.chatText != "" && Modclass.onChat(Main.chatText))          //this
                            {
                                NetMessage.SendData(25, -1, -1, Main.chatText, Main.myPlayer, 0f, 0f, 0f, 0);
                            }
                            Main.chatText = "";
                            Main.chatMode = false;
                            Main.chatRelease = false;
                            Main.player[Main.myPlayer].releaseHook = false;
                            Main.player[Main.myPlayer].releaseThrow = false;
                            Main.PlaySound(11, -1, -1, 1);
                        }
    Modclass.onChat checks my chattext.
    If there's a dot like in .noclip,
    it checks what command it is(after the dot) and executes it, then returns false.
    If there is no dot at the beginning it returns true.
    So if there is a dot it doesnt send it and executes your command, if there is none it just sends it.
    Last edited by infinest; 10-12-2013 at 03:52 PM.

  3. #3
    MrBlueSL's Avatar
    Join Date
    Apr 2012
    Gender
    male
    Location
    Illinois
    Posts
    56
    Reputation
    10
    Thanks
    51
    My Mood
    Happy
    Quote Originally Posted by infinest View Post
    Umm the chat isn't supposed to show up

    This is what i changed in my code to check the chattext before it get's sent.

    Code:
                        if (Main.inputTextEnter && Main.chatRelease)
                        {
                            if (Main.chatText != "" && Modclass.onChat(Main.chatText))          //this
                            {
                                NetMessage.SendData(25, -1, -1, Main.chatText, Main.myPlayer, 0f, 0f, 0f, 0);
                            }
                            Main.chatText = "";
                            Main.chatMode = false;
                            Main.chatRelease = false;
                            Main.player[Main.myPlayer].releaseHook = false;
                            Main.player[Main.myPlayer].releaseThrow = false;
                            Main.PlaySound(11, -1, -1, 1);
                        }
    Modclass.onChat checks my chattext.
    If there's a dot like in .noclip,
    it checks what command it is(after the dot) and executes it, then returns false.
    If there is no dot at the beginning it returns true.
    So if there is a dot it doesnt send it and executes your command, if there is none it just sends it.
    Could I send you my mod class and show you to see where the onChat would go?

  4. #4
    infinest's Avatar
    Join Date
    Feb 2012
    Gender
    male
    Posts
    163
    Reputation
    10
    Thanks
    2,929
    My Mood
    Tired
    Sure, I'll take a look at it!

  5. #5
    Xenoxiluna's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    106
    Reputation
    10
    Thanks
    4,303
    My Mood
    Asleep
    I used to remove "Main.netMode == 1" from this block of code in Main.cs.

    Code:
    /* OLD
    if (keyState.IsKeyDown(Keys.Enter) && Main.netMode == 1 && !keyState.IsKeyDown(Keys.LeftAlt) && !keyState.IsKeyDown(Keys.RightAlt))
    /*
    if (keyState.IsKeyDown(Keys.Enter) && !keyState.IsKeyDown(Keys.LeftAlt) && !keyState.IsKeyDown(Keys.RightAlt)) //enabled single player chat
    {
         if (chatRelease && !chatMode && !editSign && !keyState.IsKeyDown(Keys.Escape))
         {
              PlaySound(10, -1, -1, 1);
              chatMode = true;
              clrInput();
              chatText = "";
         }
         chatRelease = false;
    }

  6. #6
    infinest's Avatar
    Join Date
    Feb 2012
    Gender
    male
    Posts
    163
    Reputation
    10
    Thanks
    2,929
    My Mood
    Tired
    Quote Originally Posted by Xenoxiluna View Post
    I used to remove "Main.netMode == 1" from this block of code in Main.cs.

    Code:
    /* OLD
    if (keyState.IsKeyDown(Keys.Enter) && Main.netMode == 1 && !keyState.IsKeyDown(Keys.LeftAlt) && !keyState.IsKeyDown(Keys.RightAlt))
    /*
    if (keyState.IsKeyDown(Keys.Enter) && !keyState.IsKeyDown(Keys.LeftAlt) && !keyState.IsKeyDown(Keys.RightAlt)) //enabled single player chat
    {
         if (chatRelease && !chatMode && !editSign && !keyState.IsKeyDown(Keys.Escape))
         {
              PlaySound(10, -1, -1, 1);
              chatMode = true;
              clrInput();
              chatText = "";
         }
         chatRelease = false;
    }
    I already told him that, he means his commands just don't work in singleplayer

Similar Threads

  1. [Release] [1.7.2] Single Player Commands
    By Funny-Man in forum Minecraft Mods
    Replies: 34
    Last Post: 08-05-2011, 07:12 PM
  2. [Release] [1.6.5]Single Player Commands
    By Heartview in forum Minecraft Mods
    Replies: 17
    Last Post: 06-06-2011, 10:27 PM
  3. [Release] [1.5_01]Single Player Commands v2.8_2 *Updated*
    By Heartview in forum Minecraft Mods
    Replies: 9
    Last Post: 04-22-2011, 04:17 PM
  4. [1.4_01] Single Player Commands [V2.7_2]
    By Thunder in forum Minecraft Mods
    Replies: 8
    Last Post: 04-13-2011, 11:47 PM
  5. [1.4] Single Player Commands [V2.6]
    By Thunder in forum Minecraft Mods
    Replies: 16
    Last Post: 04-11-2011, 02:12 PM