Simple doublejump
#1
So I'm coding a doublejump plugin for my server, and I was wondering what the most optimal way of doing so was.

My current code:
Code:
function OnTick(Player, TimeDelta)
    if(not Player.IsOnGround) then
        if(Player.IsSprinting) then
            -- Do Stuff
        end
    end
end

I haven't really dug into the docs yet, so I'm likely missing something. I know that I would need to track the jump input in the if statement somehow... How would I go about doing that? Also, does IsSprinting get set to false if the player is airborne? And is it smart to be checking this every tick, or is there another hook that would be more optimal?

Please and thank you.
Reply
Thanks given by:
#2
I'm afraid any kind of a doublejump plugin would be a hack at best. Currently, there's no way for Cuberite plugins to read the packets sent by the client directly, so there's no way to detect the second press of the jump key (even if the client send it at all (?)).

The IsSprinting flag is taken directly from the client, so whatever the client says, the flag mirrors.

As for your code, the OnTick() hook doesn't get any Player parameter, it gets a World parameter, so you'll need to iterate over all players in the world. Also note that most if not all functions in Cuberite API need to be called using the colon convention - Player:IsOnGround() etc.
Reply
Thanks given by:
#3
I've seen people implement double jumping by detecting if they're flying. It would end up something like this:
Code:
if (player is flying) then
   stop player from flying
   set Y speed to make the player go upwards.
You can let players in survival fly by using <player>:SetCanFly(true)
Reply
Thanks given by:
#4
Another idea would be to use AddEntityEffect_1:
a_Player:AddEntityEffect(cEntityEffect.effJumpBoost, 200, 1, 1)
This gives you jump boost 2 with an duration of 10s   Smile
Reply
Thanks given by:
#5
That isn't a double jump though. It might be sufficient depending on what @nrgjrteherh435 wants to have double jump for.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)