Skip to content

Instantly share code, notes, and snippets.

@haniokasai
Last active October 19, 2015 10:26
Show Gist options
  • Save haniokasai/f4c74bd11baf054a6623 to your computer and use it in GitHub Desktop.
Save haniokasai/f4c74bd11baf054a6623 to your computer and use it in GitHub Desktop.
pocketmine-mpのプラグインのサンプルコード集です。
http://blog.haniokasai.com/2015/10/pocketmine-mp.html
ここのソースは肉なり焼くなり好きにしてください。
プレイヤーが殺した時お金をもらう。
<?php
use pocketmine\Player;
use pocketmine\event\player\PlayerDeathEvent;
public function deathdesu(PlayerDeathEvent $event){
if($event->getEntity()->getLastDamageCause() instanceof EntityDamageByEntityEvent){
$player = $event->getEntity();
if ($player instanceof Player){
$killer =$event->getEntity()->getLastDamageCause()->getDamager();
$killername = $killer->getName();//殺した人
$shinda =$event->getEntity();//殺されたプレイヤー
$shindaname = $event->getEntity()->getName();
$this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->addMoney($killername,1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment