I am wondering how do I make a command that detects or calls a player? Here is an example: /hey <player> Sends a hey to the selected player.
Not really what I was looking for. Thanks tho. I looking into MassiveEconomy and saw you used args to define the player and money with the /pay <player> <amount>. Could you show me an example command that calls the player? /poke <player>
$args is the array containing all command parameters. Each value of array is split by space. For example if you run: /example player, $args[0] will be example and $args[1] will be player Simply replace $playername with $args[1] and you'll get the name of the specified player
this will cause an error if $this->getServer()->getPlayer($playername) is null. you should do this just to be safe: if($this->getServer()->getPlayer($playername) instanceof Player){ $this->getServer()->getPlayer($playername)->sendMessage("Hey! "); }
We don't always call it $args. Off-topic: Last time I got too addicted, whenever I use array_shfit() I want to put $args inside it. Since array_shift() accepts the parameter by reference, PhpStorm didn't show a warning. Eventually, it took me quite a while to find out the problem