RUN_COMMAND

this callback is called after the game runs input prediction it gives you an instance of the current user_cmd_t and unpredicted_data_t you should avoid to change the current user_cmd_t since it will cause a re-prediction and will cost fps only use this instead of SETUP_COMMAND when you need info on the unpredicted_data_t

-- simple edge jump
local function on_run_command(cmd, unpredicted_data)
    local local_player = entity_list:get_local_player()

    -- were we on the ground before prediction?
    local was_on_ground = unpredicted_data:has_player_flag(e_player_flags.ON_GROUND)

    -- are we on ground right now?
    local is_on_ground = local_player:has_player_flag(e_player_flags.ON_GROUND)

    -- if we know that if we dont change anything about our movement, we will fall off this tick, we can automatically jump
    if not is_on_ground and was_on_ground then
        -- make sure we jump now
        cmd:add_button(e_cmd_buttons.JUMP)
    end
end

callbacks.add(e_callbacks.RUN_COMMAND, on_run_command)

Last updated