Raised This Month: $ Target: $400
 0% 

[HowTo] Properly catch shot event in CS


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-09-2012 , 09:14   Re: [HowTo] Properly catch shot event in CS
Reply With Quote #1

Code can be shortened a bit :

PHP Code:
#include <amxmodx>
#include <fakemeta>

new g_iMaxPlayers;
#define IsPlayer(%0)    ( 1 <= (%0) <= g_iMaxPlayers )

new g_iGunsEventsIdBitSum;

public 
plugin_init()
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);

    new const 
szGunsEvents[][] = {
        
"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"
    
};
    for(new 
ii<sizeof(szGunsEvents); i++)
    {
        
g_iGunsEventsIdBitSum |= 1<<engfunc(EngFunc_PrecacheEvent1szGunsEvents[i]);
    }

    
register_forward(FM_PlaybackEvent"OnPlaybackEvent");

    
g_iMaxPlayers get_maxplayers();
}

public 
OnPlaybackEvent(flagsideventid)
{
    if( 
IsPlayer(id) && g_iGunsEventsIdBitSum & (1<<eventid) )
    {
        
// gun fired

        
return FMRES_HANDLED;
    }
    return 
FMRES_IGNORED;

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-28-2013 at 03:35.
ConnorMcLeod 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 23:15.


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