so i was make an UI Plugin, but something went wrong. So when player click on one of the button they got kicked and got "Internal Server Error" Message Here's my Code: https://pastebin.com/tqxMrtWH (Sorry i use pastebin instend cuz i dont know how to wrote code menu) And heres i got this error message in my console: "Argument 1 passed to MulkiAqi192\ChatCotmine\Player given, called in C:\Users\asus\Desktop\PM\plugins\ChatColors\src\MulkiAqi19 line 62" i dont know how to fix this cuz am new PHP Programmer, i will appreciate it if someone want to help me Sorry for my bad english
i fixed that but then when i clicked at Yellow button i got another error: "Argument 1 passed to MulkiAqi192\ChatColors\main onChatYellow() must be an instance of pocketmine\event\player\PlayerChatEvent, instance of pocketmine\Player given, called in C:\Users\asus\Desktop\PM\plugins\ChatColors\src\MulkiAqi192\ChatColors\Main.php on line 52" (EXCEPTION) in "plugins/ChatColors/src/MulkiAqi192/ChatColors/Main" at line 69"
i want to change player Format when they click one of the UI button... and can you explain whats the error mean please?
onChatYellow() must be an instance of pocketmine\event\player\PlayerChatEvent, instance of pocketmine\Player given. exactly what the error says.. your onChatYellow parameter is asking for PlayerChatEvent, but you are giving Player
Ok thank you i think its hard to make this plugin (for me) xD i will mark this as Solved now thank you
oh btw if i'm not brothering you, can you tell me how to give PlayerChatEvent to the onChatYellow? cuz i have no idea how to change Player to PlayerChatEvent
or anyone if you want to help me with this problem hehe am still doing research for the problem, but i will appreciate if you help me in here
No that's not how it works. The methods you use are listening for events, so the methods/functions will be called whenever a play chats. (this only happens if you registered a listener). To achieve what you want, you would need to save the chatcolor preference of the player in a database, file or array. When the player chats the PlayerChatEvent will be triggered automatically. In that method you can execute whatever code you want it to execute when a player chats. PHP: // This will trigger whenever the player chats.public function onChat(PlayerChatEvent $e){ $e->sendMessage("You have sent a message"); }
ok i fixed my problem by myself hehe for someone in the future if you're begginer proggramer like me and you have the same problem, the error said you put the wrong member or function something like that. Instend you need to use array & database to save player by doing the command PHP: public red = []; and then you need to add player to the array when player excute the command PHP: $sendername = $sender->getName(); $this->red[$sendername] = $sendername; and then check the player if the player is registered in the array PHP: if(isset($this->red[$player->getName()])){ $event->setMessage("§c" . $msg); } and done UwU, thank you @Mohagames205 & @Levi for helping me