Could you post the code for me? I've tried cancelling this, but Players still able to sprint though.. Umm.. Yes! but not as effective as cancelling Sprinting Packet!
Not working. Am i missed something ? PHP: public function noSprint(PlayerToggleSprintEvent $event) { // TODO: No Sprint $player = $event->getPlayer(); $player->setDataProperty(Player::DATA_FLAG_SPRINTING, Player::DATA_TYPE_BYTE, false); }
There are conflicts with your code... If you are willing to send the instruction to player so the client doesn't allow any attempts of sprinting, use: PHP: public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); // BTW: Order for parameters is: PropertyId, Value, Flag Type.... $player->setDataFlag($player::DATA_FLAGS, $player::DATA_FLAG_SPRINTING, false, $player::DATA_TYPE_BYTE);} Otherwise, if you are willing to dynamically block sprint, PlayerToggleSprintEvent is your best option: PHP: public function onSprint(PlayerToggleSprintEvent $event){ $event->setCancelled(true);}
The first code is not working. Maybe you're wrong about the parameters: PHP: public function setDataFlag($propertyId, $id, $value = true, $type = self::DATA_TYPE_BYTE){ as in the Entity.php . I don't know what to fill in the $id. DataFlag's id or Player's id ? The second code doesn't work (at all). It's not blocking the sprint, but block to Not stop sprinting. So the player will keep sprinting over and over.
Even the edit sir, since the "check edited" post arrived i edited my code, and still doesn't work: PHP: public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $player->setDataFlag($player::DATA_FLAGS, $player::DATA_FLAG_SPRINTING, false, $player::DATA_TYPE_BYTE); }
Have you tried PlayerMoveEvent? public function onMove(Move $event){$event->getPlayer()->setSprinting(false);}
WORKS! Why its so simple? But will it causes lag ? Because many players will move every tick and ... u know..