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

Solved how to can not disarmament ?

Comments in 'Plugin Development' started by musaichi, Oct 11, 2015.

  1. musaichi
    Offline

    musaichi New Member

    Joined:
    Mar 2, 2015
    Posts:
    33
    Minecraft User:
    musaichi
    Hey guys!
    I have a question.Plz help me:(
    how to can not disarmament ?
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Please be more specific.
  3. musaichi
    Offline

    musaichi New Member

    Joined:
    Mar 2, 2015
    Posts:
    33
    Minecraft User:
    musaichi
    I'm sorry...
    Could you tell me how to be disable to disarm?
  4. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Do You Mean Disable PvP? (Player Vs Player/ Player hit Player/ Player kill player)
  5. musaichi
    Offline

    musaichi New Member

    Joined:
    Mar 2, 2015
    Posts:
    33
    Minecraft User:
    musaichi
    No.Could you tell me how to be disable to disarm?
    I want a player not to take off his/her armor(s). When a player put his/her armor away, it supported to be cancelled.
  6. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    TheKofola12 and Taha_The_Hacker like this.
  7. musaichi
    Offline

    musaichi New Member

    Joined:
    Mar 2, 2015
    Posts:
    33
    Minecraft User:
    musaichi
    I'm sorry...
    I readed docs just minute.
    PHP:
    function EntityArmorChangeEvent(EntityArmorChangeEvent $entity){ $entity->setCanceled;}
    Is this correct?
    Kvetinac97 likes this.
  8. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    No, you have spelling bugs, here's a fix with a feature :
    PHP:
    public function EntityArmorChangeEvent(EntityArmorChangeEvent $entity){
    $c $entity->getEntity();//gets the entity
    if($c instanceof Player){//checks if the entity is a player
    $entity->setCancelled(true);//It's setCancelled(true); not setCanceled;
    }
    }
    Note : use public function functionname{} instead of function name{}
    Thanks :)

    Last edited: Oct 11, 2015
  9. musaichi
    Offline

    musaichi New Member

    Joined:
    Mar 2, 2015
    Posts:
    33
    Minecraft User:
    musaichi
    public is optional.
    PEMapModder likes this.
  10. CavinMiana
    Offline

    CavinMiana Active Member

    Joined:
    Aug 26, 2015
    Posts:
    101
    Minecraft User:
    CavinMiana
    Umm no it's not. Are you in the wrong forums lol.
    Taha_The_Hacker likes this.
  11. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    in PocketMine-API it's needed.
  12. musaichi
    Offline

    musaichi New Member

    Joined:
    Mar 2, 2015
    Posts:
    33
    Minecraft User:
    musaichi
    thanks!
    Taha_The_Hacker likes this.
  13. musaichi
    Offline

    musaichi New Member

    Joined:
    Mar 2, 2015
    Posts:
    33
    Minecraft User:
    musaichi
    really?
    I don't know...
    thanks
    HotFireyDeath likes this.
  14. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    function works also.
    Legoboy0215 likes this.
  15. musaichi
    Offline

    musaichi New Member

    Joined:
    Mar 2, 2015
    Posts:
    33
    Minecraft User:
    musaichi
    I dont know which code I should use, function or public function…
  16. CavinMiana
    Offline

    CavinMiana Active Member

    Joined:
    Aug 26, 2015
    Posts:
    101
    Minecraft User:
    CavinMiana
    Public
  17. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Please give him a little more information about it, he is learning.

    As you want your plugin to be used by "every Entity" (Player is an Entity too), you need to make the situation Public. So, you use Public Function, whenever you wan the plugin to act on everything (depends).

    Example
    PHP:
    public function onEnable() {  //the plugin is fired when enabled
    $this->Server::getPlayer()->sendMessage("Plugin is enabled"); //sends player the message inside (" ")
    }
  18. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    -.- what player will it be sent to?
  19. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Offcourse the player available (online), I could have also done

    Code:
    Server::getOnlinePlayers()
  20. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    when the plugin is enabled NO-Player is online..

Share This Page

Advertisement