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

plugin problems please help.

Comments in 'Plugin Development' started by Legomite, Oct 11, 2013.

  1. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    so after merging herobrine scare and troll plugin together,(i will give them both high credits) I recieved a error when adding my own command.heres the script.

    <?php

    /*
    * __PocketMine Plugin__
    * name=Troll
    * description=Troll people
    * version=1.0
    * author=Legomite
    * class=Troll
    * apiversion=10
    */

    class Troll implements Plugin{
    private $api;

    public function __construct(ServerAPI $api, $server = false){
    $this->api = $api;
    }

    public function init(){
    $this->api->console->register("troll","Troll someone. Usage: /troll <playername>", array($this, "troll"));
    $this->api->console->register("hb", "This command summons Herobrine", array($this, "handleCommand"));
    $this->api->console->register("hbscare", "It scare people saying something!", array($this, "handleCommand"));
    $this->api->console->register("spook", "Scare theperson of your choice!", array($this, "handleCommand"));
    }
    public function troll($cmd, $args, $issuer, $target){
    $target = $args[0];
    $username = $issuer->username;
    $this->api->console->run("tp ".$target." 20 300 20");
    $this->api->chat->sendTo(false, "You have been trolled by ".$username, $target);
    $this->api->chat->sendTo(false, "You have trolled ".$target, $username);
    }

    public function __destruct(){}

    public function handleCommand($cmd, $args, $issuer, $alias){
    switch($cmd){
    case "hb":
    $this->api->chat->broadcast("Herobrine has joined the game");/*Modify me!*/
    $this->api->chat->broadcast(": I AM HERE. I AM WATCHING. ALWAYS.");/*Modify me!*/
    break;
    case "hbscare":
    $user = strtolower($args[0]);
    $this->api->chat->broadcast(": I will find you. Better watch your back.");/*Modify me!*/
    break;

    }

    public function __destruct(){}

    public function handleCommand($cmd, $args, $issuer, $alias){
    switch($cmd){
    case "spook":
    $target = $args[0];
    $username = $issuer->username;
    $this->api->chat->sendTo(false, "You have spooked".$target $username);
    $this->api->chat->sendTo(false, "YOU WILL PAY TO WHAT YOU HAVE DONE TO ME!!!".$username, $target);

    }

    }
    ?>
  2. Humerus
    Offline

    Humerus Staff Member Plugin Reviewer

    Joined:
    Aug 23, 2013
    Posts:
    114
    Plugins:
    1
    You have two handleCommand functions. You need to group them by adding a case to the switch in the first function.
  3. ZacHack
    Offline

    ZacHack Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    326
    Plugins:
    6
    Minecraft User:
    _ZacHack_
    Instead of two put only one with all commands and don't have two __destructs
  4. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    Thanks I will try to fix this
  5. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    435
    Plugins:
    4
    Minecraft User:
    Lambo
    Use this quote from above.

    And
    Code:
    public function __destruct(){}
    
    public function handleCommand($cmd, $args, $issuer, $alias){
    switch($cmd){
    case "hb":
    $this->api->chat->broadcast("Herobrine has joined the game");/*Modify me!*/
    $this->api->chat->broadcast(": I AM HERE. I AM WATCHING. ALWAYS.");/*Modify me!*/
    break;
    case "hbscare":
    $user = strtolower($args[0]);
    $this->api->chat->broadcast(": I will find you. Better watch your back.");/*Modify me!*/
    break;
    
    }
    has two brackets at the beginning of __destruct()

Share This Page

Advertisement