From 35c0c21c8d6632d48963be019590d15c9368b5a9 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 7 Jun 2013 12:54:45 +0200 Subject: [PATCH] Better /kill command, ensures death --- src/API/PlayerAPI.php | 3 ++- src/world/Entity.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/API/PlayerAPI.php b/src/API/PlayerAPI.php index 3100ecad40..844af3a772 100644 --- a/src/API/PlayerAPI.php +++ b/src/API/PlayerAPI.php @@ -240,7 +240,8 @@ class PlayerAPI{ $player = $this->get($params[0]); } if($player instanceof Player){ - $this->server->api->entity->harm($player->eid, 20, "console", true); + $player->entity->harm(1000, "console", true); + $player->sendChat("Ouch. That looks like it hurt.\n"); }else{ $output .= "Usage: /$cmd [player]\n"; } diff --git a/src/world/Entity.php b/src/world/Entity.php index 5dd1be3acb..fd345511d2 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -782,7 +782,7 @@ class Entity extends Position{ } public function harm($dmg, $cause = "generic", $force = false){ - return $this->setHealth($this->getHealth() - ((int) $dmg), $cause, $force); + return $this->setHealth(max(-128, $this->getHealth() - ((int) $dmg)), $cause, $force); } public function heal($health, $cause = "generic"){