Again, thank you for your replies.
I have been testing your suggestions the last few days...
Quote:
Originally Posted by MasterMind420
I think the most accurate method may be checking the animation sequence using m_nsequence entprop
|
I guess you mean checking it each GameFrame. That would theoretically work, but the interval between GameFrames is too long --> too inaccurate
Quote:
Originally Posted by Neuro Toxin
Use SDKHook_OnTakeDamage and add this to your part after you check if the weapon is a knife:
Code:
if (damagetype & DMG_SLASH)
{}
|
I need it to work every time an attack is performed, whether someone was hurt by it or not.
Quote:
Originally Posted by Lux
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.
Its in old syntax sorry i prefer it.
PHP Code:
public OnPluginStart() { AddNormalSoundHook(SoundHook); }
public Action:SoundHook(iClients[64], &iNumClients, String: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
|
To me it doesn't really matter which knife attack is performed because i need it to work for primary and secondary, but since primary attack fires the "weapon_fire" event, it is only the secondary attack that is causing problems.
I tried that method and until now it is by far the best one, but when i compared it to "weapon_fire" event it has a small but significant delay:
CODE:
PHP Code:
public Action:NormalSoundHook(clients[64], &numClients, String:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags)
{
decl String:sKnife[32];
sKnife = "weapons/knife/knife_";
decl String:sDeploy[32];
sDeploy = "weapons/knife/knife_deploy1.wav";
if(StrContains(sample, sKnife, false) == 0 && !StrEqual(sample, sDeploy, false))
{
PrintToChatAll("[SoundHook] Knife-Attack | Time %f", GetEngineTime());
}
return Plugin_Continue;
}
public EventWeaponFire(Handle:event,const String:name[],bool:dontBroadcast)
{
static String:Weapon[32];
GetEventString(event, "weapon", Weapon, sizeof(Weapon));
if(StrEqual(Weapon, "knife"))
{
PrintToChatAll("[WeaponFire] Knife-Attack | Time %f", GetEngineTime());
}
}
Tested with primary attack (3 times) since it also triggers "weapon_fire" event!
OUTPUT:
PHP Code:
[WeaponFire] Knife-Attack | Time 125.506652
[SoundHook] Knife-Attack | Time 125.506698
[WeaponFire] Knife-Attack | Time 125.911811
[SoundHook] Knife-Attack | Time 125.911842
[WeaponFire] Knife-Attack | Time 126.331619
[SoundHook] Knife-Attack | Time 126.331657
It needs to have the same accuracy as "weapon_fire" otherwise it won't work for me.
__________________