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)
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
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.
Thanks for the clarification =) PHP: public function onKill(PlayerDeathEvent $event){ $cause = $event->getEntity()->getLastDamageCause(); if($cause instanceof EntityDamageByEntityEvent){ $killer = $cause->getDamager(); $killer->setExpLevel(null); } }
If you use Genisys: https://github.com/iTXTech/Genisys/.../event/player/PlayerExperienceChangeEvent.php
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.
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); }}