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

[CSS] weapon_fire not good for pistols


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 09-16-2010 , 21:43   [CSS] weapon_fire not good for pistols
Reply With Quote #1

If you're going to hook weapon_fire for pistols, DON'T DO IT!
The event gets called billions of times if the client holds his +attack button.
Hook bullet_impact instead.

Here an example from one of my plugins:
Code:
public Action:EventBulletImpact(Handle:event, const String:name[], bool:dontBroadcast) {     new client = GetClientOfUserId(GetEventInt(event, "userid"))         ,weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");         if (weapon == specialWeapon) {                MyFunction(client); // MyFunction needs to be called ONCE for each weapon fire, so bullet_impact is the right way to do it.     }         return Plugin_Continue; }

BULLET_IMPACT IS CREDIT TO PLUGIN!
Seta00 is offline
KyleS
SourceMod Plugin Approver
Join Date: Jul 2009
Location: Segmentation Fault.
Old 09-16-2010 , 22:24   Re: [CSS] weapon_fire not good for pistols
Reply With Quote #2

The same happens for the weapon_reload event >.<
KyleS is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 09-17-2010 , 08:26   Re: [CSS] weapon_fire not good for pistols
Reply With Quote #3

Use UserCmd or PlayerThink and check for ammo > lastAmmo to detect weapon reload
Seta00 is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 09-17-2010 , 18:07   Re: [CSS] weapon_fire not good for pistols
Reply With Quote #4

you could do that for pistol fire aswell though.

in my weaponmod i have some code to test if the pistol actually fired. although i don't use weapon_fire as it doesn't detect knife stab i used client postthink which fires just before weapon_fire and manually check if the clients weapon fired.

PHP Code:
if (GetGameTime() < GetEntPropFloat(WeaponIndexProp_Send"m_flNextPrimaryAttack"))
{
    
// didn't fire
    
return;

i don't know if that will work in weapon_fire but you could try it.
blodia is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 09-17-2010 , 18:51   Re: [CSS] weapon_fire not good for pistols
Reply With Quote #5

Quote:
Originally Posted by blodia View Post
you could do that for pistol fire aswell though
It's a lot more effort than bullet_impact ;)
Seta00 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-27-2010 , 06:09   Re: [CSS] weapon_fire not good for pistols
Reply With Quote #6

Sticky: Bug Thread: Non-Beta Issues #77


*edit
one more thing about bullet impact, bullets penetrate player or wall corners or through box will give multiple event.. Like fire one time you mayeb get lucky 4 bullet impact event fired.
bad english

Last edited by Bacardi; 09-27-2010 at 06:14.
Bacardi is offline
M1NDFREAK
Junior Member
Join Date: Nov 2010
Old 10-04-2011 , 14:46   Re: [CSS] weapon_fire not good for pistols
Reply With Quote #7

Fixed by Valve (15.09.2011)

Pistols no longer continuously spam weapon_fire event when the +attack key is pressed. This has the side effect of no longer allowing the glock to continuously auto-fire in burst mode).
M1NDFREAK is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 10-04-2011 , 18:55   Re: [CSS] weapon_fire not good for pistols
Reply With Quote #8

Keep in mind, that bullet_impact is called everytime a bullet hits a surface. So if you shoot through a door or similar it'll fire twice with different x, y and z coordinates. Once at the door and at the wall behind it.
__________________
Peace-Maker is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 12-24-2011 , 14:30   Re: [CSS] weapon_fire not good for pistols
Reply With Quote #9

weapon==special weapon, shouldnt that be a StrEqual?
Mitchell is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 12-25-2011 , 06:37   Re: [CSS] weapon_fire not good for pistols
Reply With Quote #10

Quote:
Originally Posted by Mitchell View Post
weapon==special weapon, shouldnt that be a StrEqual?
No, because that's the ID of the weapon, not the name.
__________________
hleV 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 22:22.


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