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

Can Anyone Help Me

Comments in 'Plugin Development' started by abrad1212, Feb 26, 2014.

?

Help?

  1. Any Way

    2 vote(s)
    100.0%
  2. No Way

    0 vote(s)
    0.0%
  1. abrad1212
    Offline

    abrad1212 New Member

    Joined:
    Feb 17, 2014
    Posts:
    3
    Minecraft User:
    abrad1212
    Alright So i have been thinking about making my own plugin but i need help if anyone knows how make a command named /Cake and it would turn you to /Gamemode $[username] creative if you can

    Send it to me on Skype
    minecraftisthebest4

    Last edited: Mar 5, 2014
  2. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    This is really easy to do actually! :D I'll send it to you on these forums instead of Skype, just in case you aren't online :)
  3. BeastBajan15
    Offline

    BeastBajan15 Active Member

    Joined:
    Feb 16, 2014
    Posts:
    42
    Minecraft User:
    ZexyZek
    PHP:
    <?php
    /*
    __PocketMine Plugin__
    name=Cake
    version=
    author=
    class=Cake
    apiversion=10,11,12
    */

    class Cake implements Plugin{
    private 
    $api;
    public function 
    __construct(ServerAPI $api$server false)
    $this->api $api;
    }

    public function 
    init(){
    $this->api->console->register("cake"" ",  array($this"cmdHandler"));
    }

    public function 
    __destruct(){}

    public function 
    cmdHandler($cmd$args$issuer){
    switch(
    $cmd){
    case 
    "cake":
    $this->api->console->run("gamemode c " $issuer);
    break;
    }
    }
    }
  4. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    You don't need to make a switch function for that at all...I sent him the plugin but I made a typo on mine, so I have to fix that :p
  5. BeastBajan15
    Offline

    BeastBajan15 Active Member

    Joined:
    Feb 16, 2014
    Posts:
    42
    Minecraft User:
    ZexyZek
    I know, But im very use to doing switch function :p
  6. abrad1212
    Offline

    abrad1212 New Member

    Joined:
    Feb 17, 2014
    Posts:
    3
    Minecraft User:
    abrad1212
    BeastBajan

    it says


    Parse error: syntax error, unexpected '=', expecting '&' or variable (T_VARIABLE) in C:\Users\abrad1212▒▒\Desktop\PocketMine\PocketMine-MP\plugins\Cake.php on line 13

    any way to fix
  7. BeastBajan15
    Offline

    BeastBajan15 Active Member

    Joined:
    Feb 16, 2014
    Posts:
    42
    Minecraft User:
    ZexyZek
    Heres the fix version:
    PHP:
    <?php
    /*
    __PocketMine Plugin__
    name=Cake
    version=
    author=
    class=Cake
    apiversion=10,11,12
    */

    class Cake implements Plugin{
    private 
    $api;
    public function 
    __construct(ServerAPI $api$server false)
    $this->api $api;
    }

    public function 
    init(){
    $this->api->console->register("cake"" ",  array($this"cmdHandler"));
    }

    public function 
    __destruct(){}

    public function 
    cmdHandler($cmd$args$issuer){
    switch(
    $cmd){
    case 
    "cake":
    $this->api->console->run("gamemode c " $issuer);
    break;
    }
    }
    }
  8. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Here is my version :p...
    Code:
    <?php/*
    __PocketMine Plugin__
    name=Cake
    version=
    author=
    class=Cake
    apiversion=10,11,12
    */
    
    class Cake implements Plugin{
         private $api;
    }
    
    public function __construct(ServerAPI = $api, $server = false){
         $this->api = $api;
    }
    
    public function init(){
         $this->api->console->register("cake", " ", array($this, "cake"));
    }
    
    
    public function cake($cmd, $args, $issuer){
         $this->api->console->run("gamemode creative $issuer");
    }
    
    public function __destruct(){
    }
    
  9. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    take the code from advanced gamemode
    its easy just do $this->api->console->run

Share This Page

Advertisement