AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [CSS] weapon_fire not good for pistols (https://forums.alliedmods.net/showthread.php?t=138332)

Seta00 09-16-2010 21:43

[CSS] weapon_fire not good for pistols
 
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!

KyleS 09-16-2010 22:24

Re: [CSS] weapon_fire not good for pistols
 
The same happens for the weapon_reload event >.<

Seta00 09-17-2010 08:26

Re: [CSS] weapon_fire not good for pistols
 
Use UserCmd or PlayerThink and check for ammo > lastAmmo to detect weapon reload :P

blodia 09-17-2010 18:07

Re: [CSS] weapon_fire not good for pistols
 
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.

Seta00 09-17-2010 18:51

Re: [CSS] weapon_fire not good for pistols
 
Quote:

Originally Posted by blodia (Post 1302051)
you could do that for pistol fire aswell though

It's a lot more effort than bullet_impact ;)

Bacardi 09-27-2010 06:09

Re: [CSS] weapon_fire not good for pistols
 
Sticky: Bug Thread: Non-Beta Issues #77
:3

*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

M1NDFREAK 10-04-2011 14:46

Re: [CSS] weapon_fire not good for pistols
 
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).

Peace-Maker 10-04-2011 18:55

Re: [CSS] weapon_fire not good for pistols
 
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.

Mitchell 12-24-2011 14:30

Re: [CSS] weapon_fire not good for pistols
 
weapon==special weapon, shouldnt that be a StrEqual?

hleV 12-25-2011 06:37

Re: [CSS] weapon_fire not good for pistols
 
Quote:

Originally Posted by Mitchell (Post 1619004)
weapon==special weapon, shouldnt that be a StrEqual?

No, because that's the ID of the weapon, not the name.

Mitchell 12-26-2011 13:10

Re: [CSS] weapon_fire not good for pistols
 
Yeah i was goi9ng to post back but i forgot, i just got the classname of that id and compared it to a string:

Code:

        new weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
        new String:weaponname[32];
        GetEdictClassname(weapon, weaponname, 32);
        if(!StrEqual(weaponname, "weapon_glock"))
        {
//values
        }



All times are GMT -4. The time now is 18:16.

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