How to hook amxx module functions with orpheu?
I want to change handle of nick change in csx module.
For example, if players change nick and this doesn't exists, its not create new entry, but changes nick for current rank.
CSX Nick change handle
Code:
void ClientUserInfoChanged_Post( edict_t * pEntity, char * infobuffer ) {
CPlayer * pPlayer = GET_PLAYER_POINTER( pEntity) ;
if ( pPlayer- >pEdict == NULL )
{
pPlayer- >Init( ENTINDEX( pEntity) , pEntity) ;
}
const char* name = INFOKEY_VALUE( infobuffer,"name" ) ;
const char* oldname = STRING( pEntity- >v.netname ) ;
if ( pPlayer- >rank ) {
if ( strcmp ( oldname,name) != 0 ) {
if ( ( int) csstats_rank- >value == 0 )
pPlayer- >rank = g_rank.findEntryInRank ( name, name ) ;
else
pPlayer- >rank- >setName( name ) ;
}
}
else if ( pPlayer- >IsBot( ) ) {
pPlayer- >Connect( "127.0.0.1" ) ;
pPlayer- >PutInServer( ) ;
}
RETURN_META( MRES_IGNORED) ;
}
As i think i need to hook
ClientUserInfoChanged_Post ,
findEntryInRank and
setName functions.
How to do it?
First i tried to hook findEntryInRank. Here is sig (for latest csx dev build):
findEntryInRank sig
Code:
{
"name" : "findEntryInRank" ,
"library" : "csx" ,
"identifiers" :
[
{
"os" : "windows" ,
"mod" : "cstrike" ,
"value" : 0x002810
} ,
{
"os" : "linux" ,
"mod" : "cstrike" ,
"value" : "_ZN10RankSystem15findEntryInRankEPKcS1_b"
}
]
}
But after player join server its crashed.
Plugin that i tried:
Spoiler
Code:
public plugin_init( ) {
register_plugin ( PLUGIN, VERSION, AUTHOR)
OrpheuRegisterHook(
OrpheuGetFunction( "findEntryInRank" ) ,
"RankSystem_findEntryInRank" )
}
public RankSystem_findEntryInRank( ) {
server_print ( "--> GOT IT!" )
}
After i tried to hook ClientUserInfoChanged_Post, nothing happens, no crash, no hook.
Sigs
Code:
{
"name" : "csx_ClientUserInfoChanged_Post" ,
"library" : "csx" ,
"arguments" :
[
{
"type" : "edict_s *"
} ,
{
"type" : "char *"
}
] ,
"identifiers" :
[
{
"os" : "windows" ,
"mod" : "cstrike" ,
"value" : 0x003C50
} ,
{
"os" : "linux" ,
"mod" : "cstrike" ,
"value" : "_Z26ClientUserInfoChanged_PostP7edict_sPc"
}
]
}
Test ppl
Code:
public plugin_init( ) {
register_plugin ( PLUGIN, VERSION, AUTHOR)
OrpheuRegisterHook(
OrpheuGetFunction( "csx_ClientUserInfoChanged_Post" ) ,
"ClientUserInfoChanged_Post" )
}
public ClientUserInfoChanged_Post( ) {
server_print ( "--> GOT IT" )
}
Can someone show me how to modules functions ?
__________________