Closed ghost closed 3 years ago
plugins crash when they try to getDamager of player who died by the guns
maybe change the bullet to snowball?
I agree with this, although if I'm reading the config correctly, changing it to a snowball wouldn't help, as you could set the Projectile to be a Sword for all the plugin cares. I haven't actually tested that ofc, but it should be possible. Therefore, your earlier mention of finding a way to set a custom cause of death, would probably be the best way to solve this.
@mote166 Have you tried this as a method onDeath?
$cause = $event->getPlayer()->getLastDamageCause();
if($cause instanceof EntityDamageByEntityEvent and $cause->getDamager() instanceof Player) {
$killer = $cause->getDamager();
$event->setDeathMessage("§f•§r " . $killer . " §fkilled§r " . $name);
}
looks like i can no longer test anything since my test server started kicking me each time i join with Blocked 10.89.218.194 for 300 seconds
and i have no other way to test plugins except by this android client hosted server .
$cause = $event->getEntity()->getLastDamageCause();
if ($cause instanceof EntityDamageByEntityEvent){
if ($cause->getDamager() instanceof Player) {
$killer = $cause->getDamager();
$this->eco = $this->getServer()->getPluginManager()->getPlugin("EconomyAPI");
$this->eco->addMoney($killer, 10);
$killer->sendTip("§eYou earned $10 for killing " . $name . "!");
}
}
}
I'm about to test this on my server, I'll let you know if it works. (If you need a new server host, check out WitherHost, their great and free)
@KadTheHunter did your code work?
i just tested both the codes you sent and none of them worked.
Oof this was well over a year ago, but I believe it failed. Given the Dev hasn't responded to a single open issue in this repo, I plan on asking another dev i know to make a guns plugin, and maybe uh incorporate the requests here.
This is an experimental plugin, it is not meant to be used in production servers. Most of my open source work is experiemental and I don't plan on updating it any longer. Apologies, will add this to the readme.
can u make it announce player's death? like not by the plugin by pocketmine itself like edit the plugin so pocketmine know that the player has died by something like CAUSE::PROJECTILE or CAUSE::CUSTOM idk, so that we can use this plugin with other plugins and extend its functionality.