I have a simple Minigame plugin called BlockRun. I want to freeze a player before they start. They get in by tapping a sign then they are in on their spawns. How can I freeze them? I know PlayerMoveEvent, but how do I add a player to an array (Maybe...) and check if they are in-game then when the game starts they unfreeze all the players. I think basicly the problem is the arrays. IDK how to use them XD. How can I acheive that???
so create a array using PHP: $arrayname = array(); you can then add players to the array by array_push i recomend names PHP: array_push($arrayname, $player) and then to check if player is in array use in_array PHP: if (in_array($player, $arrayname)){//DO something here} to remove player PHP: if (($key = array_search($player, $arrayname)) !== false) { unset($array[$key]);} other array stuff i would suggest google
First question yea i think i dont get what your asking to well. And for the second one the way i did was easier so later you can get a player from array and sendmessage or teleport directly from the item in array if ($item instanceof Player) of course. Hope that makes sense?
PHP: if (($key = array_search($player, $arrayname)) !== false) { unset($array[$key]); } Should the $array be changed to $arrayname?
yea and also $event->getPlayer() also returns player name just for a fyi (at least for me it does) so the list of player in the array would be by name
How do I make the frozen player able to see around? PHP: public function onFrozenMove(PlayerMoveEvent $event){ if (in_array($event->getPlayer()->getName(), $this->plugin->freeze)){ $event->setCancelled(true); }else{ $event->setCancelled(false); }} ??? I saw GrabBag but IDK how to implent it in my plugin...
PHP: $event->getPlayer(); returns player id! like: Player(1), not a name ! To get name do PHP: $event->getPlayer()->getName(); now it will return a name!
That's not just the ID. It returns the Player object, but if you use the object as a string, you would get $player->__toString(), which is implemented in the Entity class: https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/entity/Entity.php#L1570