Hello comrades! I want create plugin who on/off breaknews on server (player message are broadcast in our server), but my plugin not work... Code PHP: CHATpublic function onChat(PlayerChatEvent $e1){$pl = $e1->getPLayer();$text = $e1->getMessage();$nickname = $pl->getName();$adm = $this->PP->getUserDataMgr()->getGroup($pl)->getName();foreach($this->getServer()->getOnlinePlayers() as $play){$px = $pl->getFloorX();$py = $pl->getFloorY();$pz = $pl->getFloorZ();$plx = $play->getFloorX();$ply = $play->getFloorY();$plz = $play->getFloorZ();$pxx = $px - $plx;$pyy = $py - $ply;$pzz = $pz - $plz;if($pxx < 7 && $pyy < 7 && $pzz < 7 && $pxx > -7 && $pyy > -7 && $pzz > -7){$this->getServer()->broadcastMessage("§l§f • §cПрямой эфир §f | ".$pl->getName().": ".$text);$e1->setCancelled();} else {$play->sendMessage("§a".$adm." §f§l ".$nickname.": ".$text);$e1->setCancelled();}}}public function offChat(PlayerChatEvent $e2){$pl = $e2->getPLayer();$text = $e2->getMessage();$nickname = $pl->getName();$adm = $this->PP->getUserDataMgr()->getGroup($pl)->getName();foreach($this->getServer()->getOnlinePlayers() as $play){$px = $pl->getFloorX();$py = $pl->getFloorY();$pz = $pl->getFloorZ();$plx = $play->getFloorX();$ply = $play->getFloorY();$plz = $play->getFloorZ();$pxx = $px - $plx;$pyy = $py - $ply;$pzz = $pz - $plz;if($pxx < 7 && $pyy < 7 && $pzz < 7 && $pxx > -7 && $pyy > -7 && $pzz > -7){$play->sendMessage("§a".$adm." §f§l ".$nickname.": ".$text);$e2->setCancelled();}}}COMMANDcase "trans":$rich = $this->rich->getAll();if($rich[$p->getName()] >= 3){if(isset($args[0])){if($args[0] == "on"){$p->sendMessage("§l§b» §Live stream enable!");$this->onChat($p->getName());}if($args[0] == "off"){$p->sendMessage("§l§b» §fLive stream disable!");$this->offChat($p->getName());} else {$p->sendMessage("§l§b» §fplease, use /trans on | off");}} else {$p->sendMessage("§l§b» §fplease use /trans on | off");}} else {$p->sendMessage("§l§b» §fYou have not permission!");}break; Message from console TypeError: "zagadka\dury\Main:ffChat(): Argument #1 ($e2) must be of type pocketmine\event\player\PlayerChatEvent, string given, called in /home/plugins/RichardStation/src/zagadka/dury/Main.php on line 124" (EXCEPTION) in "plugins/RichardStation/src/zagadka/dury/Main" at line 53
You provided string in $this->offChat($p->getName()) ($p->getName()) while the function requires PlayerChatEvent object. I also see some things to point out! 1. It seems like you're using PM3! I recommend you to update it to PM4. 2. event->getPLayer() be like
no, the function offChat requires pocketmine\event\player\PlayerChatEvent for its first param But you provided a player object's name
Oh, thanks comrade, but is not end... Well... Everything would be fine, but I do not know how to $event to take what I need, I wrote like this $this->onChat(PlayerChatEvent()->getPlayer()); but it doesn't work... What's wrong?
okay, i find in this forum as make this, $this->onChat($event->getPlayer()); but i dont know what i should do of "$event", plugin not find this value ://
Well... I need create something "stream". Plugin have two mode "onChat" - enable break and "offChat" - disable them, thanks command, player change mode, onChat set broadcast all message player, offChat disable them... And sorry of my English langauge
Uhh..Correct me if I'm wrong, but this is what I understood: If someone's onChat, their message is viewable to everyone On the other hand, if someone is offChat, their message sending is cancelled
no, if player change mode of onChat, player message are translated in server and all players view them