Raised This Month: $32 Target: $400
 8% 

[HowTo] Properly catch shot event in CS


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
VEN
Veteran Member
Join Date: Jan 2005
Old 05-06-2007 , 15:23   [HowTo] Properly catch shot event in CS
Reply With Quote #1

Since CurWeapon/TraceLine methods may produce false positives i'd recommend to use the below method. Didn't added comments but variables/function names are descriptive enough. If you still don't undestand something ask me.

Code:
/* AMX Mod X *   gun_fire_playback_event_way.sma * * (c) Copyright 2007 by VEN * * This file is provided as is (no warranties) */ // plugin's main information #define PLUGIN_NAME "gun_fire_playback_event_way" #define PLUGIN_VERSION "0.1" #define PLUGIN_AUTHOR "VEN" #include <amxmodx> #include <fakemeta> #define MAX_CLIENTS 32 new g_fwid new g_max_clients new const g_guns_events[][] = {         "events/awp.sc",         "events/g3sg1.sc",         "events/ak47.sc",         "events/scout.sc",         "events/m249.sc",         "events/m4a1.sc",         "events/sg552.sc",         "events/aug.sc",         "events/sg550.sc",         "events/m3.sc",         "events/xm1014.sc",         "events/usp.sc",         "events/mac10.sc",         "events/ump45.sc",         "events/fiveseven.sc",         "events/p90.sc",         "events/deagle.sc",         "events/p228.sc",         "events/glock18.sc",         "events/mp5n.sc",         "events/tmp.sc",         "events/elite_left.sc",         "events/elite_right.sc",         "events/galil.sc",         "events/famas.sc" } new g_guns_eventids_bitsum public plugin_precache() {         g_fwid = register_forward(FM_PrecacheEvent, "fwPrecacheEvent", 1) } public fwPrecacheEvent(type, const name[]) {         for (new i = 0; i < sizeof g_guns_events; ++i) {                 if (equal(g_guns_events[i], name)) {                         g_guns_eventids_bitsum |= (1<<get_orig_retval())                         return FMRES_HANDLED                 }         }         return FMRES_IGNORED } public plugin_init() {         register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)         unregister_forward(FM_PrecacheEvent, g_fwid, 1)         register_forward(FM_PlaybackEvent, "fwPlaybackEvent")         g_max_clients = global_get(glb_maxClients) } public fwPlaybackEvent(flags, invoker, eventid) {         if (!(g_guns_eventids_bitsum & (1<<eventid)) || !(1 <= invoker <= g_max_clients))                 return FMRES_IGNORED         // gun fired         return FMRES_HANDLED }
Attached Files
File Type: sma Get Plugin or Get Source (gun_fire_playback_event_way.sma - 2298 views - 1.7 KB)
VEN is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 05-06-2007 , 15:38   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #2

Nice tut o0....Gj!
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 05-07-2007 at 02:26.
Alka is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-06-2007 , 16:02   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #3

Interesting.
__________________
Arkshine is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 05-06-2007 , 21:19   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #4

Code:
(1 <= invoker <= g_max_clients)

Ok, I remember talking about this a long time ago. Is this valid, are you able to do this? Because I had previously thought that it would read from left to right (like it normally does) and actually check the return from the pervious check.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-07-2007 , 03:30   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #5

Yes, it's valid.

Quote:
Originally Posted by Pawn Guide (p. 107) about <,>,<=,>= operators
...operators may be "chained", as in the expression "e1 <= e2 <= e3", with the semantics that the result is "1" if all individual comparisons hold and "0" otherwise.
VEN is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 05-07-2007 , 16:33   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #6

Thanks for that clarification ;).
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Simon Logic
Senior Member
Join Date: Nov 2006
Location: RF
Old 06-01-2007 , 10:15   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #7

what about
Code:
if(g_fwid) unregister_forward(FM_PrecacheEvent, g_fwid, 1)
?
__________________
my modest stuff: AXN 1.6.1 | plugins | bsp2csdm
Simon Logic is offline
Send a message via Skype™ to Simon Logic
Voi
Veteran Member
Join Date: Sep 2006
Location: Gdansk, Poland
Old 08-18-2007 , 12:34   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #8

how about processor consumption, its more resource eating than curweapon event ?
__________________
Voi is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-18-2007 , 15:30   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #9

Are the events played back before or after the shot is actually fired?
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 08-19-2007 , 07:28   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #10

After.
VEN is offline
Reply


Thread Tools
Display Modes

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 03:00.


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