Raised This Month: $ Target: $400
 0% 

Event Hooking


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Twelve-60
Senior Member
Join Date: Aug 2007
Old 08-20-2009 , 01:55   Event Hooking
Reply With Quote #1

Is it possible to hook events such as player_blind (flashed) and player_abort_defuse?

So far I've just been using register_logevent, but these obviously don't get logged, and it doesn't appear in the event listing here http://wiki.amxmodx.org/Half-Life_1_Game_Events

Thanks

- Twelve-60
__________________
Twelve-60 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-20-2009 , 02:12   Re: Event Hooking
Reply With Quote #2

For defuse/bomb scripting:
http://forums.alliedmods.net/showthread.php?t=40164

For flash blind:
Code:
#include < amxmodx > public plugin_init( ) {     register_message( get_user_msgid( "ScreenFade" ), "MessageScreenFade" ); } public MessageScreenFade( iMsgId, iDest, iReceiver ) {     if( get_msg_arg_int( 4 ) == 255     && get_msg_arg_int( 5 ) == 255     && get_msg_arg_int( 6 ) == 255 )     {         new iAlpha = get_msg_arg_int( 7 );         if( iAlpha == 200 || iAlpha == 255 )         {             // iReceiver was flashed         }     } }
OR
Code:
#include < amxmodx > public plugin_init( ) {     register_event( "ScreenFade", "EventFlashbang", "b", "4=255", "5=255", "6=255", "7=200", "7=255" ); } public EventFlashbang( client ) {     // client was flashed }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Twelve-60
Senior Member
Join Date: Aug 2007
Old 08-20-2009 , 02:33   Re: Event Hooking
Reply With Quote #3

Great, awesome

I also forgot one, grenade_detonate (i.e. when a grenade detonates (flash/smoke/he), and detect who threw it?

Thanks again!

- Twelve-60
__________________
Twelve-60 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-20-2009 , 02:44   Re: Event Hooking
Reply With Quote #4

Code:
#include < amxmodx > #include < engine > public plugin_init( ) {     register_think( "grenade", "FwdGrenadeThink" ); } public FwdGrenadeThink( iEntity ) {     if( is_valid_ent( iEntity ) )     {         static Float:fExplodeTime;         fExplodeTime = entity_get_float( iEntity, EV_FL_dmgtime );                 if( fExplodeTime <= get_gametime( ) )         {             // iEntity is exploding                         new iOwner = entity_get_edict( iEntity, EV_ENT_owner );             // iOwner = the person who threw it         }     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 08-20-2009 at 02:46.
Exolent[jNr] is offline
Twelve-60
Senior Member
Join Date: Aug 2007
Old 08-20-2009 , 02:57   Re: Event Hooking
Reply With Quote #5

Hmm, what exactly is going on there? e.g. how many times is FwdGrenadeThink being called?

Trying to be faily efficient

Thanks

- Twelve-60
__________________
Twelve-60 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-20-2009 , 03:03   Re: Event Hooking
Reply With Quote #6

The grenade's think after it has been throw is like a player's PreThink.
Therefore, we have to filter out its explode time so we can get the explosion.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Twelve-60
Senior Member
Join Date: Aug 2007
Old 08-20-2009 , 03:09   Re: Event Hooking
Reply With Quote #7

Ah okay.

So how would I hook the throwing event itself? (i.e. before detonating), and how do I know what type of grenade it is?

Thanks

- Twelve-60
__________________
Twelve-60 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-20-2009 , 03:58   Re: Event Hooking
Reply With Quote #8

Code:
#include < amxmodx > #include < fakemeta > new const g_iNadeConstants[ 3 ] = {     CSW_HEGRENADE,     CSW_FLASHBANG,     CSW_SMOKEGRENADE }; new const g_szNadeModels[ 3 ][ ] = {     "models/w_hegrenade.mdl",     "models/w_flashbang.mdl",     "models/w_smokegrenade.mdl"; }; new Trie:g_tNadeModels; public plugin_init( ) {     g_tNadeModels = TrieCreate( );         for( new i = 0; i < 3; i++ )     {         TrieSetCell( g_tNadeModels, g_szNadeModels[ i ], i );     }         register_forward( FM_SetModel, "FwdSetModel", 1 ); } public plugin_end( ) {     TrieDestroy( g_tNadeModels ); } public FwdSetModel( iEntity, const szModel[ ] ) {     if( pev_vaild( iEntity ) )     {         new iOwner = pev( iEntity, pev_owner );                 if( is_user_connected( iOwner ) )         {             static Float:fExplodeTime;             pev( iEntity, pev_dmgtime, fExplodeTime );                         if( fExplodeTime > 0.0 )             {                 static iIndex;                 if( TrieGetCell( g_tNadeModels, szModel, iIndex ) )                 {                     new CSW_nadetype = g_iNadeConstants[ iIndex ];                                         // iEntity = the grenade entity                     // CSW_nadetype = the CSW_* constant for the nade type                     // iOwner = the thrower                 }             }         }     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Twelve-60
Senior Member
Join Date: Aug 2007
Old 08-20-2009 , 06:52   Re: Event Hooking
Reply With Quote #9

Awesome thanks
- Twelve-60
__________________
Twelve-60 is offline
Twelve-60
Senior Member
Join Date: Aug 2007
Old 08-20-2009 , 07:01   Re: Event Hooking
Reply With Quote #10

hmmm I seem to having trouble with the bomb planted event, I posted it in that thread:

http://forums.alliedmods.net/showpos...2&postcount=46

I don't see how I can find out who is planting Without maybe tracking it through bomb_drop/pickup/spawn events

- Twelve-60
__________________
Twelve-60 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 15:14.


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