Thanks
ConnorMcLeod,
i tested it but i am not sure if it works or not. I just pasted it in a .sma and compiled it. I couldn't really notice any speeds.
I tried it this way but for some reason, you cannot jump while the below velocity code is in action. Why!?
Can you please correct this code? The current velocity code will disable players jumping ability. Currently you
do get a short burst but you cannot jump, although you have pressed the jump button.
What i want is a "Dodge" jump. Like when you are under fire, you press e.g. D+JUMP and you get a boost jump to the side to get out of the trouble zone.
Thanks.
PHP Code:
new bool:fboost[MAX_PLAYERS+1]
new bool:bboost[MAX_PLAYERS+1]
new bool:rboost[MAX_PLAYERS+1]
new bool:lboost[MAX_PLAYERS+1]
public client_PreThink(id)
{
if(!is_user_alive(id)) return;
new button = pev(id, pev_button);
if((button & IN_JUMP) && (button & IN_FORWARD) && pev(id,pev_flags)&FL_ONGROUND && !is_user_bot(id))
{
fboost[id] = true
set_task (0.3, "boost_end", id)
}
if((button & IN_JUMP) && (button & IN_BACK) && pev(id,pev_flags)&FL_ONGROUND && !is_user_bot(id))
{
bboost[id] = true
set_task (0.3, "boost_end", id)
}
if((button & IN_JUMP) && (button & IN_MOVERIGHT) && pev(id,pev_flags)&FL_ONGROUND && !is_user_bot(id))
{
rboost[id] = true
set_task (0.3, "boost_end", id)
}
if((button & IN_JUMP) && (button & IN_MOVELEFT) && pev(id,pev_flags)&FL_ONGROUND && !is_user_bot(id))
{
lboost[id] = true
set_task (0.3, "boost_end", id)
}
new Float:maxspeed = 600.0;
static Float:aim_velocity[3];
velocity_by_aim(id, floatround(maxspeed), aim_velocity);
static Float:client_origin[3];
pev(id, pev_origin, client_origin);
new Float:velocity[3];
if (fboost[id])
{
velocity[0] += aim_velocity[0];
velocity[1] += aim_velocity[1];
velocity[2] += aim_velocity[2];
set_pev(id, pev_velocity, velocity);
}
if (bboost[id])
{
velocity[0] -= aim_velocity[0];
velocity[1] -= aim_velocity[1];
velocity[2] -= aim_velocity[2];
set_pev(id, pev_velocity, velocity);
}
if (rboost[id])
{
velocity[0] += aim_velocity[1];
velocity[1] -= aim_velocity[0];
set_pev(id, pev_velocity, velocity);
}
if (lboost[id])
{
velocity[0] -= aim_velocity[1];
velocity[1] += aim_velocity[0];
set_pev(id, pev_velocity, velocity);
}
}
public boost_end(id)
{
fboost[id] = false
bboost[id] = false
rboost[id] = false
lboost[id] = false
}
__________________