Thread: Auto Name
View Single Post
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 03-15-2024 , 06:02   Re: Auto Name
Reply With Quote #14

Quote:
Originally Posted by WATCH_D0GS UNITED View Post
@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_szNameMAX_PLAYERS ][ 32 ];
new 
g_bCheckName;

public 
plugin_init() 
{
    
register_plugin"Name Change Hook" Version "bugsy" );
    
    
register_event"SayText" "EventSayText" "a" "2=#Cstrike_Name_Change" );
    
    
register_forwardFM_ClientUserInfoChanged "ClientUserInfoChanged" );
}

public 
EventSayText()
{
    
g_bCheckName 1;
}

public 
ClientUserInfoChangedid )
{
    if ( !
g_bCheckName )
        return;
    
    
g_bCheckName 0;
    
    if ( !
is_user_connectedid ) )
        return;
    
    
get_user_nameid g_szNameid ] , charsmaxg_szName[] ) );
    
    for ( new 
sizeof DefaultNames ) ; i++ )
    {
        if ( 
equalig_szNameid ] , DefaultNames] ) )
        {
            
//set name
        
}
    }

__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57