Mini_Midget
04-29-2008, 01:21
#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, "FW_CmdStart" );
register_forward(FM_PlayerPreThink, "FW_PreThink" );
register_forward(FM_UpdateClientData, "FW_UpdateClientData", 1)
}
public client_putinserver(id)
{
g_sprint[id] = false
}
public FW_CmdStart( 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 FW_PreThink(id)
{
if (!is_user_alive(id))
return FMRES_IGNORED
static flag ; flag = pev(id, pev_flags)
static button ; button = pev(id, pev_button)
//Block not on ground or ducking or left, back, right movement keys
if ( !(flag & FL_ONGROUND) || (flag & FL_DUCKING) || !(button & IN_FORWARD) )
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, button & ~IN_ATTACK );
set_pev(id, pev_button, 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 FW_UpdateClientData(id, sendweapons, cd_handle )
{
if ( !is_user_alive(id) || !g_sprint[id] || !(pev(id, pev_button) & IN_FORWARD) )
return FMRES_IGNORED;
set_cd(cd_handle, CD_ID, 0);
return FMRES_HANDLED;
}
While sprinting, I'm trying to make it you have nothing in your hands rather than running around with your knife. But the problem is when I set the view model to nothing. It will stay like that even if you change weapons and such. What I want to do is to remember the weapon you had BEFORE you started sprinting so then I can set the view model back to normal when you stop sprinting.
I also want to try and make a small delay before you can fire when you just release the sprint key.
#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, "FW_CmdStart" );
register_forward(FM_PlayerPreThink, "FW_PreThink" );
register_forward(FM_UpdateClientData, "FW_UpdateClientData", 1)
}
public client_putinserver(id)
{
g_sprint[id] = false
}
public FW_CmdStart( 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 FW_PreThink(id)
{
if (!is_user_alive(id))
return FMRES_IGNORED
static flag ; flag = pev(id, pev_flags)
static button ; button = pev(id, pev_button)
//Block not on ground or ducking or left, back, right movement keys
if ( !(flag & FL_ONGROUND) || (flag & FL_DUCKING) || !(button & IN_FORWARD) )
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, button & ~IN_ATTACK );
set_pev(id, pev_button, 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 FW_UpdateClientData(id, sendweapons, cd_handle )
{
if ( !is_user_alive(id) || !g_sprint[id] || !(pev(id, pev_button) & IN_FORWARD) )
return FMRES_IGNORED;
set_cd(cd_handle, CD_ID, 0);
return FMRES_HANDLED;
}
While sprinting, I'm trying to make it you have nothing in your hands rather than running around with your knife. But the problem is when I set the view model to nothing. It will stay like that even if you change weapons and such. What I want to do is to remember the weapon you had BEFORE you started sprinting so then I can set the view model back to normal when you stop sprinting.
I also want to try and make a small delay before you can fire when you just release the sprint key.