How can I "track" down the end of pressing RIGHT_CLICK_AIR? Is it possible at all? P.s i am russian boy, my english is bad)
I don't really understand your question, could you please explain a bit more? if by "'track' down the end of pressing RIGHT_CLICK_AIR" you mean getting the block the player sees with their crosshair, you can do PHP: /** @var Player $player */$player->getTargetBlock();
No, I make weapons, I want to shoot while the player presses the screen, when he stops pressing - shooting stops.
You could make a task, loop each player, check if they have your weapon in their hand, then check if $player->getItemUseDuration() is over 20, then shoot
I did just that, but when I let go of the screen / RBM, the task still goes on until I click on the block or change the item. PHP: <?phpnamespace test;use pocketmine\{ Server, Player, plugin\PluginBase};use pocketmine\scheduler\Task;//use pocketmine\math\Vector3;use pocketmine\{ event\Listener, event\server\DataPacketReceiveEvent};//use pocketmine\event\player\PlayerInteractEvent;//use pocketmine\network\mcpe\protocol\PlayerActionPacket;class file extends PluginBase implements Listener{ public function onEnable(){ $this->getScheduler()->scheduleRepeatingTask(new shoot($this), 2); //$this->getServer()->getPluginManager()->registerEvents($this, $this); } }class shoot extends Task{ public $p; public function __construct(file $pl){ $this->p = $pl; //parent::__construct($pl, $x); } public function onRun($currentTick){ foreach($this->p->getServer()->getOnlinePlayers() as $pl){ if($pl->getInventory()->getItemInHand()->getId() == 289){ if($pl->getItemUseDuration() > 5){ $pl->sendMessage("test"); } } } } }
can you show your task file? Edit: Sorry I didn't scroll PHP: class shoot extends Task{ public $p; public function __construct(file $pl){ $this->p = $pl; //parent::__construct($pl, $x); } public function onRun($currentTick){ foreach($this->p->getServer()->getOnlinePlayers() as $pl){ if($pl->getInventory()->getItemInHand()->getId() === Item::GUNPOWDER){ if($pl->getItemUseDuration() > 20){ $pl->sendMessage("shoot"); }else{ $pl->sendMessage("not shoot"); } } } }} try this