Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Console command (with API 12)

Comments in 'Plugin Development' started by Kripto, Mar 3, 2014.

  1. Kripto
    Offline

    Kripto New Member

    Joined:
    Mar 2, 2014
    Posts:
    15
    Minecraft User:
    Kripto96
    Hi, yesterday I downloaded the new pocketmine 1.3.12 with the new API 12 and there's a problem with the plugin:
    PHP:
    $this->api->console->run("restart");
    this code, in API 11, restart the server, but doesn't work with te new api.
    Is this code changed?

    The console doesn't send error message.

    Thanks :)
  2. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    ok here is the problem the $this->api->console->run part is ok but if your trying to stop the server like /stop
    then it has to be

    $this->api->console->run("stop");
  3. Sulfatezz
    Offline

    Sulfatezz Banned

    Joined:
    Dec 3, 2013
    Posts:
    9
    Minecraft User:
    Sulfatezz
    The "code" from @jerlegom is rigth. You cant restart the Server with a command. You have to edit the Start.bat/sh
    Did you host your Servers on Linux or Windows?
  4. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    $this->api->console->run just runs a command from console but the command must exist. you can find some great examples in the advanced gamemode plugins code
  5. Sulfatezz
    Offline

    Sulfatezz Banned

    Joined:
    Dec 3, 2013
    Posts:
    9
    Minecraft User:
    Sulfatezz
    But he whants to restart his Server, its exists a server restart with the rigth start.bat/sh! You have then only run in the console "stop", the start.sh/bat is coded to restart the Server!
  6. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    The only way to do that (That exist) is to make a server loop, just edit your "start.sh" file, delete everything and paste this:
    Code:
    #!/bin/bash
    DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
    cd "$DIR"
    if [ -f ./php5/bin/php ]; then
            exec ./bin/php5/bin/php -d enable_dl=On PocketMine-MP.php [email protected]
    fi
    while :
    do
    rm console.log
    sleep 5
    ./bin/php5/bin/php -d enable_dl=On PocketMine-MP.php [email protected]
    done
    read -p "Press [Enter] to continue..."
    exit
    This will automatically restart your server when you do "/stop" or your server crashes
    Kripto likes this.
  7. Kripto
    Offline

    Kripto New Member

    Joined:
    Mar 2, 2014
    Posts:
    15
    Minecraft User:
    Kripto96
    I'm testing the plugin on a mcpe dedicated server that uses multicraft, I can't edit the start :/
  8. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Please open it using any text editor, erase everything and paste that

Share This Page

Advertisement