AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to hook if player just shooted? (https://forums.alliedmods.net/showthread.php?t=54634)

Voi 04-30-2007 12:47

how to hook if player just shooted?
 
i was using prethink and then in_attack, but its inefficient since i want to hook each bullet not just pressing attack button

so anybody got an idea? i was thinking if i could mb hook weapon sounds thru
FM_EmitSound but i can hook only knife sounds :/

VEN 04-30-2007 17:54

Re: how to hook if player just shooted?
 
PlaybackEvent hook. This method is more accurate than CurWeapon and TraceLine methods.

Make sure that you don't take in account non-gun events like createsmoke, etc.

In plugin_precache() hook PrecacheEvent and cache necessary event indeces. In plugin_init() unhook PrecacheEvent and hook PlaybackEvent.

EDIT:

You can review [HowTo] Properly catch shot event in CS

Voi 06-11-2010 07:24

Re: how to hook if player just shooted?
 
Which method is better ?
PlaybackEvent hook or Ham_Weapon_PrimaryAttack? Which one is called before other and which one would be better to control recoil ?

Arkshine 06-11-2010 07:32

Re: how to hook if player just shooted?
 
The first.

Voi 06-11-2010 08:28

Re: how to hook if player just shooted?
 
Could you explain why ?

Arkshine 06-11-2010 08:36

Re: how to hook if player just shooted?
 
PrimaryAttack is called a lot of times when you hold +attack/2 when the event is called only one time by bullet ; for your need it would be better to use the event.


All times are GMT -4. The time now is 06:42.

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