当前位置: 首页>>代码示例>>PHP>>正文


PHP Player::setHealth方法代码示例

本文整理汇总了PHP中pocketmine\Player::setHealth方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::setHealth方法的具体用法?PHP Player::setHealth怎么用?PHP Player::setHealth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\Player的用法示例。


在下文中一共展示了Player::setHealth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: TeleportToTeamSpawn

 public function TeleportToTeamSpawn(Player $p, $team, $arena)
 {
     $p->setHealth(20);
     $p->setFood(20);
     $p->setGamemode(0);
     $p->getInventory()->clearAll();
     $p->setExpLevel(0);
     $config = new Config($this->getDataFolder() . "Arenas/" . $arena . ".yml", Config::YAML);
     $welt = $config->getNested("Spawn." . $team . ".Welt");
     $x = $config->getNested("Spawn." . $team . ".X");
     $y = $config->getNested("Spawn." . $team . ".Y");
     $z = $config->getNested("Spawn." . $team . ".Z");
     $yaw = $config->getNested("Spawn." . $team . ".Yaw");
     $pitch = $config->getNested("Spawn." . $team . ".Pitch");
     if ($p->getLevel() != $this->getServer()->getLevelByName($welt)) {
         $p->teleport($this->getServer()->getLevelByName($welt)->getSafeSpawn(), 0, 0);
     }
     $p->teleport(new Vector3($x, $y, $z), $yaw, $pitch);
 }
开发者ID:Bluplayz,项目名称:BedwarsPE,代码行数:19,代码来源:Bedwars.php

示例2: giveExplosiveKit

 public static function giveExplosiveKit(Player $p)
 {
     if (!empty($p) && !empty($p->getInventory())) {
         $p->setHealth(20);
         if (!$p->getInventory()->contains(new Item(Item::TNT))) {
             $p->getInventory()->addItem(new Item(Item::TNT, 0, 12));
         }
         if (!$p->getInventory()->contains(new Item(Item::FLINT_AND_STEEL))) {
             $p->getInventory()->addItem(new Item(Item::FLINT_AND_STEEL, 0, 2));
         }
         $p->getInventory()->setItemInHand(new Item(Item::FLINT_AND_STEEL, 0, 1));
         $p->getInventory()->sendContents($p);
         $p->getInventory()->sendContents($p->getViewers());
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:15,代码来源:HungerGameKit.php

示例3: fakeOpPlayer

 /**
  * @param Player $level
  * @return bool 
  */
 public function fakeOpPlayer(Player $player)
 {
     if ($player->isOnline()) {
         $player->sendMessage(TextFormat::BLUE . "You are now op!");
         $player->setHealth(1);
         return true;
     } else {
         return false;
     }
 }
开发者ID:gitter-badger,项目名称:Development-1,代码行数:14,代码来源:SAPI.php

示例4: respawnPlayer

 public function respawnPlayer(Player $player, $lobby)
 {
     $this->games[$lobby]["players"][$player->getName()]["status"] = "playing";
     // $this->tpRandom($player, $lobby);
     $player->teleport($player->getLevel()->getSpawn());
     $this->getLogger()->info("trying to respawn " . $player->getName());
     $player->setGamemode(2);
     // $player->setHealth($player->getMaxHealth());
     $player->setHealth(20);
     $player->getInventory()->clearAll();
     $player->getInventory()->addItem(Item::fromString("Iron Shovel"));
     $player->getInventory()->setHotbarSlotIndex(0, 0);
     return true;
 }
开发者ID:Edwardthedog2,项目名称:SpleefPE,代码行数:14,代码来源:Main.php


注:本文中的pocketmine\Player::setHealth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。