Raised This Month: $ Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-27-2011 , 12:39   Re: +use Button | 3Sec Boost | 20 Sec Cooldown.
Reply With Quote #1

Some optimizations:
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
    
    
if(g_sprint[id])
    {
        if(~
get_uc(uc_handleUC_Buttons) & IN_USE
        
|| get_gametime() - gStartTime[id] > get_pcvar_float(cvar_speedtime))
        {
            
g_sprint[id] = false
        
}
    }
    else if(
get_uc(uc_handleUC_Buttons) & IN_USE)
    {
        new 
Float:curtime get_gametime()
        
        if(
curtime gStartTime[id] > get_pcvar_float(cvar_cooldown))
        {
            
g_sprint[id] = true
            gStartTime
[id] = curtime
        
}
    }
    
    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
    
    
if ( g_sprint[id] ) //Walking
    
{
        static 
Floatsprinting[3], Floatnormal[3]
        
        
velocity_by_aim(idget_pcvar_num(cvar_speed), sprinting//Speed
        
pev(idpev_velocitynormal)
        
sprinting[2] = normal[2]
        
        
set_pev(idpev_velocitysprinting//Set the speed of sprinting
        
set_pev(idpev_buttonbutton & ~(IN_ATTACK|IN_ATTACK2));   
        
engclient_cmd(id"weapon_knife")
        
//set_pev(id, pev_viewmodel2, "")
    
}
    
    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;

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 06-27-2011 at 13:47.
Exolent[jNr] is offline
Reply



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