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

Disable the exp adding

Comments in 'Plugin Development' started by domybest, Oct 17, 2016.

  1. domybest
    Offline

    domybest New Member

    Joined:
    Dec 18, 2015
    Posts:
    7
    Minecraft User:
    Riceball_bro
    Does anyone know how to disable the exp adding when a player kills the others ?
    (When Player A kills Player B, Player A will get exp)
  2. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Cant you disable it in the pocketmine.yml?
  3. JUZEXMOD
    Offline

    JUZEXMOD New Member

    Joined:
    May 28, 2016
    Posts:
    19
    Minecraft User:
    JUZEXMOD
    Set Player Level anytime Nothing

    PHP:
    class Task extends PluginTask{
        public 
    $owner;
        public function 
    __construct($owner){
            
    parent::__construct($owner);
            
    $this->owner $owner;
        }
        public function 
    onRun($currentTick){
            foreach (
    $this->owner->getServer()->getOnlinePlayers() as $p){
                    
    $p->setExpLevel(null);
            }
        }
    }
    this task ^ if you notknow to task you can do this Event but task better

    PHP:
    public function onMove(PlayerMoveEvent $event){
          
    $player $event->getPlayer();
          
    $name $player->getName();
        
          
    $player->setExpLevel(null);
        }
    This code ^ on Player Move set exp player nothing but task anytime
    Last edited: Oct 21, 2016
  4. corytortoise
    Offline

    corytortoise New Member

    Joined:
    Aug 23, 2015
    Posts:
    10
    Minecraft User:
    corytortoise
    That looks like a horrific method to do that. You are running a task EVERY time a player moves, or in the first example, constantly. Not to mention that the OP asked for the player to not get XP when they kill a player, not to disable XP entirely.

    I would suggest getting the XP an Entity(Or Player) is supposed to drop when they die, and setting that to 0.
    Primus likes this.
  5. JUZEXMOD
    Offline

    JUZEXMOD New Member

    Joined:
    May 28, 2016
    Posts:
    19
    Minecraft User:
    JUZEXMOD
    Thanks for the clarification =)

    PHP:
    public function onKill(PlayerDeathEvent $event){
        
    $cause $event->getEntity()->getLastDamageCause();
            if(
    $cause instanceof EntityDamageByEntityEvent){
                
    $killer $cause->getDamager();
                   
                    
    $killer->setExpLevel(null);
          }
      }
  6. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    No just no, disable it in the YAML.
  7. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    maybe OP mean to disable drop of EXP to make server more swift?
  8. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
  9. corytortoise
    Offline

    corytortoise New Member

    Joined:
    Aug 23, 2015
    Posts:
    10
    Minecraft User:
    corytortoise
    If any of you noticed the full question, it stated that they didn't want Experience transaction when a player kills another player, but they never stated that they wanted to disable Experience entirely.
  10. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    There is a simple way to do it, just cancel experience spawn.
    PHP:
    public function onSpawn(\pocketmine\event\entity\EntitySpawnEvent $e){
        if(
    $e->getType() == 69){
            
    $e->setCancelled(true);
        }
    }

Share This Page

Advertisement