1. How do you set health of player in-game? like adding hearts? (with Katana) like LegionPE? 2. How do you send a message to public? not only in 1 player? 3. how to mute player with timer?
I supose it's broken. Third's answer: if(in_array($player->getName(), $this->muted, true)) $e->setCancelled();
You're making it hard... PHP: public function onChat(PlayerChatEvent $event){$muted = array("MutedPlayer1", "MutedPlayer2"); //etc..if($event->getPlayer()->getName() == in_array($muted){$event->setCancelled(true);}}
PHP: public function onChat(PlayerChatEvent $ev){ $p = $ev->getPlayer(); $pl = $ev->$getPlayer()->getName(); $badwords = array("fuck","pussy","bitch","nigga","cunt","whore","asshole","dick","pene", "penis","cock","hoe","stfu","kys","sma","smd","asshole","ass","fuckboi","fuckboy","cocksucker","dick","dicksucker","penissucker"); $msg = explode(" ",$ev->getMessage()); foreach($msg as $word){ foreach($badwords as $m){ if(strtolower($word) === $m){ $this->getServer()->BroadcastMessage("§e-§c§lCalm down§a" $pl); $p->sendMessage("§cYou have been muted for 10 seconds"); I just wanted to add a 10 seconds time muter on this
PHP: if(isset($this->history[$player->getName()])){ if($this->history[$player->getName()] >= time()){ // Calm down time has been expired $this->history[$player->getName()] = time() + 10; }else{ $player->sendMessage('Dont chat so fast.'); }} else { $this->history[$player->getName()] = time() + 10;}
PHP: public function onChat(PlayerChatEvent $ev){ $p = $ev->getPlayer(); $pl = $ev->$getPlayer()->getName(); $badwords = array("fuck","pussy","bitch","nigga","cunt","whore","asshole","dick","pene", "penis","cock","hoe","stfu","kys","sma","smd","asshole","ass","fuckboi","fuckboy","cocksucker","dick","dicksucker","penissucker"); $msg = explode(" ",$ev->getMessage()); foreach($msg as $word){ foreach($badwords as $m){ if(strtolower($word) === $m){ $this->getServer()->BroadcastMessage("§e-§c§lCalm down§a" $pl); $p->sendMessage("§cYou have been muted for 10 seconds"); if(isset($this->history[$p->getName()])){ if($this->history[$p->getName()] >= time()){ // Calm down time has been expired $this->history[$p->getName()] = time() + 10;} else { $this->history[$player->getName()] = time() + 10; wil that work now? shh ik im bad at coding Im just trying to learn by this
Side notes: LegionPE uses Katana. It does some backs with the Attribute manager, which does not work with PocketMine. LegionPE uses a complex method of muting. There is a kind of Hormone called MuteHormone, which will tell receptor servers to block chat from players of that IP or username until a certain timestamp. You can look at http://lgpe.co/tsrc for reference.
I didn't steal it or what, I've tried to update it if possible with some helps by these developers. It was the plugin from BearGames which needs to be updated because of the poor idea and code. yes, it's his code, Any problem?