Hi, I would like to know what's the code to broadcast a general message that everyone can see, but, with the variable "player" in front, that change in function of the player executing the command. Eg : ZakousseMC : /afk "player" is now AFK. This is one of the code I wrote, but when I execute it, an error message appears. PHP: public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { $sender->sendMessage(TextFormat::GREEN . "Vous etes desormais AFK."); $this->api->console->run("broadcast est desormais AFK."); return false;
No just no.... I just fixed your Code but please learn the API. PHP: public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { switch ($cmd->getName()) { case "afk": if ($sender instanceof Player) { $pn = $sender->getName(); $sender->getServer()->broadcastMessage("$pn is now AFK for $args[0] Minutes!"); } } } So I made that the command usage is: /afk [minutes] It will broadcast the Message.
Read what I said in the other topic, I'm french, not english, and I can't find anything in french, I'm just taking other codes and trying to figure out what it does. So please, before talking, try having my point of view, it's not because it's easy for you, that it is for me huh.
Lol i am from Germany my English isnt also good but lol php is in english lol. Just change the message where $sender->sendMessage () is.