Im making a plugin where a player gave give his staff members effects. I have the itemheld event but how can I make it so that it can only give effects to fac members in a certain radius(connecting it to FactionsPro api*I know how to do that * PHP: public function onHeld(PlayerItemHeldEvent $event) { $player = $event->getPlayer(); $name = $player->getName(); switch($event->getItem()->getId()){ case Item::SUGAR: $player->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(1)->setDuration(20 * 8)); break; case Item::BLAZE_POWDER: $player->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(0)->setDuration(20 * 8)); break; case Item::GHAST_TEAR: $player->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(1)->setDuration(20 * 8)); break; case Item::IRON_INGOT: $player->addEffect(Effect::getEffect(Effect::DAMAGE_RESISTANCE)->setAmplifier(1)->setDuration(20 * 8)); break; case Item::FEATHER: $player->addEffect(Effect::getEffect(Effect::JUMP)->setAmplifier(1)->setDuration(20 * 8)) break; } }
You are dumb, I said I know how to connect the factions pro api already. I just need help with checking if a player is in a radius. Please use your head and read and comprehend stuff better before you say anything thanks.
Maybe make more sense then people can comprehend what you are trying to say. This really does make sense doesn't it?
well, you need to get viewers of the player *disclaimer:this is no PHP and pls dont copy and paste it, nothing here is exact and normally you will need your ide to get the actual method names foreach $player->getviewer() as $viewers if viewers instance of player AND viewers->isteammate($player) AND viewers->distance($player) < [the effect range] //to effect $player->getviewer() can be replaced with $faction->getonlineplayers(), tho might just be micro optimizations
Solved- used player move event and checked if the player was in radius if not then thatd almost close to what I did thanks so much.
Please nonononononononnononononononono use task please or else you will be lagging your server like crap for running code onMove
Yeah, my freind told me just make it a regular public function checkDistance(player $p) and then $this->checkDistance to check if online fac members are in range. I didnt use the onMove event