rehlds / reapi

AMX Mod X module, using API regamedll & rehlds
GNU General Public License v3.0
158 stars 105 forks source link

don't move, when var_velocity modified. #7

Closed bjallamo closed 8 years ago

bjallamo commented 8 years ago

I made a modification to serfreeman's plugin, but when i'm in the second jump, the character don't move anywhere. I have tried the code with bitstop flag "~" too. Here's a video of the problem: https://www.youtube.com/watch?v=yXIYLEyuuG4

#include <amxmodx>
#include <reapi>

#define MAXJUMPS    2           // maximum jumps

#define IN_JUMP         (1<<1)
#define FL_ONGROUND     (1<<9)

new const PLUGIN[] = "Multijump"
new const VERSION[] = "1.0"
new const AUTHOR[] = "serfreeman1337"   // Reapi modification by mforce

enum _:jdata {
    bool:DOJUMP,
    JUMPCOUNT
}

new player_jumps[33][jdata]

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR);
    RegisterHookChain(RG_CBasePlayer_Jump, "Hook_PlayerJump");
}

public Hook_PlayerJump(id) {
    static oldButtons
    oldButtons = get_entvar(id, var_oldbuttons)

    if(!(get_entvar(id, var_flags) & FL_ONGROUND) && !(oldButtons & IN_JUMP)) {
        if(player_jumps[id][JUMPCOUNT] < MAXJUMPS - 1) {
            player_jumps[id][DOJUMP] = true
            player_jumps[id][JUMPCOUNT] ++
        }
    }
    else if(get_entvar(id, var_flags) & FL_ONGROUND) {
        player_jumps[id][JUMPCOUNT] = 0
    }

    if(player_jumps[id][DOJUMP]) {
        static Float:velocity[3]
        get_entvar(id, var_velocity, velocity)
        velocity[2] = random_float(265.0,285.0)
        set_entvar(id, var_velocity, velocity)

        player_jumps[id][DOJUMP] = false
    }
}

public client_disconnect(id) {
    arrayset(player_jumps[id], 0, jdata)
}

Original: http://1337.uz/download/plugins/sf_multijump.sma

s1lentq commented 8 years ago

Try last build

bjallamo commented 8 years ago

Everything perfect