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

plugin says that addhandler is not capable

Comments in 'Plugin Development' started by Puzzleo, Nov 30, 2013.

  1. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    not solved
    2013-11-30 07:02:19 [ERROR] A level 4096 error happened: "Argument 2 passed to PocketMinecraftServer::addHandler() must be callable, array given, called in C:\Users\Ivett\Desktop\PocketMine-MP\src\API\ServerAPI.php on line 319 and defined" in "C:\Users\Ivett\Desktop\PocketMine-MP\src\PocketMinecraftServer.php" at line 269
    2013-11-30 07:02:19 [ERROR] A level 4096 error happened: "Argument 2 passed to PocketMinecraftServer::addHandler() must be callable, array given, called in C:\Users\Ivett\Desktop\PocketMine-MP\src\API\ServerAPI.php on line 319 and defined" in "C:\Users\Ivett\Desktop\PocketMine-MP\src\PocketMinecraftServer.php" at line 269
    Last edited: Nov 30, 2013
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,707
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Please read your code before posting here, people spend time helping with problems, it's the least you can do to check your code for spelling errors.
    You spelling the eventHandler function name wrong.
  3. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    oh sorry was that all thanks i will do the rest
  4. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    <?php

    /*
    __PocketMine Plugin__
    name=limited lives
    version=1.0
    description=gives players get 5 lives
    author=puzzleo
    class=lives
    apiversion=7,8,9,10
    */

    class lives implements Plugin{

    private $api;

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


    public function init(){
    $this->api->Handler("player.connect", array($this, "eventHandler"), 5);
    $this->api->Handler("player.respawn", array($this, "eventHandler"), 5);
    $this->config = new Config($this->api->plugin->configPath($this)."[LIVES].yml", CONFIG_YAML, array());
    console("[INFO] [limted lives] have Loaded!");

    }

    public function eventHandlder($issuer, $event){
    switch($event){
    case "player.connect":
    if (isset($params[0])) {
    $data = $this->api->plugin->readYAML($this->api->plugin->configPath($this). "[LIVES].yml");
    if (array_key_exists($params[0][1], $data)) {
    }else {
    $name = $params[0];
    $number= 0;
    $issuer;
    $data["$name"] = array($number,issuer);
    $this->api->plugin->writeYAML($this->api->plugin->configPath($this)."[LIVES].yml", $data);
    }
    break;
    }
    case "player. respawn":
    $data = $this->api->plugin->readYAML($this->api->plugin->configPath($this). "[LIVES].yml");
    if (isset($params[0])) {
    $name = $params[0];
    if (array_key_exists($params[0], $data)) {
    $number = $data[$params[0]][0];
    $issuer = $data[$params[0]][1];


    }
    }
    if ($name == true){
    $number+1;
    $livesleft =5-$numbers;
    $issuer->sendChat("you have $livesleft ");
    }
    if ($number == 5){
    $ip = $issuer->ip;
    $this->api->ban->ban("Default_User");
    $this->api->ban->banIP($ip);
    $this->api->ban->kick("","run out of livees");
    }
    break;
    }
    }
    public function __destruct()
    {
    }

    }
    ?>
    still doesnt work
    Last edited: Nov 30, 2013
  5. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    • what is wrong
  6. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,707
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Because your function name is still spelt wrong!
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It is ServerAPI::addHandler($eventName, $callable, $priority)
    $priority omittable
  8. Glitchmaster_PE
    Offline

    Glitchmaster_PE Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    834
    Plugins:
    8
    Minecraft User:
    Glitchmaster_PE
    or you can all it like this: $this->api->addHandler(blah blalh blah);
  9. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    here is my code
    PHP:
    /*
    __PocketMine Plugin__
    name=limited lives
    version=1.0
    description=gives players get 5 lives
    author=puzzleo
    class=lives
    apiversion=7,8,9,10
    */

    class lives implements Plugin{

    private 
    $api;

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


    public function 
    init(){
    $this->api->Handler("player.connect", array($this"eventHandler"), 5);
    $this->api->Handler("player.respawn", array($this"eventHandler"), 5);
    $this->config = new Config($this->api->plugin->configPath($this)."[LIVES].yml"CONFIG_YAML, array());
    console("[INFO] [limted lives] have Loaded!");

    }

    public function 
    eventHandler($issuer$event$params $username $username $livesleft $number){
    switch(
    $event){
    case 
    "player.connect":
    if (isset(
    $params[0])) {
    $data $this->api->plugin->readYAML($this->api->plugin->configPath($this). "[LIVES].yml");
    if (
    array_key_exists($params[0][1], $data)) {
    }else {
    $username =$issuer->username;
    $username $params[0];
    $number0;
    $data["$username"] = array($number);
    $this->api->plugin->writeYAML($this->api->plugin->configPath($this)."[LIVES].yml"$data);
    }
    break;
    }
    case 
    "player. respawn":
    $data $this->api->plugin->readYAML($this->api->plugin->configPath($this). "[LIVES].yml");
    if (isset(
    $params[0])) {
    $name $params[0];
    if (
    array_key_exists($params[0], $data)) {
    $number $data[$params[0]][0];


    }
    }
    if (
    $number == 5){
    $ip $issuer->ip;
    $this->api->ban->ban("Default_User");
    $this->api->ban->banIP($ip);
    $this->api->ban->kick("","run out of lives");
    }
    if (
    $username == true){
    $number+1;
    $livesleft =5-$numbers;
    $issuer->sendChat("you have $livesleft ");
    $this->overwriteConfig($username);
        }

    break;
    }
    }
    public function 
    __destruct()
    {
    }

    }
    ?>
    the error is
    Code:
    `
    # PocketMine-MP Error Dump Mon Dec 2 06:09:45 GMT 2013
    Error: array (
      'type' => 1,
      'message' => 'Call to undefined method ServerAPI::Handler()',
      'file' => 'C:\\Users\\Ivett\\Desktop\\PocketMine-MP\\src\\API\\PluginAPI.php(87) : eval()\'d code',
      'line' => 23,
    )
    
    Code:
    [14]
    [15]
    [16]
    [17]
    [18]
    [19]
    [20]
    [21]
    [22]
    [23]
    [24]
    [25]
    [26]
    [27]
    [28]
    [29]
    [30]
    [31]
    [32]
    [33]
    
    
    PM Version: Alpha_1.3.10 #618 [Protocol 12]
    Commit: 0000000000000000000000000000000000000000
    uname -a: Windows NT IVETT-PC 6.1 build 7601 (Windows 7 Home Premium Edition Service Pack 1) i586
    PHP Version: 5.5.6
    Zend version: 2.5.0
    OS : WINNT, win
    Debug Info: array (
      'tps' => 19.8598,
      'memory_usage' => '9.59MB',
      'memory_peak_usage' => '9.78MB',
      'entities' => 0,
      'players' => 0,
      'events' => 1,
      'handlers' => 6,
      'actions' => 14,
      'garbage' => 0,
    )
    
    
    Parameters: array (
      'input' =>
      array (
      ),
      'commands' =>
      array (
        'enable-ansi' => true,
      ),
      'flags' =>
      array (
      ),
    )
    
    
    server.properties: array (
      'server-name' => 'Minecraft: PE Server',
      'description' => 'Server made using PocketMine-MP',
      'motd' => 'Welcome @player to this server!',
      'server-ip' => '',
      'server-port' => 19132,
      'server-type' => 'normal',
      'memory-limit' => '128M',
      'last-update' => 1385964583,
      'white-list' => false,
      'spawn-protection' => '16',
      'view-distance' => '10',
      'max-players' => 20,
      'allow-flight' => false,
      'spawn-animals' => true,
      'spawn-mobs' => true,
      'gamemode' => 0,
      'hardcore' => false,
      'pvp' => true,
      'difficulty' => 1,
      'generator-settings' => '',
      'level-name' => 'world',
      'level-seed' => '',
      'level-type' => 'DEFAULT',
      'enable-query' => true,
      'enable-rcon' => false,
      'rcon.password' => '******',
      'send-usage' => true,
      'auto-save' => true,
    )
    
    
    Loaded plugins:
    limited lives 1.0 by puzzleo
    line 23 is the handler player.connect
  10. Chris35000vr
    Offline

    Chris35000vr Banned

    Joined:
    Sep 22, 2013
    Posts:
    15
    Minecraft User:
    Chris35000vr
    Try another handler like player.join
  11. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    i guess thanks
  12. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    nope it dosnt work
  13. Chris35000vr
    Offline

    Chris35000vr Banned

    Joined:
    Sep 22, 2013
    Posts:
    15
    Minecraft User:
    Chris35000vr
    You put $username twice on line 23
  14. Xfusionios
    Offline

    Xfusionios Active Member Plugin Developer

    Joined:
    Aug 24, 2013
    Posts:
    67
    Plugins:
    2
    Minecraft User:
    XFusionios
    Here try this
    PHP:
    /*
    __PocketMine Plugin__
    name=limited lives
    version=1.0
    description=gives players get 5 lives
    author=puzzleo
    class=lives
    apiversion=7,8,9,10
    */

    class lives implements Plugin{

    private 
    $api;

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


    public function 
    init(){
    $this->api->addHandler("player.connect", array($this"eventHandler"), 5);
    $this->api->addHandler("player.respawn", array($this"eventHandler"), 5);
    $this->config = new Config($this->api->plugin->configPath($this)."[LIVES].yml"CONFIG_YAML, array());
    console("[INFO] [limted lives] have Loaded!");

    }

    public function 
    eventHandler($issuer$event$params $username $username $livesleft $number){
    switch(
    $event){
    case 
    "player.connect":
    if (isset(
    $params[0])) {
    $data $this->api->plugin->readYAML($this->api->plugin->configPath($this). "[LIVES].yml");
    if (
    array_key_exists($params[0][1], $data)) {
    }else {
    $username =$issuer->username;
    $username $params[0];
    $number0;
    $data["$username"] = array($number);
    $this->api->plugin->writeYAML($this->api->plugin->configPath($this)."[LIVES].yml"$data);
    }
    break;
    }
    case 
    "player. respawn":
    $data $this->api->plugin->readYAML($this->api->plugin->configPath($this). "[LIVES].yml");
    if (isset(
    $params[0])) {
    $name $params[0];
    if (
    array_key_exists($params[0], $data)) {
    $number $data[$params[0]][0];


    }
    }
    if (
    $number == 5){
    $ip $issuer->ip;
    $this->api->ban->ban("Default_User");
    $this->api->ban->banIP($ip);
    $this->api->ban->kick("","run out of lives");
    }
    if (
    $username == true){
    $number+1;
    $livesleft =5-$numbers;
    $issuer->sendChat("you have $livesleft ");
    $this->overwriteConfig($username);
        }

    break;
    }
    }
    public function 
    __destruct()
    {
    }

    }
    ?>

Share This Page

Advertisement