Raised This Month: $51 Target: $400
 12% 

Request - Duck While Planting C4 (CSS)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 08-13-2022 , 21:27   Request - Duck While Planting C4 (CSS)
Reply With Quote #1

Guys

can someone make this please?

Description:

While planting the bomb, duck the player, like in csgo.
Ark_Procession is offline
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
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 08-14-2022 , 21:59   Re: Request - Duck While Planting C4 (CSS)
Reply With Quote #3

Quote:
Originally Posted by Cruze View Post
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);

Hey thanks for the help!

unfortunately, doesnt work.

EDIT: To be fair the players tried to duck like million times constantly, quite hilarious. also, have like 4 warnings when compiling.

Last edited by Ark_Procession; 08-14-2022 at 22:02. Reason: forgot ofc
Ark_Procession is offline
`666
AlliedModders Donor
Join Date: Jan 2006
Old 08-15-2022 , 05:44   Re: Request - Duck While Planting C4 (CSS)
Reply With Quote #4

Maybe css has
Quote:
m_iDesiredStance
? In insurgency we use
Quote:
SetEntProp(client, Prop_Send, "m_iDesiredStance", 2);
to make players go prone. I guess 1 will be duck.
`666 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-15-2022 , 09:43   Re: Request - Duck While Planting C4 (CSS)
Reply With Quote #5

hmmmm

https://developer.valvesoftware.com/...playermovement
__________________
Do not Private Message @me
Bacardi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-18-2022 , 03:48   Re: Request - Duck While Planting C4 (CSS)
Reply With Quote #6

For CS:S

There is just small problem. This will print in server console:
Setting CBaseEntity to non-brush model models/props/cs_office/vending_machine.mdl

...when human player start planting. This message can be ignore.


If any bug happens, it would be: player can't run and player stay in crouch.

PHP Code:


#include <sdktools>

#define SF_TRIGGER_MOVE_AUTODISABLE                 0x80
#define SF_TRIGGER_AUTO_DUCK                      0x800

#define SF_TRIGGER_ALLOW_CLIENTS                 0x01        // Players can fire this trigger
#define SF_TRIGGER_ALLOW_NPCS                     0x02        // NPCS can fire this trigger
#define SF_TRIGGER_ALLOW_PUSHABLES                 0x04        // Pushables can fire this trigger
#define SF_TRIGGER_ALLOW_PHYSICS                 0x08        // Physics objects can fire this trigger
#define SF_TRIGGER_ONLY_PLAYER_ALLY_NPCS         0x10        // *if* NPCs can fire this trigger, this flag means only player allies do so
#define SF_TRIGGER_ONLY_CLIENTS_IN_VEHICLES         0x20        // *if* Players can fire this trigger, this flag means only players inside vehicles can 
#define SF_TRIGGER_ALLOW_ALL                     0x40        // Everything can fire this trigger EXCEPT DEBRIS!
#define SF_TRIGGER_ONLY_CLIENTS_OUT_OF_VEHICLES     0x200        // *if* Players can fire this trigger, this flag means only players outside vehicles can 
#define SF_TRIG_PUSH_ONCE                         0x80        // trigger_push removes itself after firing once
#define SF_TRIG_PUSH_AFFECT_PLAYER_ON_LADDER         0x100        // if pushed object is player on a ladder, then this disengages them from the ladder (HL2only)
#define SF_TRIG_TOUCH_DEBRIS                     0x400        // Will touch physics debris objects
#define SF_TRIGGER_ONLY_NPCS_IN_VEHICLES         0x800        // *if* NPCs can fire this trigger, only NPCs in vehicles do so (respects player ally flag too)
#define SF_TRIGGER_DISALLOW_BOTS                 0x1000      // Bots are not allowed to fire this trigger


//#define MODEL_PATH_DEFAULT "models/props/de_train/pallet_barrels.mdl" // cs:s
#define MODEL_PATH_DEFAULT "models/props/cs_office/vending_machine.mdl" // cs:s

enum struct TriggerPlayermovement
{
    
int ent;
    
int modelindex;
    
int userid;
    
bool IsRoundEnd;
}
TriggerPlayermovement trigger_playermovement;

public 
void OnPluginStart()
{
    
trigger_playermovement.ent = -1;
    
trigger_playermovement.IsRoundEnd true// if plugin is loaded manually, wait to next round_start

    
HookEventEx("bomb_beginplant"bomb);
    
HookEventEx("bomb_abortplant"bomb);
    
HookEventEx("bomb_planted"bomb);
    
HookEventEx("bomb_planted"bomb);
    
HookEventEx("round_end"rounds);
    
HookEventEx("round_freeze_end"rounds);
}

public 
void OnConfigsExecuted()
{
    
trigger_playermovement.modelindex PrecacheModel(MODEL_PATH_DEFAULT);
}


