AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Block name command (https://forums.alliedmods.net/showthread.php?t=135842)

ghostdlr 08-20-2010 07:16

Block name command
 
I don't want to allow players to change their name .

Registering the command and return PLUGIN_HANDLED seems to be working for other commands , like "say" , but with "name" it doesn't .

Any ideas ?

SpeeDeeR 08-20-2010 07:23

Re: Block name command
 
First of all http://forums.alliedmods.net/showthread.php?t=134274
Then
PHP Code:

#include < amxmodx >
#include < amxmisc >

public plugin_init( )
{
    
register_messageget_user_msgid"SayText" ), "MessageSayText" );
}

public 
client_infochangedclient )
{
    static const 
name[ ] = "name";
    
    static 
szNewName32 ], szOldName32 ];
    
get_user_infoclientnameszNewName31 );
    
get_user_nameclientszOldName31 );
    
    if( !
equalszNewNameszOldName ) )
    {
        
set_user_infoclientnameszOldName );
    }
}

public 
MessageSayTextiMsgIdiDestiReceiver )
{
    static const 
Cstrike_Name_Change[ ] = "#Cstrike_Name_Change";
    
    static 
szMessagesizeofCstrike_Name_Change ) + ];
    
get_msg_arg_string2szMessagesizeofszMessage ) - );
    
    return 
equalszMessageCstrike_Name_Change ) ? PLUGIN_HANDLED PLUGIN_CONTINUE;



ghostdlr 08-20-2010 07:52

Re: Block name command
 
Doesn't work properly . After I connect , my name is "unnamed" .

I want to keep the players name when they connect but not allow them to change it in game .

SpeeDeeR 08-20-2010 07:56

Re: Block name command
 
It actually blocks the name change and doesnt rename anything.

lucas_7_94 08-20-2010 08:00

Re: Block name command
 
PHP Code:

register_forward(FM_ClientUserInfoChanged"Fwd_ClientInfoChanged")

[ ... ]



public 
Fwd_ClientInfoChanged(idbuffer)
{
    if (!
is_user_connected(id))
        return 
FMRES_IGNORED;
    
    static 
val[32];
static 
name[33]
get_user_name(idnamecharsmax(name))
    
    
engfunc(EngFunc_InfoKeyValuebuffer"name"valsizeof val 1);
    
    if(
equal(valname))
        return 
FMRES_IGNORED;

    
engfunc(EngFunc_SetClientKeyValueidbuffer"name"name);
    
    
client_cmd(id"name ^"%s^"; setinfo name ^"%s^"",namename);
    
    
    
    return 
FMRES_SUPERCEDE;



ghostdlr 08-20-2010 08:07

Re: Block name command
 
Quote:

Originally Posted by lucas_7_94 (Post 1276620)
PHP Code:

register_forward(FM_ClientUserInfoChanged"Fwd_ClientInfoChanged")

[ ... ]



public 
Fwd_ClientInfoChanged(idbuffer)
{
    if (!
is_user_connected(id))
        return 
FMRES_IGNORED;
    
    static 
val[32];
static 
name[33]
get_user_name(idnamecharsmax(name))
    
    
engfunc(EngFunc_InfoKeyValuebuffer"name"valsizeof val 1);
    
    if(
equal(valname))
        return 
FMRES_IGNORED;

    
engfunc(EngFunc_SetClientKeyValueidbuffer"name"name);
    
    
client_cmd(id"name ^"%s^"; setinfo name ^"%s^"",namename);
    
    
    
    return 
FMRES_SUPERCEDE;



Do I need a particular library to compile this ?

lucas_7_94 08-20-2010 08:12

Re: Block name command
 
fakemeta.

ghostdlr 08-20-2010 08:15

Re: Block name command
 
It works .
Thanks

lucas_7_94 08-20-2010 08:44

Re: Block name command
 
np.

mrgregory 03-09-2011 22:07

Re: Block name command
 
lucas794 can u tell me how to compile your script?


All times are GMT -4. The time now is 21:53.

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