hello! I need to make a plugin, which protect the chat, like if player swears, the PlayerChatEvent set to cancelled and the server send to the player message "DONT SWEAR!" so I started with this code: PHP: <?phpnamespace AvivShopen\ChatProtect;use pocketmine\plugin\PluginBase;use pocketmine\Player;use pocketmine\Server;use pocketmine\event\Listener;use pocketmine\utils\TextFormat;use pocketmine\event\player\PlayerChatEvent;class MainClass extends PluginBase implements Listener{ function onLoad(){ $this->getLogger()->info(TextFormat::WHITE . "I've been loaded!"); } function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getLogger()->info(TextFormat::DARK_GREEN . "I've been enabled!");} function onDisable(){ $this->getLogger()->info(TextFormat::DARK_RED . "I've been disabled!"); } function onChat(PlayerChatEvent $event) { $player = $event->getPlayer(); $message = $event->getMessage();if ($message == "word") {$player->sendMessage(TextFormat::RED . "Dont say word!!!!");$event->setCancelled(true);}}} the "word" and the message is just for example, so I got a problem, player can say EVERYTHING except "word" like "wordy" "wordi" "I love words" is there a code to fix it?
[CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerChatEvent' to 'ChatProtect v1.0.0': stripos() expects at most 3 parameters, 6 given on AvivShopen\ChatProtect\MainClass [15:40:29] [WARNING]: RuntimeException: "stripos() expects at most 3 parameters, 6 given" (E_WARNING) in "/ChatProtect/src/AvivShopen/ChatProtect/MainClass" at line 50 idk why that's happening, i tried all:/
PHP: <?phpnamespace AvivShopen\ChatProtect;use pocketmine\plugin\PluginBase;use pocketmine\Player;use pocketmine\Server;use pocketmine\event\Listener;use pocketmine\utils\TextFormat;use pocketmine\event\player\PlayerChatEvent;class MainClass extends PluginBase implements Listener{ function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getLogger()->info("enabled!");} function onDisable(){ $this->getLogger()->info("disabled!"); } function onChat(PlayerChatEvent $event) { $player = $event->getPlayer(); $message = $event->getMessage();if(stripos($message, "word" or $message, "word1" or $message, "word2" or $message, "word3" or $message, "word4") === 0){$player->sendMessage(TextFormat::RED . "Dont swear!!!!");$event->setCancelled(true);}}}
i know, I fixed it already but its still not working [CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerChatEvent' to 'ChatProtect v1.0.0': stripos() expects parameter 3 to be long, string given on AvivShopen\ChatProtect\MainClass [09:12:32] [WARNING]: InvalidArgumentException: "stripos() expects parameter 3 to be long, string given" (E_WARNING) in "/ChatProtect/src/AvivShopen/ChatProtect/MainClass" at line 45 but answear me just if you have time, I don't want to annoy you (I just gived the original swears) btw, right now I'm going to codeacademy to learn PHP and don't be a noob! so PLEASE don't tell me that I don't know php cuz I know it and you know it lol