1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Cancel Armor quip

Discussion in 'Development' started by #A6543, Jan 30, 2017.

  1. #A6543

    #A6543 Zombie

    Messages:
    267
    How can I stop players equipping armor? (EntityArmorChangeEvent only works when I use setBoots etc)
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    That event must do it. Can you send us the code you are executing?
     
    InspectorGadget likes this.
  3. #A6543

    #A6543 Zombie

    Messages:
    267
    I only cancel the event
     
  4. kaliiks

    kaliiks Zombie

    Messages:
    250
    PHP:
    function onArmorChange(EntityArmorChange $e){
    $item $e->getItem()->getId();
    if(
    $item == Item){
    $e->setCancelled();
     
  5. #A6543

    #A6543 Zombie

    Messages:
    267
    But I only want to cancel it for players. I need to use setBoots
     
  6. kaliiks

    kaliiks Zombie

    Messages:
    250
    PHP:
    public function onArmorCange(EntityArmorChangeEvent $e){
    $entity $e->getEntity(); //Entity
    $item $e->getItem()->getId(); //ItemId
    if($entity instanceof Player){ //Check when entity is Player
    $e->setCancelled(); //Cancel event
    $entity->getInventory()->setBootsBoots ); //Set boots
    $entity->getInventory()->sendArmorContents($entity);  //send Armor contents
     
  7. #A6543

    #A6543 Zombie

    Messages:
    267
    No... I don't want to set the boots when the players changes his Armor.. pls read my question
     
  8. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    PHP:
    public function onArmor(EntityArmorChangeEvent $ev){
        
    $itemid $ev->getNewItem()->getId();
        
    $boots array_flip([301,305,309,313,317]);
        
    $event->setCancelled(isset($boots[$itemid]));
    }
     
  9. #A6543

    #A6543 Zombie

    Messages:
    267
    I don't want to cancel id's.
     
  10. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    What do you mean by cancel IDs?
     
  11. kaliiks

    kaliiks Zombie

    Messages:
    250
    hah you said "I need to use setBoots"
     
    Muqsit likes this.
  12. MioTaku

    MioTaku Witch

    Messages:
    69
    GitHub:
    uselesswaifu
    Guessing you want to cancel it in a certain world
    Code:
     public function onArmor(EntityArmorChangeEvent $event){
    if( $player->getLevel()->getFolderName() == "Lobby" ) { 
        $event->setCancelled( true );
      }
    } 
     
  13. kaliiks

    kaliiks Zombie

    Messages:
    250
    Why you using
    Code:
     use [PHP]
     
  14. MioTaku

    MioTaku Witch

    Messages:
    69
    GitHub:
    uselesswaifu
    oh sorry I rarely ever goes on these forums but thanks :D
     
    kaliiks likes this.
  15. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    there nothing wrong using [code]
     
  16. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    But [PHP] is better for php code...
     
    kaliiks likes this.
  17. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    still shouldnt be fuzzed of it
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.