:| $count = 0; foreach($this->getLevelByName("StuffMap")->getEntities() as $entitys) { if($entities instanceof Zombie) { $count++; } }
I have now counted the entities but I would like that if a player kills 10 zombies the following message comes up: You managed to kill 10 zombies
:| use cfg, save player kills to array and save it to cfg, and foreach kill do some thing like $count++; it wi;; save players how many zombie killed but its laggy for server
learn php befor creating plugins, when you dont know lessons in school, how can you take extraexam? you need to learn first, then exam.
That's exactly what you should do now. Those forums are to help people with it, not to tell them to learn it on himself. Maybe you know some php basics, but to help someone you need much more knowledge. In every second post by you I see wrong information... Also try improve your English, I think google could translate your messages better than you.
You must save each kill while EntityDeathEvent is called. Then you must find the value for player you saved.
ok, sorry i make my torurials better (in explation) and ok i use google translator XD to translate messages, you right
use statments: PHP: use pocketmine\entity\Zombie;use pocketmine\event\entity\EntityDamageByEntityEvent;use pocketmine\event\Listener;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\Player;use pocketmine\plugin\PluginBase; and use this: PHP: class Main extends PluginBase implements Listener{ public function onJoin(PlayerJoinEvent $event) { //save zombieKills of player to 0 if(!isset($cfg["zombieKills"])) {} //idk how do you want to use config, you should do this own your self //also register events } /** * @param EntityDamageByEntityEvent $event */ public function onPvM(EntityDamageByEntityEvent $event) { //PvM is Player vs Mob XD $damager = $event->getDamager(); $zombie = $event->getEntity(); $zombieKills = 0; if ($damager instanceof Player && $zombie instanceof Zombie) { if ($zombie->getHealth() - $event->getFinalDamage() <= 0) { $zombieKills++; //now you can save it to cfg, but its laggy, its better to save it with task or onDisable func..? //now when player kills a zombie mob, add +1 number to his kills in cfg and you can check it if player zombieKills are === 10 sendmessage tp player, you have killed 10 zombie $damager->sendMessage("You Killed " . $zombieKills . " Zombies"); //just for see plugin is working or not } } }} it should solving, sorry my last code is wring its correct now
Why are you checking twice that Zombie is instance of zombie? Also do you know that EntityDeathEvent exists?
because i wrote twice code and i forget to remove that, now edited i know, there isn't difference, its working, what is your problem to me? Why do you want to prove your superiority to others by making useless objections?
ok, how can we do it in your idea? idk how to, so he need to count zombie kills for each player can you send code? i want learn a more.
I said it in my first post in this thread. In the next one I told you it won't work. That's all. By the way did you test the code? ^ There are several mistakes in the code. ^ 1) The first one is that variable $zombieKills will be reseted after the function start again so player can reach max 1 zombie kill 2) The second one is that if you would think about the code more, and didn't make mistake #1, then you would (maybe) recognise that you store values for every players in one integer public variable and that you must create array for that. 3) If you want handle EntityDamageByEntityEvent, you must use EntityDamageEvent, and then check if it's instanceof EntityDamageByEntityEvent 4) You already fixed that you checked that $zombie is instanceof Zombie twice ----> GOOD JOB!