hi can someone help me make a bind for this, that allows the player to bind a key to "+dd" and make the same function as this does when you press duck?
PHP Code:
#include <sourcemod>
#include <sdktools>
#define DOUBLEDUCK_HEIGHT 40.0
public Action OnPlayerRunCmd( int client, int &buttons )
{
if ( !IsPlayerAlive( client ) ) return Plugin_Continue;
static int fFlags;
fFlags = GetEntityFlags( client );
if ( fFlags & FL_ONGROUND )
{
if ( GetEntProp( client, Prop_Data, "m_bDucking" ))
{
float vecPos[3];
GetClientAbsOrigin( client, vecPos );
vecPos[2] += DOUBLEDUCK_HEIGHT;
if ( IsValidPlayerPos( client, vecPos ) )
{
TeleportEntity( client, vecPos, NULL_VECTOR, NULL_VECTOR );
}
}
}
return Plugin_Continue;
}
public bool IsValidPlayerPos( int client, float vecPos[3] )
{
static const float vecMins[] = { -20.0, -20.0, 0.0 };
static const float vecMaxs[] = { 20.0, 20.0, 72.0 };
TR_TraceHullFilter( vecPos, vecPos, vecMins, vecMaxs, MASK_SOLID, TraceFilter_IgnorePlayer, client );
return ( !TR_DidHit( null ) );
}
public bool TraceFilter_IgnorePlayer( int ent, int mask, any ignore_me )
{
return ( ent != ignore_me );
}