Set player flight and walking speed

Discussion in 'Plugin Development' started by tschagg, Aug 10, 2012.

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

    tschagg

    Edit:

    Problem fixed.
     
  2. Offline

    agd555

  3. Offline

    tschagg

    how i use that? like player.setFlySpeed(2); or something?
     
  4. Offline

    agd555

    Really, you should start using Bukkit's Javadocs.
    Code:
    void setWalkSpeed(float value)
    void setFlySpeed(float value)
    So yes, Player.setFlySpeed(2) will work.
     
  5. Offline

    MolaynoxX

    Does this also work for swimming? (setWalkSpeed)
     
  6. Offline

    tschagg

    hm that isnt workin for me.
    i've made it like this:

    Code:
          if (cmd.getName().equalsIgnoreCase("fs")) {
              if (sender.hasPermission("tschagg.setflyspeed")) {
            if (args.length == 0) {
              player.setFlySpeed(2);
              succeed = true;
                }
              }
    Error:

    Edit:

    if you make player.setFlySpeed(1);

    it works :) thx for help!

    how can i set a variable in player.setFlySpeed(); ?

    player.setFlySpeed(args[0]); isnt workin, and if i do a string, like:
    Code:
              String flyspeed = 1;
              player.setFlySpeed(flyspeed);
    that dont work too...
    anyone a idea?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  7. Offline

    lol768

    It doesn't accept a String as an argument. Look at the javaDocs.
     
    tschagg likes this.
  8. Offline

    devilquak

    It tells me I can only use an integer between 1 and -1. Does that mean every incremental value you want to use must be something very small with a decimal? I'm kind of confused about how it measures speed changes.
     
  9. Offline

    ZeusAllMighty11

    I am guessing 0 means no modifier, so it would be normal fly speed. So try 0.5 and see the difference...
     
  10. Offline

    Kodfod

    Okay, I works like this:

    Let's say 1 = 100 and -1 = -100

    Now there is a line of numbers. 100 99 98 97 ... 0 ... -97 -98 -99 -100 Okay, now if you want to increase it, go little by little. so lets say 5. you would do .05. Why? Because the decimals can go out to 32(?) Places.

    So just a recap, take a number like 25 and go two places over and stick a decimal: 25 = .25
     
  11. Offline

    devilquak

    That's what I had thought, I was asking to see if anyone else had tried it yet.

    But when I test it, it won't let me use any kind of decimal :confused:

    Only -1, 0, and 1 work, and only setFlySpeed works, setWalkSpeed does nothing. And even then, 1 only makes you go hyper fast and -1 makes your movement controls inverted.

    Am I missing something here, or is this all it does?
     
  12. Offline

    one4me

    I couldn't be bothered with looking up how the code works, but editing the player.data and testing a few numbers I found that:
    • Walk speed is not used.
    • Fly speed is normally .05
    • Setting the fly speed to 0 will make it so the player can only move up or down
      • Anything times zero is zero
    • Setting the fly speed to 1 or -1 will make the player move very slow
      • Then it's as if there is no multiplier
    • Setting the speed higher than .5, or lower than -.5 will invert the controls
      • For regular controls the speed must be between 0.01 to 0.50, or -0.51 to -0.99
      • For inverted controls the speed must be between -0.01 to -0.50 or 0.51 to 0.99
    • For the max speed you would need to set the speed to ±0.99
     
  13. Offline

    WastedWither

    to make a simple string for the walk speed do: public float = *;
    *amount u want the float to be :D
     
  14. Offline

    lionbryce

    dang... i know this post is old, but it's not player.setWalkSpeed(0);
    it would be player.setWalkSpeed(0.0f); if you don't put the f, then it gets confused, the f at the end makes it a float value, which is what the javadoc calls for, so its not player.setWalkSpeed(0.5); it's player.setWalkSpeed(0.5f);
     
  15. Offline

    Nateb1121


    Don't grave dig a thread. Besides, the solution posted could be from older versions of the API.
     
Thread Status:
Not open for further replies.

Share This Page