AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Check if he fired on PrimaryAttack post (https://forums.alliedmods.net/showthread.php?t=144223)

meTaLiCroSS 11-30-2010 18:02

Check if he fired on PrimaryAttack post
 
I'm trying to find the best method of how know if the player fired, catching the event on Ham's PrimaryAttack. It's like the M3: If the player is underwater, PrimaryAttack is called but doesn't fire a bullet bcoz the engine blocks the shotgun's attack when player is underwater.

I thought in this methods, hope someone can tell me another one better than mines:

1) Check if EF_MUZZLEFLASH is on player's pev_effect
2) Use a global bar, and store ammo amount on PrimaryAttack pre. Then in PrimaryAttack post check if current bullets are different from global variable's value.

Thanks in advance.

Arkshine 11-30-2010 20:09

Re: Check if he fired on PrimaryAttack post
 
Quote:

bcoz the engine blocks the shotgun's attack when player is underwater
Because there is simply a check at the start of PrimaryAttack(), which check pev_waterlevel.

Quote:

best method of how know if the player fired
All is depending your need (if you need to hook as pre/pôst). As post, see the tutorial by VEN about catching shot event. The weapon event is call in PrimaryAttack() after the first checks. If you need to hook as pre, you would need to hook PrimaryAttack() and adding check with pev_waterlevel and m_iClip. It should be enough.

Bugsy 11-30-2010 20:10

Re: Check if he fired on PrimaryAttack post
 
Do you only want to use Ham? This method works good http://forums.alliedmods.net/showthread.php?t=54887

meTaLiCroSS 11-30-2010 20:40

Re: Check if he fired on PrimaryAttack post
 
I'm actually doing this:

I hook PrimaryAttack on every weapon (excepting grenades knives and c4) on Pre and Post.

PHP Code:

public fw_Weapon_PrimaryAttack(iWeaponId)
{
    
g_bWeaponFiring true
}

public 
fw_Weapon_PrimaryAttack_Post(iWeaponId)
{
    
g_bWeaponFiring false
    
    
static iPlayer
    iPlayer 
get_pdata_cbase(iWeaponIdm_pPlayer4)
    
    if(
/*HAS BULLETS REMAINING*/)
    {
        
// DECREASE_REMAINING_BULLETS
    
}


g_bWeaponFiring works for catching on TraceAttack the damage caused by bullet. Here I apply the Special bullet effect.

So, the weird thing is that not always when the engine calls PrimaryAttack, a gun is fired. So some special bullets will be lose.

So we're here now. Asking how to know if the gun fired. I think detecting EF_MUZZLEFLASH on player's effect entvar will be a solution.

What do you think?

ConnorMcLeod 12-01-2010 02:00

Re: Check if he fired on PrimaryAttack post
 
Why do you want to do exactly ? which feature i mean.

meTaLiCroSS 12-01-2010 15:08

Re: Check if he fired on PrimaryAttack post
 
Quote:

Originally Posted by ConnorMcLeod (Post 1360628)
Why do you want to do exactly ? which feature i mean.

That doesn't care. Btw, it's an ability called Hard Bullets. You can make knockback on each player.

Oh man who can help me? I no need other things, only need this answer and I'll gtfo of here.

Arkshine 12-01-2010 16:16

Re: Check if he fired on PrimaryAttack post
 
See the 2 first answers... :roll:

meTaLiCroSS 12-01-2010 17:26

Re: Check if he fired on PrimaryAttack post
 
Quote:

Originally Posted by Arkshine (Post 1361058)
See the 2 first answers... :roll:

That will not work for the thing that I'm doing. Read it again...

Exolent[jNr] 12-01-2010 17:28

Re: Check if he fired on PrimaryAttack post
 
Why do you need to use Ham_PrimaryAttack?

meTaLiCroSS 12-01-2010 17:32

Re: Check if he fired on PrimaryAttack post
 
Quote:

Originally Posted by Exolent[jNr] (Post 1361110)
Why do you need to use Ham_PrimaryAttack?

Bcoz I can know when a gun fires After and Before.


All times are GMT -4. The time now is 11:17.

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