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


PHP Player::setGamemode方法代码示例

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


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

 private function checkInVIP(Player $player)
 {
     //if ($player->getLevel ()->getName () === $this->plugin->vipLevelName) {
     if (isset($this->vips[$player->getName()])) {
         $this->plugin->log("[HG] VIPPlayerListener->VIPCheck-IN: " . $player->getName());
         return true;
     } else {
         $vip = $this->plugin->profileManager->isPlayerVIP($player->getName());
         if (!$vip) {
             return false;
         }
         if (!$player->isOp()) {
             if (!$player->isSurvival()) {
                 $player->setGamemode(Player::SURVIVAL);
             }
         }
         $this->vips[$player->getName()] = $player->getName();
         $this->plugin->log("[HG] VIPPlayerListener->VIPCheck-IN: " . $player->getName());
         return true;
     }
     //}
     return false;
 }
开发者ID:robozeri,项目名称:SG,代码行数:23,代码来源:VIPPlayerListener.php

示例3: restorePlayer

 public function restorePlayer(Player $player)
 {
     if (isset($this->players[$player->getName()])) {
         $get = $this->players[$player->getName()];
         $player->setGamemode($get["gamemode"]);
         $player->getInventory()->setContents(unserialize($get["inventory"]));
         $player->getInventory()->setArmorContents(unserialize($get["armor"]));
         $player->teleport(unserialize($get["spawn"]));
         unset($this->players[$player->getName()]);
     }
 }
开发者ID:EmreTr1,项目名称:TNTRun,代码行数:11,代码来源:PlayerData.php

示例4: participate

 public function participate(Player $player)
 {
     $soldier = new soldier($player);
     if ($player->isCreative()) {
         $player->setGamemode(0);
     }
     if (count($this->redteam->soldiers) < count($this->blueteam->soldiers)) {
         $soldier->setTeam($this->redteam);
         $color = TextFormat::RED;
     } else {
         $soldier->setTeam($this->blueteam);
         $color = TextFormat::BLUE;
     }
     $soldier->getTeam()->soldiers[$player->getName()] = $soldier;
     $rank = RankProvider::getInstance()->getRank($player);
     $prefix = $color . $soldier->getTeam()->getTeamName() . TextFormat::GOLD;
     $rank->addPrefixs([$prefix]);
     $rank->setPrefix($prefix);
     $player->teleport($soldier->getTeam()->getSpawnPoint());
     $this->eventlistener->giveRandomItem($player);
     $this->soldiers[$player->getName()] = $soldier;
 }
开发者ID:organization,项目名称:MCFTWARS,代码行数:22,代码来源:war.php

示例5: removePlayer

 public function removePlayer(Player $player)
 {
     if (isset($this->players[$player->getName()])) {
         unset($this->players[$player->getName()]);
         unset($player->arena);
         $player->teleport(Server::getInstance()->getDefaultLevel()->getSafeSpawn());
         $player->setGamemode($player->prevGamemode);
         unset($player->prevGamemode);
         $player->getInventory()->remove($player->breakItem);
         unset($player->breakItem);
         return true;
     } else {
         $player->sendMessage("You couldn't be removed from the arena.");
     }
 }
开发者ID:Skull3x,项目名称:WonderCore,代码行数:15,代码来源:Arena.php

示例6: killHandler

 public function killHandler(Player $entity)
 {
     // $this->getServer()->broadcastMessage("killHandler tries to handle");
     // player add deaths
     // $nr = $this->games[strtolower($entity->getLevel()->getName())]["players"][$entity->getName()]["deaths"] + 1;
     // $this->games[strtolower($entity->getLevel()->getName())]["players"][$entity->getName()]["deaths"] = $nr;
     // save to config.. WHY EVEN?! can't i do ranks just only by times played and wins?
     $this->getPlayerConfig();
     $this->players->getAll()[$entity->getName()]["deaths"]++;
     $this->setPlayerConfig();
     $entity->sendTip(TextFormat::RED . "You fell into void");
     $entity->setGamemode(3);
     $entity->teleport($entity->getLevel()->getSpawnLocation());
     $this->leaveLobby($entity, $entity->getLevel());
     // if killer add kills
     /*
      * if($killer !== null){
      * $players = array();
      * foreach(array_keys($this->games[strtolower($killer->getLevel()->getName())]["players"]) as $player){
      * array_push($players, $this->getServer()->getPlayer($player));
      * }
      * $this->getServer()->broadcastMessage(TextFormat::RED . $killer->getDisplayName() . " killed " . $entity->getDisplayName(), $players);
      * $this->games[strtolower($killer->getLevel()->getName())]["players"][$killer->getName()]["kills"]++;
      * // add arrow
      * $killer->getInventory()->addItem(Item::fromString("Arrow"));
      * // save to config.. WHY EVEN?! can't i do ranks just only by times played and wins?
      * $this->getPlayerConfig();
      * $this->players->getAll()[$killer->getName()]["kills"]++;
      * $this->setPlayerConfig();
      * $killer->sendTip(TextFormat::GOLD . "Kills: " . TextFormat::GREEN . $this->games[strtolower($killer->getLevel()->getName())]["players"][$killer->getName()]["kills"] . TextFormat::LIGHT_PURPLE . " | " . TextFormat::GOLD . "Deaths: " . TextFormat::RED . $this->games[strtolower($killer->getLevel()->getName())]["players"][$killer->getName()]["deaths"]);
      */
     if (isset($this->games[strtolower($entity->getLevel()->getName())])) {
         if (count(array_keys($this->games[strtolower($entity->getLevel()->getName())]["players"])) <= 1) {
             $this->stopGame($entity->getLevel(), $this->getServer()->getPlayer(array_keys($this->games[strtolower($entity->getLevel()->getName())]["players"])[0]));
             return;
         }
         // }
         // else{
         $this->getServer()->broadcastTip(TextFormat::RED . $entity->getName() . " fell into void\n" . TextFormat::GREEN . count(array_keys($this->games[strtolower($entity->getLevel()->getName())]["players"])) . " players remaining");
     }
     // }
     // end if died too often
     /*
      * if($nr >= $this->getConfig()->getNested("lobby-defaults.maxdeaths")){
      * $entity->setGamemode(3);
      * $entity->sendMessage(TextFormat::RED . "You died too many times.");
      * // leave or better let the player spectate? if spectate then the player has to do /spleef leave.. but the game will run until the player will do this
      * }
      * else{
      * $this->respawnPlayer($entity, strtolower($entity->getLevel()->getName()));
      * }
      */
     $this->leaveLobby($entity, $entity->getLevel());
 }
开发者ID:Edwardthedog2,项目名称:SpleefPE,代码行数:54,代码来源:Main.php

示例7: giveItemAndEffect

 public function giveItemAndEffect(Player $player)
 {
     $player->setGamemode(2);
     $player->getInventory()->addItem(new Item(Item::MUSHROOM_STEW, 0, 1));
     $this->giveEffect($player);
 }
开发者ID:EpicArtz08999,项目名称:ZombieGame,代码行数:6,代码来源:GameGenius.php


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