public 
void rounds(Event event, const char[] namebool dontBroadcast)
{
    
trigger_playermovement.IsRoundEnd StrEqual(name"round_end"true);

    if(
trigger_playermovement.IsRoundEnd &&
        
trigger_playermovement.ent != -1)
    {
        
AcceptEntityInput(trigger_playermovement.ent"FireUser1");
        
trigger_playermovement.ent = -1;
    }
}

public 
void bomb(Event event, const char[] namebool dontBroadcast)
{
    
trigger_playermovement.userid 0;

    if(!
StrEqual(name"bomb_beginplant"true) || trigger_playermovement.IsRoundEnd)
    {
        if(
trigger_playermovement.ent != -1)
        {
            
AcceptEntityInput(trigger_playermovement.ent"FireUser1");
            
trigger_playermovement.ent = -1;
        }

        return;
    }


    
int userid event.GetInt("userid");
    
int client GetClientOfUserId(userid);


    if(!
client || !IsClientInGame(client) || IsFakeClient(client))
        return;

    
trigger_playermovement.ent CreateEntityByName("trigger_playermovement");
    
    if(
trigger_playermovement.ent == -1)
        return;

    
int enteffects GetEntProp(trigger_playermovement.entProp_Send"m_fEffects");
    
enteffects |= 32;
    
SetEntProp(trigger_playermovement.entProp_Send"m_fEffects"enteffects);


    
int flags SF_TRIGGER_ALLOW_CLIENTS|SF_TRIGGER_MOVE_AUTODISABLE|SF_TRIGGER_AUTO_DUCK;
    
char spawnflags[12];

    
Format(spawnflagssizeof(spawnflags), "%i"flags);

    
DispatchKeyValue(trigger_playermovement.ent"StartDisabled""0");
    
DispatchKeyValue(trigger_playermovement.ent"spawnflags"spawnflags);

    
DispatchKeyValue(trigger_playermovement.ent"OnUser1""!self,DisableAndEndTouch,,0.1,-1");
    
DispatchKeyValue(trigger_playermovement.ent"OnUser1""!self,Kill,,1.0,-1");

    
DispatchSpawn(trigger_playermovement.ent);
    
ActivateEntity(trigger_playermovement.ent);

    if(
trigger_playermovement.modelindex)
        
SetEntityModel(trigger_playermovement.entMODEL_PATH_DEFAULT);

    
float m_vecMins[] = {-20.0, -20.00.0};
    
float m_vecMaxs[] = {20.020.072.0};

    
SetEntPropVector(trigger_playermovement.entProp_Data"m_vecMins"m_vecMins);
    
SetEntPropVector(trigger_playermovement.entProp_Data"m_vecMaxs"m_vecMaxs);
    
SetEntProp(trigger_playermovement.entProp_Data"m_nSolidType"2);

    
trigger_playermovement.ent EntIndexToEntRef(trigger_playermovement.ent);

    
trigger_playermovement.userid userid;
    
CreateTimer(0.6delaytrigger_playermovement.entTIMER_FLAG_NO_MAPCHANGE);
}

public 
Action delay(Handle timerany EntRef)
{
    if(
EntRef != trigger_playermovement.ent)
        return 
Plugin_Continue;

    
int client GetClientOfUserId(trigger_playermovement.userid);
    
    if(!
client || !IsClientInGame(client) || !IsPlayerAlive(client) || trigger_playermovement.IsRoundEnd)
    {
        
AcceptEntityInput(trigger_playermovement.ent"FireUser1");
        
trigger_playermovement.ent = -1;
        
trigger_playermovement.userid 0;

        return 
Plugin_Continue;
    }

    
float pos[3];
    
GetClientAbsOrigin(clientpos);
    
TeleportEntity(trigger_playermovement.entpos);

    return 
Plugin_Continue;


*updated, added round_end check
__________________
Do not Private Message @me

Last edited by Bacardi; 08-18-2022 at 20:09. Reason: update
Bacardi is offline
L4D2Noob
AlliedModders Donor
Join Date: Mar 2020
Location: Moscow
Old 08-18-2022 , 18:53   Re: Request - Duck While Planting C4 (CSS)
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
If any bug happens, it would be: player can't run and player stay in crouch.
If a player starts planting a bomb at the end of a round, and does not have time to plant it before the next round, then the player will move very slowly in the next round.

Video
__________________
L4D2Noob is offline
Send a message via ICQ to L4D2Noob Send a message via Skype™ to L4D2Noob
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-18-2022 , 19:49   Re: Request - Duck While Planting C4 (CSS)
Reply With Quote #8

Quote:
Originally Posted by L4D2Noob View Post
If a player starts planting a bomb at the end of a round, and does not have time to plant it before the next round, then the player will move very slowly in the next round.

Video
ok, thanks for info. I look that later

*plugin code updated, I added round end check
__________________
Do not Private Message @me

Last edited by Bacardi; 08-18-2022 at 20:09.
Bacardi 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:37.


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