Raised This Month: $ Target: $400
 0% 

+use Button | 3Sec Boost | 20 Sec Cooldown.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
FoxueR
Senior Member
Join Date: Jun 2011
Old 06-27-2011 , 11:03   Re: +use Button | 3Sec Boost | 20 Sec Cooldown.
Reply With Quote #4

Try this:

PHP Code:
#include <amxmodx>
#include <fakemeta>

new boolg_sprint[33]
new 
cvar_speed
new cvar_cooldown
new cvar_speedtime

new Float:gStartTime[33]

public 
plugin_init()
{
    
register_plugin("Sprint""0.1""Mini_Midget");
    
cvar_speed register_cvar("sprint_speed""400");
    
cvar_cooldown register_cvar("sprint_cooldown""20");
    
cvar_speedtime register_cvar("sprint_speedtime""3");
    
register_forwardFM_CmdStart"FMCmdStart" );
    
register_forwardFM_PlayerPreThink"FMPreThink" );
    
register_forward(FM_UpdateClientData"FMUpdateClientData"1)
    
}

public 
client_putinserver(id)
{
    
g_sprint[id] = false
}

public 
FMCmdStartiduc_handlerandseed )
{
    if (!
is_user_alive(id))
        return 
FMRES_IGNORED

    
new Float:curtime get_gametime()
        
    if ( 
curtime gStartTime[id] > get_pcvar_floatcvar_cooldown ) ) 
    {
        if(
get_uc(uc_handleUC_Buttons) & IN_USE)
        { 
            
g_sprint[id] = true
            gStartTime
[id] = curtime
        
}
        else
        {
            
g_sprint[id] = false
        
}
    }
    
    return 
FMRES_IGNORED
}

public 
FMPreThink(id)
{
    if (!
is_user_alive(id))
        return 
FMRES_IGNORED
    
    
static flag flag pev(idpev_flags)
    static 
button button pev(idpev_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 Floatsprinting[3], Floatnormal[3]
    static 
speed speed get_pcvar_num(cvar_speed)
    
    
velocity_by_aim(idspeedsprinting//Speed
    
pev(idpev_velocitynormal)
    
sprinting[2] = normal[2]
    
    if ( 
g_sprint[id] == true && get_gametime() - gStartTime[id] < get_pcvar_floatcvar_speedtime ) ) //Walking
    
{
        
set_pev(idpev_velocitysprinting//Set the speed of sprinting
        
set_pev(idpev_buttonpev(id,pev_button) & ~IN_ATTACK);
        
set_pev(idpev_buttonpev(id,pev_button) & ~IN_ATTACK2 );    
        
engclient_cmd(id"weapon_knife")
        
//set_pev(id, pev_viewmodel2, "")
    
}
    else if (
g_sprint[id] == false//Running
    
{
        
set_pev(idpev_velocitynormal)  //Return to normal speed
    
}
    
    return 
FMRES_IGNORED
}

public 
FMUpdateClientData(idsendweaponscd_handle )
{
    if ( !
is_user_alive(id) || !g_sprint[id])
        return 
FMRES_IGNORED;

    
set_cd(cd_handleCD_ID0);        
        
    return 
FMRES_HANDLED;

__________________
¯\_(ツ)_/¯
FoxueR is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode