Hi. I want to broadcast a message to specific players not all players. Or using sendMessage to specific players, not one player. Is there any way to do that?
use this code: PHP: $players = [] //player you want to send packet/messageforeach($players as $player){ // your code like $player->sendMessage("hey there");}
Thanks for your reply And, I tried to like this PHP: $online = $this->getServer()->getOnlinePlayers();$players = array($online);$english = array($this->lang->db [$players] ["language"] == "eng");$korea = array($this->lang->db [$players] ["language"] == "kor");foreach($english as $englang) { $this->getServer()->broadcastMessage("Broadcast Test in English", $englang);}foreach($korea as $korealang) { $this->getServer()->broadcastMessage("Broadcast Test in Korean Language", $korealang);} *In this code, $this->lang is to get config from my own plugin for a multi-language system. So.. I should send different messages to each language. But in this code, I got Code: 'ErrorException: "Illegal offset type" (EXCEPTION)' I have no idea what 'Illegal offset type' means.
1. $this->getServer()->getOnlinePlayers() is array no nee to put in into other array the result will be [[/*players array*/]] 2.what is $this->lang->db [$players] ["language"]? and what == "eng" or second one? i recommend you first learn php basics