Skip to content

Instantly share code, notes, and snippets.

@Omattyao
Last active December 14, 2015 04:39
Show Gist options
  • Save Omattyao/5030043 to your computer and use it in GitHub Desktop.
Save Omattyao/5030043 to your computer and use it in GitHub Desktop.
<?php
/*
__PocketMine Plugin__
name=HealCommandsforSC
version=0.1.1
author=Omattyao
apiversion=2
class=scHealCommands
*/
class scHealCommands extends scClass{
public function init() {
$this->sc->register("heal", "Fill up a player health.", array($this, "commandH"));
$this->sc->register("healall", "Fill up all players health.", array($this, "commandH"));
}
public function commandH($cmd, $args){
switch ($cmd) {
case 'heal':
$player = $this->api->player->get(implode(" ", $args));
if ($player !== false) {
$e = $this->api->entity->get($player->eid);
if (!($e === false or $e->dead === true)) {
$e->setHealth(20, 'console', false);
break;
}
}
$output .= "Usage: /heal <player>\n";
break;
case 'healall':
$players = $this->api->player->getAll();
foreach ($players as $client) {
$e = $this->api->entity->get($client->eid);
if (!($e === false or $e->dead === true)) {
$e->setHealth(20, 'console', false);
}
}
break;
}
return $output;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment