How Do I set the user like , By press +use (e button) They can boost for 3 seconds & a 20 second cool down . They just have to press E once , Then they will be able to boost for 3 sec.
I've tried using & reading the method here >
[TUT] Using Button Constant but still doesn't work . Its either it doesn't work or the player the moment on spawn , keep walking to the front . Also , I've already read all post / thread regarding to button , but still it didn't helped me in any .
EDIT ;
Can someone just help me edit this code below to the button +use to speed instead of shift key ? But I still need the 3 sec boost & 20 second cool down.
PHP Code:
#include <amxmodx>
#include <fakemeta>
new bool: g_sprint[33]
new cvar_speed
public plugin_init()
{
register_plugin("Sprint", "0.1", "Mini_Midget");
cvar_speed = register_cvar("sprint_speed", "400");
register_forward( FM_CmdStart, "FMCmdStart" );
register_forward( FM_PlayerPreThink, "FMPreThink" );
register_forward(FM_UpdateClientData, "FMUpdateClientData", 1)
}
public client_putinserver(id)
{
g_sprint[id] = false
}
public FMCmdStart( id, uc_handle, randseed )
{
if (!is_user_alive(id))
return FMRES_IGNORED
new Float:fmove, Float:smove;
get_uc(uc_handle, UC_ForwardMove, fmove);
get_uc(uc_handle, UC_SideMove, smove );
new Float:maxspeed;
pev(id, pev_maxspeed, maxspeed);
new Float:walkspeed = (maxspeed * 0.52);
fmove = floatabs( fmove );
smove = floatabs( smove );
if(fmove <= walkspeed && smove <= walkspeed && !(fmove == 0.0 && smove == 0.0))
{
//client_print( id, print_center, "WALKING" );
g_sprint[id] = true
}
else
{
//client_print( id, print_center, "RUNNING" );
g_sprint[id] = false
}
return FMRES_IGNORED
}
public FMPreThink(id)
{
if (!is_user_alive(id))
return FMRES_IGNORED
static flag ; flag = pev(id, pev_flags)
static button ; button = pev(id, pev_button)
if ( !(flag & FL_ONGROUND) || (flag & FL_DUCKING) || !(button & IN_FORWARD) ) //Block not on ground or ducking or left, back, right movement keys
return FMRES_IGNORED
static Float: sprinting[3], Float: normal[3]
static speed ; speed = get_pcvar_num(cvar_speed)
velocity_by_aim(id, speed, sprinting) //Speed
pev(id, pev_velocity, normal)
sprinting[2] = normal[2]
if (g_sprint[id] == true) //Walking
{
set_pev(id, pev_velocity, sprinting) //Set the speed of sprinting
set_pev(id, pev_button, pev(id,pev_button) & ~IN_ATTACK);
set_pev(id, pev_button, pev(id,pev_button) & ~IN_ATTACK2 );
engclient_cmd(id, "weapon_knife")
//set_pev(id, pev_viewmodel2, "")
}
else if (g_sprint[id] == false) //Running
{
set_pev(id, pev_velocity, normal) //Return to normal speed
}
return FMRES_IGNORED
}
public FMUpdateClientData(id, sendweapons, cd_handle )
{
if ( !is_user_alive(id) || !g_sprint[id])
return FMRES_IGNORED;
set_cd(cd_handle, CD_ID, 0);
return FMRES_HANDLED;
}
Get From
Here
__________________