Player run cancel

Discussion in 'Plugin Development' started by xMalwarez, Aug 31, 2014.

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

    xMalwarez

    Hello there,

    I am trying to make a power system, and I would like to have help.
    I would like to ensure that the person can not run, as if she was only 3 bars food, it moves slowly.
    Do you have ideas to achieve this?

    Good evening to you!
     
  2. Offline

    hintss

    cancel togglesprintevent?
     
  3. Offline

    xMalwarez

    This event doesn't exist..
     
  4. Offline

    hintss

  5. Offline

    xMalwarez

    I try this, and not cancel the sprint player.

    Code:java
    1. @EventHandler
    2. public void method_116_class_32(PlayerToggleSprintEvent event)
    3. {
    4. // toggle to sprint player
    5. Player player = event.getPlayer();
    6. if(Players.energie.containsKey(player)==true && (int) Players.energie.get(player)<=0==true)
    7. {
    8. System.out.println("Okay, this player is not allowed for sprint");
    9. event.setCancelled(true);
    10. }
    11. }


    Is detected, not cancel :( Help me!


    Code:
    [21:33:21 INFO]: Okay, this player is not allowed for sprint
    [21:33:22 INFO]: Okay, this player is not allowed for sprint
    [21:33:23 INFO]: Okay, this player is not allowed for sprint
    [21:33:23 INFO]: Okay, this player is not allowed for sprint
    [21:33:26 INFO]: Okay, this player is not allowed for sprint
    [21:33:27 INFO]: Okay, this player is not allowed for sprint
    [21:33:27 INFO]: Okay, this player is not allowed for sprint
    [21:33:29 INFO]: Okay, this player is not allowed for sprint
    
     
  6. Offline

    Totom3

    xMalwarez Set the players' hunger bar to 3 food icons. This will also prevent those who are lagging from running.
     
    hintss likes this.
  7. Offline

    hintss

    ...clean up your code...
     
  8. Offline

    fireblast709

    xMalwarez Don't decompile code and edit it expecting it will work out of the blue. Just write your own plugin?
     
    hintss likes this.
  9. Offline

    xMalwarez


    You make me laugh, you speak without knowledge of what I do, so much hate in you, that I do not qualify developer aloft.
     
  10. Offline

    fireblast709

    Have you read the method names, lol. You would be the first to personally chose an arbitrary, nondescriptive name :p. I do not hate, I merely state that it is unlikely that you wrote this (or at least a big part of the source) yourself.
     
    hintss likes this.
  11. Offline

    Anrza

    xMalwarez Now, I'm not sure, but I think that sprinting is handled 100% client-side. That's why hacks can make you run with blindness and low hunger, and even while sneaking.

    In 1.5 or so, Mojang messed with it and made it server-side, but quickly reversed this, since there was a constant delay on it, and was a real pain in the ass. IIRC.

    The event probably shouldn't implement cancellable.
    As someone already said, set their food to 6.
     
  12. Offline

    Jalau

    It must be possible because Dungeonrealms does the same thing without setting food level
     
  13. Offline

    Totom3

    Anrza He could listen to PlayerToggleSprintEvent. If the event is triggered after he set the player's food bar then the guy's probably hacking
     
    hintss likes this.
  14. Offline

    BillyGalbreath

    hintss likes this.
Thread Status:
Not open for further replies.

Share This Page