AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [HowTo] Properly catch shot event in CS (https://forums.alliedmods.net/showthread.php?t=54887)

VEN 05-06-2007 15:23

[HowTo] Properly catch shot event in CS
 
1 Attachment(s)
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 }

Alka 05-06-2007 15:38

Re: [HowTo] Properly catch shot event in CS
 
Nice tut o0....Gj! :wink:

Arkshine 05-06-2007 16:02

Re: [HowTo] Properly catch shot event in CS
 
Interesting. :)

Zenith77 05-06-2007 21:19

Re: [HowTo] Properly catch shot event in CS
 
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.

VEN 05-07-2007 03:30

Re: [HowTo] Properly catch shot event in CS
 
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.


Zenith77 05-07-2007 16:33

Re: [HowTo] Properly catch shot event in CS
 
Thanks for that clarification ;).

Simon Logic 06-01-2007 10:15

Re: [HowTo] Properly catch shot event in CS
 
what about
Code:
if(g_fwid) unregister_forward(FM_PrecacheEvent, g_fwid, 1)
?

Voi 08-18-2007 12:34

Re: [HowTo] Properly catch shot event in CS
 
how about processor consumption, its more resource eating than curweapon event ?

XxAvalanchexX 08-18-2007 15:30

Re: [HowTo] Properly catch shot event in CS
 
Are the events played back before or after the shot is actually fired?

VEN 08-19-2007 07:28

Re: [HowTo] Properly catch shot event in CS
 
After.


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

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