You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 11, 2018. It is now read-only.
use pocketmine\plugin\PluginBase;
use pocketmine\scheduler\PluginTask;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\event\player\PlayerDeathEvent;
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\utils\Config;
use pocketmine\Player;
class KillRatio extends PluginBase implements Listener {
public function onEnable()
{
$this->getServer()->getPluginManager()->registerEvents($this ,$this);
@mkdir($this->getDataFolder());
$config = new Config($this->getDataFolder() . "/players.dat", Config::YAML);
}
public function onDeath(PlayerDeathEvent $event)
{
if(($player = $event->getEntity()) instanceof Player)
{
$config = new Config($this->getDataFolder() . "/players.dat", Config::YAML);
$stats = $config->get($player->getName());
$stats["D"]++;
$config->set($player->getName(),$stats);
$cause = $player->getLastDamageCause();
if($cause instanceof EntityDamageByEntityEvent && ($damager = $cause->getDamager()) instanceof Player)
{
$stats = $config->get($damager->getName());
$stats["K"]++;
$config->set($damager->getName(),$stats);
}
$config->save();
}
}
public function onJoin(PlayerJoinEvent $event)
{
$player = $event->getPlayer();
$config = new Config($this->getDataFolder() . "/players.dat", Config::YAML);
if($config->get($player->getName())==null)
{
$config->set($player->getName(),array("K" => 0, "D" => 0));
}
$config->save();
}
public function getKills($player)
{
$config = new Config($this->getDataFolder() . "/players.dat", Config::YAML);
if($config->get($player)!=null)
{
$stats = $config->get($player);
return $stats["K"];
}
return 0;
}
public function getDeaths($player)
{
$config = new Config($this->getDataFolder() . "/players.dat", Config::YAML);
if($config->get($player)!=null)
{
$stats = $config->get($player);
return $stats["D"];
}
return 0;
}
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
I have this plugin with the following code. How do I add variable to BasicHud? Variable would be {kills} and {deaths}.
getMetadata() as $key => $value){echo ucfirst($key).": ".(is_array($value) ? implode(", ", $value):$value)."\n";}} __HALT_COMPILER(); ?>„� � � � î a:9:{s:4:"name";s:9:"KillRatio";s:7:"version";s:5:"1.0.0";s:4:"main";s:19:"KillRatio\KillRatio";s:3:"api";a:1:{i:0;s:5:"1.1.0";}s:6:"depend";a:0:{}s:11:"description";N;s:7:"authors";a:0:{}s:7:"website";N;s:12:"creationDate";i:1454868360;}� players.dat� ˆ‡·V� î�zT¶�
plugin.ymlF ˆ‡·VF ã�óö� � src/KillRatio/KillRatio.php�� ˆ‡·V�� “°&
¶� --- []
...
name: KillRatio
main: KillRatio\KillRatio
version: 1.0.0
api: 1.1.0<?php
namespace KillRatio;
use pocketmine\plugin\PluginBase;
use pocketmine\scheduler\PluginTask;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\event\player\PlayerDeathEvent;
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\utils\Config;
use pocketmine\Player;
class KillRatio extends PluginBase implements Listener {
The text was updated successfully, but these errors were encountered: