View Single Post
Cruze
Veteran Member
Join Date: May 2017
Old 08-14-2022 , 04:01   Re: Request - Duck While Planting C4 (CSS)
Reply With Quote #2

You can try this. I don't know much about CSS. Gathered all these up from the internet.
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

bool g_bPlanting[MAXPLAYERS+1] = {false, ...};

public 
void OnPluginStart()
{
    
HookEvent("bomb_beginplant"Event_BeginPlantEventHookMode_Pre);
    
HookEvent("bomb_abortplant"Event_Abort);
    
HookEvent("bomb_planted"Event_Abort);
    
HookEvent("player_death"Event_Abort);
}

public 
void OnClientPutInServer(int client)
{
    
g_bPlanting[client] = false;
    
SDKHook(clientSDKHook_PreThinkPreThink);
}

public 
Action PreThink(int client)
{
    if(!
IsPlayerAlive(client))
    {
        return;
    }
    if(!
g_bPlanting[client])
    {
        return;
    }
    if(
GetEntProp(clientProp_Send"m_bDucking") != 1)
        
SetEntProp(clientProp_Send"m_bDucking"1);
    if(!(
GetEntityFlags(client) & FL_DUCKING))
        
SetEntityFlags(clientGetEntityFlags(client)|FL_DUCKING);
}

public 
Action OnPlayerRunCmd(int iClientint &iButtonsint &iImpulsefloat Velocity[3], float fAngles[3], int &iWeapon)
{
    if(!
IsPlayerAlive(iClient))
    {
        return 
Plugin_Continue;
    }
    if(!
g_bPlanting[iClient])
    {
        return 
Plugin_Continue;
    }
    
iButtons |= IN_DUCK;
    return 
Plugin_Changed;


public 
Action Event_BeginPlant(Event ev, const char[] namebool dbc)
{
    
int client GetClientOfUserId(ev.GetInt("userid"));
    
    
g_bPlanting[client] = true;
}

public 
Action Event_Abort(Event ev, const char[] namebool dbc)
{
    
int client GetClientOfUserId(ev.GetInt("userid"));
    
    
g_bPlanting[client] = false;
    
SetEntProp(clientProp_Send"m_bDucking"0);
    
SetEntityFlags(clientGetEntityFlags(client) & ~FL_DUCKING);

__________________
Taking paid private requests! Contact me
Cruze is offline