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

[help] register_event(???) when shooting ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kinsprite2
Junior Member
Join Date: Mar 2006
Old 03-12-2006 , 21:02   [help] register_event(???) when shooting ?
Reply With Quote #1

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.
kinsprite2 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-13-2006 , 05:05  
Reply With Quote #2

CurWeapon event, but that wouldn't work with knife so you have to get player's buttons and check if he in_attack*.
VEN is offline
kinsprite2
Junior Member
Join Date: Mar 2006
Old 03-14-2006 , 01:56  
Reply With Quote #3

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
kinsprite2 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-14-2006 , 03:01  
Reply With Quote #4

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.
VEN is offline
kinsprite2
Junior Member
Join Date: Mar 2006
Old 03-14-2006 , 09:15  
Reply With Quote #5

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.
kinsprite2 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-14-2006 , 09:38  
Reply With Quote #6

Code:
register_event("CurWeapon", "function", "be", "1=1")
VEN is offline
kinsprite2
Junior Member
Join Date: Mar 2006
Old 03-15-2006 , 05:10  
Reply With Quote #7

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.
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.........
kinsprite2 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-15-2006 , 10:32  
Reply With Quote #8

Quote:
this still include weapon change!
Yes, i wanted to give you a chance to do it yourself.
VEN is offline
kinsprite2
Junior Member
Join Date: Mar 2006
Old 03-15-2006 , 18:26  
Reply With Quote #9

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
kinsprite2 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 12:54.


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