You can use: PHP: /* * @var Player $player */if($player->getGamemode() === 1) { // Survival Mode = 0, Creative Mode = 1, Adventure Mode = 2, Spectator Mode = 4 // your code} https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/Player.php#L1228
can we do something like that? $player = $event->getPlayer(); if($player->getGamemode() == 1,3) { // code } so the code work when the player is in gamemode 1 and when he is in gamemode 3?
If you want to check for multiple conditions in php, you need to write them out out and combine them with a logical or, also it's recommended to use the constants from PocketMine instead of hardcoding the IDs of the gamemodes, as that is more furture-proof and makes the code more readable. PHP: $player = $event->getPlayer();if($player->getGamemode() === Player::CREATIVE || $player->getGamemode() === Player::SPECTATOR) {// code}
$player = $event->getPlayer(); if($player->getGamemode() == 1 or $player->getGamemode() == 3) { // code }