Raised This Month: $ Target: $400
 0% 

Check if he fired on PrimaryAttack post


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 11-30-2010 , 18:02   Check if he fired on PrimaryAttack post
Reply With Quote #1

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.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-30-2010 , 20:09   Re: Check if he fired on PrimaryAttack post
Reply With Quote #2

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.
__________________

Last edited by Arkshine; 11-30-2010 at 20:15.
Arkshine is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-01-2010 , 17:35   Re: Check if he fired on PrimaryAttack post
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
As post, see the tutorial by VEN about catching shot event. The weapon event is call in PrimaryAttack() after the first checks.
That's how you hook after player shoots.

Quote:
Originally Posted by Arkshine View Post
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.
That's how you hook before player shoots.


Why did you not either read that or use that?
They both use Ham_PrimaryAttack.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-30-2010 , 20:10   Re: Check if he fired on PrimaryAttack post
Reply With Quote #4

Do you only want to use Ham? This method works good http://forums.alliedmods.net/showthread.php?t=54887
__________________
Bugsy is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 11-30-2010 , 20:40   Re: Check if he fired on PrimaryAttack post
Reply With Quote #5

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?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-01-2010 , 02:00   Re: Check if he fired on PrimaryAttack post
Reply With Quote #6

Why do you want to do exactly ? which feature i mean.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 12-01-2010 , 15:08   Re: Check if he fired on PrimaryAttack post
Reply With Quote #7

Quote:
Originally Posted by ConnorMcLeod View Post
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.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-01-2010 , 16:16   Re: Check if he fired on PrimaryAttack post
Reply With Quote #8

See the 2 first answers...
__________________
Arkshine is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 12-01-2010 , 17:26   Re: Check if he fired on PrimaryAttack post
Reply With Quote #9

Quote:
Originally Posted by Arkshine View Post
See the 2 first answers...
That will not work for the thing that I'm doing. Read it again...
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-01-2010 , 17:28   Re: Check if he fired on PrimaryAttack post
Reply With Quote #10

Why do you need to use Ham_PrimaryAttack?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply


Thread Tools
Display Modes

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 11:17.


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