Code:
#include <amxmodx>
#include <engine>
#include <xs>
public client_PreThink(id) {
if(is_user_alive(id)) {
new button = get_user_button(id);
new oldbuttons = get_user_oldbutton(id);
new pressed = button & ~oldbuttons;
new flags = get_entity_flags(id);
new onground = flags & FL_ONGROUND;
if(pressed & IN_JUMP && onground) {
// Player is jumping
new tmp[3], Float:eyes[3], Float:aim[3];
get_user_origin(id, tmp, 1);
IVecFVec(tmp, eyes);
get_user_origin(id, tmp, 3);
IVecFVec(tmp, aim);
new Float:aimDirection[3];
xs_vec_sub(aim, eyes, aimDirection);
new Float:aimAngledRight[3], Float:aimAngledLeft[3];
angle_vector(aimDirection, ANGLEVECTOR_RIGHT, aimAngledRight);
xs_vec_neg(aimAngledRight, aimAngledLeft);
new Float:velocity[3];
entity_get_vector(id, EV_VEC_velocity, velocity);
aimAngledRight[2] = aimAngledLeft[2] = velocity[2] = 0.0;
if(xs_vec_angle(aimAngledRight, velocity) < 45.0) {
// Jumped to the right
}
else if(xs_vec_angle(aimAngledLeft, velocity) < 45.0) {
// Jumped to the left
}
}
if(pressed & IN_DUCK) {
// Player started ducking
}
if(button & IN_MOVELEFT) {
if(~button & IN_MOVERIGHT) {
// Player is moving left
}
}
else if(button & IN_MOVERIGHT) {
// Player is moving right
}
}
}