Quote:
Originally Posted by WATCH_D0GS UNITED
@georgik57
If the "2=#Cstrike_Name_Change" occurs it is always a player changing his name.
But it is global "a", so you will not be able to catch the player id there. You could use a loop although.
So Bugsy proceeds on FM_ClientUserInfoChanged, where the player id can be catched a bit after.
By unregistering the forward you eliminate unnecessary "if" checks when the function is called, in this case when the player changes its team or something else.
|
I meant like this. 2 less native calls.
PHP Code:
#include <amxmodx>
#include <fakemeta>
new const Version[] = "0.2";
#define MAX_PLAYERS 32
new const DefaultNames[][] =
{
"Player",
"Sizzle Chest",
"Frank Rizzo",
"Sol Rosenberg",
"Mike Derucki"
};
new g_szName[ MAX_PLAYERS + 1 ][ 32 ];
new g_bCheckName;
public plugin_init()
{
register_plugin( "Name Change Hook" , Version , "bugsy" );
register_event( "SayText" , "EventSayText" , "a" , "2=#Cstrike_Name_Change" );
register_forward( FM_ClientUserInfoChanged , "ClientUserInfoChanged" , 1 );
}
public EventSayText()
{
g_bCheckName = 1;
}
public ClientUserInfoChanged( id )
{
if ( !g_bCheckName )
return;
g_bCheckName = 0;
if ( !is_user_connected( id ) )
return;
get_user_name( id , g_szName[ id ] , charsmax( g_szName[] ) );
for ( new i = 0 ; i < sizeof ( DefaultNames ) ; i++ )
{
if ( equali( g_szName[ id ] , DefaultNames[ i ] ) )
{
//set name
}
}
}
__________________