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

A Question About Modules


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 08-21-2011 , 04:13   A Question About Modules
Reply With Quote #1

Hello everybody, I have a question...
What should I do to hook the game events in modules?
Examples: DeathMsg, ResetHUD, CurWeapon, Damage, HLTV, etc: ...

But, also, I need some natives to get the event's data!

CurWeapon = The player who's switching his weapons, the weapon index, if the weapon is active, the clip... How to get that variables...?

All the best,
Hattrick
__________________
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-21-2011 , 05:14   Re: A question about modules!
Reply With Quote #2

You have to hook pfnMessageBegin + filter message. Look at the event system in amxx.
__________________
Arkshine is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 08-21-2011 , 05:30   Re: A question about modules!
Reply With Quote #3

coding module is powerful enough to let u not use event system like amxx anymore.
I use a method that redirect the message_end() call from where I need to hook that message. Here is a DeathMsg example
Code:
void CSDM_PostDeath(const char *weapon, int headshot, int victim, edict_t *pv, int killer, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed)
{
	MESSAGE_END();
I wrote a tut about that tech, you can find it.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-21-2011 , 05:53   Re: A question about modules!
Reply With Quote #4

You mean you make a memory patch on MESSAGE_END() called in the function where you want to hook ?
__________________
Arkshine is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 08-21-2011 , 06:09   Re: A question about modules!
Reply With Quote #5

Yes but the CSX module... you know... it contain some messages like DeathMsg and CurWeapon...

With the AMXX module you also can register events
__________________
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 08-21-2011 , 07:27   Re: A question about modules!
Reply With Quote #6

Thanks a lot guys, both, I have solved the problem!

PHP Code:
int g_int_curweapon_index;
int g_int_deathmsg_index;

bool g_bool_curweapon;
bool g_bool_deathmsg;

int g_int_variable;
int g_int_status;

edict_t *g_edict_player;

void MessageBegin_Postint int_destinationint int_type, const float *float_originedict_t *edict_entity )
{
    
// Check for the messages indexes
    
if( int_type == g_int_curweapon_index )
    {
        
// If there's CurWeapon and the player has not a jetpack do nothing
        
if( !g_bool_jetpackEngFunc_IndexOfEdictedict_entity ) ] )
            
RETURN_METAMRES_IGNORED );

        
g_bool_curweapon true;

        
g_edict_player edict_entity;

        
g_int_variable 0;
    }

    else if( 
int_type == g_int_deathmsg_index )
    {
        
g_bool_deathmsg true;

        
g_int_variable 0;
    }

    
RETURN_METAMRES_IGNORED );
}

void MessageEnd_Postvoid )
{
    
// End the messages
    
if( g_bool_curweapon )
        
g_bool_curweapon false;

    else if( 
g_bool_deathmsg )
        
g_bool_deathmsg false;

    
RETURN_METAMRES_IGNORED );
}

void WriteByte_Postint iValue )
{
    if( 
g_bool_curweapon )
    {
        
g_int_variable++;

        if( 
g_int_variable == )
            
g_int_status iValue;

        if( 
g_int_variable == )
        {
            if( !
g_int_status )
                
RETURN_METAMRES_IGNORED );

            
int int_player EngFunc_IndexOfEdictg_edict_player );

            
g_int_current_weaponint_player ] = iValue;

            if( 
g_int_current_weaponint_player ] == CSW_KNIFE )
            {
                
g_edict_player -> v.viewmodel EngFunc_AllocString"models/v_egon.mdl" );
                
g_edict_player -> v.weaponmodel EngFunc_AllocString"models/p_egon.mdl" );
            }
        }
    }

    else if( 
g_bool_deathmsg )
    {
        
g_int_variable++;

        if( 
g_int_variable == )
            if( 
g_bool_jetpackiValue ] )
                
Func_Drop_JetpackiValue );
    }

    
RETURN_METAMRES_IGNORED );
}

int RegUserMsg_Post( const char *char_nameint int_size )
{
    
// Get the messages indexes and remember them
    
if( strcmpchar_name"CurWeapon" ) == )
        
g_int_curweapon_index META_RESULT_ORIG_RET( int );

    else if( 
strcmpchar_name"DeathMsg" ) == )
        
g_int_deathmsg_index META_RESULT_ORIG_RET( int );

    
RETURN_META_VALUEMRES_IGNORED);

__________________

Last edited by claudiuhks; 08-21-2011 at 16:32.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
jim_yang
Veteran Member
Join Date: Aug 2006
Old 08-21-2011 , 07:38   Re: A question about modules!
Reply With Quote #7

Quote:
Originally Posted by Arkshine View Post
You mean you make a memory patch on MESSAGE_END() called in the function where you want to hook ?
yes, although message_end() itself has no parameters, it happen to have esp pointer not clear, so I can list all parameters the whole DeathMsg used before.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-21-2011 , 07:58   Re: A question about modules!
Reply With Quote #8

Ok, I see, thanks.

@claudiuhks: If you can, you should really take a look at Jim's method, far more efficient.
__________________
Arkshine is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 08-21-2011 , 13:42   Re: A question about modules!
Reply With Quote #9

I don't understand how to use the GETREALADRDESS macro or where can I found it or how to get the offset for the DeathMsg message and to hook it...
__________________
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Destro-
Veteran Member
Join Date: Jun 2010
Location: $me->location();
Old 08-22-2011 , 14:56   Re: A question about modules!
Reply With Quote #10

Hello.
This is valid?.

PHP Code:
#include <amxmodx>

native new_native(players[32])

public 
plugin_init() {
    new 
players[32], count
    get_players
(playerscount"ch")

    
new_native(players)

PHP Code:
static cell AMX_NATIVE_CALL new_native(AMX *amxcell *params)
{
    
cell *players MF_GetAmxAddr(amxparams[1]);

           
// This is valid?.

@EDIT
Tested, seems to work well.
__________________

Last edited by Destro-; 08-22-2011 at 16:30.
Destro- 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:13.


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