onPlayerMove difficulties.. Stopping movement + speeding up movement.

Discussion in 'Plugin Development' started by Relentless_x, Apr 11, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Relentless_x

    Code:
        public void onPlayerMove(PlayerMoveEvent event) {
            Player player = event.getPlayer();
            if (!(canMove(player))){
            event.setCancelled(true);
            event.setTo(event.getFrom());
            }
    		if (getRace(player).equalsIgnoreCase("elf")) {
    			Vector speed = player.getVelocity();
    			Vector newspeed = speed.multiply(2);
    			player.setVelocity(newspeed);
    
    		}
        }
    Thats is my current curren onPlayerMove()
    The first part is my attempt at stopping people from moving, but i could only make it so it teleports them back to previous location. Can I stop them from moving completely? The second part is meant to speed them up, but it makes them move incredibly slow and they can jump like an inch off the floor but im sure i multiplied the old speed by 2, please help :)
     
  2. Offline

    Raphfrk

    It isn't possible to freeze a player. The best you can do is return them to their old location if they move. If it is any consolation, from the server's perspective, the player is frozen.

    Velocity again is an issue for the client. You could try to teleport them to the new location, but that is also going to be jumpy.
     
  3. Offline

    Relentless_x

    bah ok but plugins like superpowers make you go faster, but it takes you in whichever direction you look...
     
  4. Offline

    Raphfrk

    Hmm, well, you could look at the source (if it is available). If you send updates to the player fast enough, then it may work.
     
Thread Status:
Not open for further replies.

Share This Page