AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [help] register_event(???) when shooting ? (https://forums.alliedmods.net/showthread.php?t=25381)

kinsprite2 03-12-2006 21:02

[help] register_event(???) when shooting ?
 
I want to call a fuction when a player is shooting or using his knife,but I do not know which event can be registered? if you know, please tell me.Thanks a lot.
:arrow: :arrow: :arrow:

VEN 03-13-2006 05:05

CurWeapon event, but that wouldn't work with knife so you have to get player's buttons and check if he in_attack*.

kinsprite2 03-14-2006 01:56

Quote:

Originally Posted by VEN
CurWeapon event, but that wouldn't work with knife so you have to get player's buttons and check if he in_attack*.

CurWeapon event ,the fuction will be called when you change weapon. if not shooting, it still be called! so, I use Damage event to find who is attaking

VEN 03-14-2006 03:01

You said
Quote:

I want to call a fuction when a player is shooting
That's why i said CurWeapon and not Damage.
Yes, i know about weapon change, but you can filter that event out with a few variables.

kinsprite2 03-14-2006 09:15

Quote:

Originally Posted by VEN
but you can filter that event out with a few variables.

register_event ( const event[], const function[], const flags[], [ cond=[], ... ] )
flags is a combination of flags that determine if this event is forwarded:
"a" - Global Event
"b" - Event sent to a single target
"c" - Send only once when repeated to other players
"d" - Only if sent to a dead player
"e" - Only if sent to an alive player

Name: CurWeapon
Structure:
byte isActive
byte WeaponID
byte Ammo in weapon

register_event (CurWeapon,"function","Flags","???")
Flags must contain "e",any others? And the last "???", i don't know either.
Thank you for your help.

VEN 03-14-2006 09:38

Code:
register_event("CurWeapon", "function", "be", "1=1")

kinsprite2 03-15-2006 05:10

Quote:

Originally Posted by VEN
Code:
register_event("CurWeapon", "function", "be", "1=1")

this still include weapon change!
I added this code to the function to judge whether a player is shooting.:D
Code:
if(weapon==CSW_KNIFE){         last_weapon[id]=CSW_KNIFE         max_ammo[id]=0         return PLUGIN_CONTINUE     } if(weapon!=last_weapon[id]){         last_weapon[id]=weapon         max_ammo[id]=clip         return PLUGIN_CONTINUE     }     if(max_ammo[id]<=clip){         max_ammo[id]=clip         return PLUGIN_CONTINUE     } else max_ammo[id]=clip .............. ..............
it works now.woohoo.........

VEN 03-15-2006 10:32

Quote:

this still include weapon change!
Yes, i wanted to give you a chance to do it yourself.

kinsprite2 03-15-2006 18:26

Quote:

Originally Posted by VEN
Quote:

this still include weapon change!
Yes, i wanted to give you a chance to do it yourself.

thank you very much


All times are GMT -4. The time now is 20:19.

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