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

Why won't this work?

Comments in 'Plugin Development' started by Legomite, Apr 27, 2014.

  1. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    When I join it won't spawn me with armor. :'(
    PHP:
    public function init() {
            
    //Adds handler
            
    $this -> api -> addHandler("player.spawn", array($this"Handler"));
        
    $this -> api -> addHandler("player.respawn", array($this"Handler"));
        }

        public function 
    Handler($data$event) {
                 switch(
    $event){
                case 
    "player.spawn":
            
    $user =$player->iusername;
         
    //IF YOU WANT TO CHANGE IT EDIT THE VALUE IN ()
         //HEAD
         
    $user->setArmor(0,$this->getArmor(298));
          
    //BODY
          
    $user->setArmor(1,$this->getArmor(303));
         
    //LEG
         
    $user->setArmor(2,$this->getArmor(304));
          
    //FEET
          
    $user->setArmor(3,$this->getArmor(305));
    break;
                case 
    "player.respawn":
            
    $user =$player->iusername;
         
    //IF YOU WANT TO CHANGE IT EDIT THE VALUE IN ()
         //HEAD
         
    $user->setArmor(0,$this->getArmor(298));
          
    //BODY
          
    $user->setArmor(1,$this->getArmor(303));
         
    //LEG
         
    $user->setArmor(2,$this->getArmor(304));
          
    //FEET
          
    $user->setArmor(3,$this->getArmor(305));
    break;
                }
        }
        
    //Thing I don't understand Lol
        
    public function __destruct() {
        }
        }
    ?>
  2. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    Try adding debug messages between the armour, that will tell you if the handler is working.
  3. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,167
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    after the code

    case "player.spawn" :

    add

    $player =$this->api->player->getByEID($data->eid);

    try that if it works or not
  4. DA_Swagnemite
    Offline

    DA_Swagnemite Notable Member Plugin Developer

    Joined:
    Nov 17, 2013
    Posts:
    386
    Plugins:
    7
    Minecraft User:
    DA_SWAGNEMITE
    Besides the fact that it doesnt spawn the player with armour, why dont you have the plugin generate a config file so that the server owner can edit the armour given without having to edit the actual code?
  5. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    “Personal Use”

Share This Page

Advertisement