Quote:
Originally Posted by SaBBa
I might be wrong, but if forward button is pressed twice within 0.5 sec (not required to press them in a row), make_leap func will be executed
PHP Code:
new Float:buttonPressed = 0
public plugin_init()
{
register_clcmd("forward", "hook_command")
}
public hook_command(id)
{
new Float:currentTime = get_gametime()
if(is_user_bot(id))
return PLUGIN_CONTINUE
if((currentTime - buttonPressed) < 0.5) {
// make_leap(id) or whatever you want
} else {
buttonPressed = currentTime
}
return PLUGIN_CONTINUE
}
|
Thank you for trying to help, I got it working by looking at this plugin
https://forums.alliedmods.net/showthread.php?t=229005 from akcaliberg
I used his method and with a bit of work I got it work.
PHP Code:
static button, oldbuttons;
button = pev(id, pev_button);
oldbuttons = pev(id, pev_oldbuttons);
if(button & IN_FORWARD && !(oldbuttons & IN_FORWARD)) {
if( (get_gametime() - LastKeyPressed[id]) < 0.3 ) {
if (fm_get_speed(id) < 80)
return;
static Float:velocity[3]
// Make velocity vector
velocity_by_aim(id, g_survivor[id] ? get_pcvar_num(cvar_leapsurvivorforce) : g_nemesis[id] ? get_pcvar_num(cvar_leapnemesisforce) : !g_zombie[id] ? get_pcvar_num(cvar_leaphumanforce) : get_pcvar_num(cvar_leapzombiesforce), velocity)
// Set custom height
velocity[2] = g_survivor[id] ? get_pcvar_float(cvar_leapsurvivorheight) : g_nemesis[id] ? get_pcvar_float(cvar_leapnemesisheight) : !g_zombie[id] ? get_pcvar_float(cvar_leaphumanheight) : get_pcvar_float(cvar_leapzombiesheight)
// Apply the new velocity
set_pev(id, pev_velocity, velocity)
// Update last leap time
g_lastleaptime[id] = current_time
}
LastKeyPressed[id] = get_gametime();
}