View Single Post
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 05-11-2018 , 23:47   Re: [CS:S] Hooking Secondary Knife Attack
Reply With Quote #9

Quote:
Originally Posted by hmmmmm View Post
PHP Code:
public Action OnPlayerRunCmd(int clientintbuttons)
{
    
int pressedButtons GetEntProp(clientProp_Data"m_afButtonPressed");
    if(
pressedButtons IN_ATTACK2)
    { 
        
//Code 
    
}

    return 
Plugin_Continue;

This would tell you when +attack2 was initially pressed. The prop exists in CS:GO, you'll have to check if it exists in CS:S. If not you can always just keep track of last buttons to find out when the button is pressed.

EDIT: After thinking about it this might not be the most accurate method since clicking the button might not always correspond to the secondary attack happening, might need a different method.

This might be a longshot but.

Is the button press in the same gameframe of the sound being emitted?

if so we can use the button press to determine which attack is being performed?
example in my own way

[Framestart]
OnPlayerRunCmd
Source Processing buttons
Starts attack
SoundHook checks
SoundEmitted

[frameend]

it maywork.

Quote:
Originally Posted by Komodo3000 View Post
@Lux

You mean hooking the swing sound of knife attack? That actually would be possible but i never used this method. Where do i get the path of the swing sound?

Its in old syntax sorry i prefer it.
PHP Code:
public OnPluginStart()
{
    
AddNormalSoundHook(SoundHook);
}

public 
Action:SoundHook(iClients[64], &iNumClientsString:sSampleFile[PLATFORM_MAX_PATH], &iEntity, &iChannel, &Float:fVolume, &fLevel, &iPitch, &iFlags)
{
    
//checks for sounds
    //Note besure to optimize heavily this will forward all sounds that are emitted!
    //like storing ent refs of already checked entitys that are not knife or client
    

I'm not a css coder so its just a shot in the dark of how i would go about doing it in l4d2 hope this helps
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline