AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Restrict changename [unnamed error] (https://forums.alliedmods.net/showthread.php?t=168829)

tristanoff 10-04-2011 14:45

Restrict changename [unnamed error]
 
Hi, im triying to block changename & message so i have this:
PHP Code:

register_message(get_user_msgid("SayText"), "MessageNameChange");
register_forward(FM_ClientUserInfoChanged"fwClientUserInfoChanged")
[...] 

block changename:
PHP Code:

public fwClientUserInfoChanged(idbuffer) {
    
// can_proced_to_tag[id] it's a flag...
    
if (!is_user_connected(id) || can_proced_to_tag[id]){
        
can_proced_to_tag[id] = false;
        return 
FMRES_IGNORED
    
}

    static 
name[32], val[32]
    
get_user_name(idnamesizeof name 1)
    
engfunc(EngFunc_InfoKeyValuebufferg_namevalsizeof val 1)
    if (
equal(valname))
        return 
FMRES_IGNORED

    engfunc
(EngFunc_SetClientKeyValueidbufferg_namename)
    
console_print(id"%s""cant changename!")

    return 
FMRES_SUPERCEDE


block msg:
PHP Code:

public MessageNameChange(msgiddestreceiver) {     
    static 
info[64];     
    
get_msg_arg_string(2infosizeof(info) - 1);         
    if( !
equali(info"#Cstrike_Name_Change") ) return PLUGIN_CONTINUE;  
    
    static 
client;         
    for( new 
35i++ ){         
        
get_msg_arg_string(iinfosizeof(info) - 1);         
        
client get_user_index(info);                 
        if( 
is_user_connected(client) ) break;                
        
client 0;     
        }         
 
    return 
PLUGIN_HANDLED ;

 } 

Ok that's work ( i think ) .. so i have too some like this:
PHP Code:

public set_tag(playerid groupid){
    new 
name[28] , newname[33];
    
    
get_user_name(playerid,name,27)
    
copy(old_names[playerid],27,name)
    

    
formatex(newname,32,"%s.%s",group_tag[groupid],name)
    
    
can_proced_to_tag[playerid] = true;
    
client_cmd(playerid,"name ^"%s^";setinfo name ^"%s^"",newname,newname)
    
can_proced_to_tag[playerid] = true;
    
set_user_info(playerid,"name",newname)
    
    


so.. the player can change his name if can_proced_to_tag[id] its true .. and this work but the problem it's when changemap .. the player's name has set to "unnamed,unnamed(1)...etc" and when they are connecting get some "overflow" :crab:

keyblade 10-05-2011 02:04

Re: Restrict changename [unnamed error]
 
PHP Code:

#include <amxmodx>
#include <fakemeta>
 
#define PLUGIN "TEST"
#define VERSION "1.0"
#define AUTHOR "Ice-Action |#KeyBlade"
 
new bool:can_proced_to_tag[33]
 
public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_forward(FM_ClientUserInfoChanged"InfoChanged"1)
    
register_message(get_user_msgid("SayText"), "Message_SayText")
}
 
public 
Message_SayText(msg_idmsg_destmsg_entity)
{
    new 
Marg[32]
    
get_msg_arg_string(2Marg31)
    if( 
equal(Marg"#Cstrike_Name_Change") )
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}
public 
InfoChanged(id)
{
    if( 
is_user_connected(id) && !can_proced_to_tag[id] )
    {
        new 
pname[32], oldname[32]
        
pev(idpev_netnameoldname31)
        
get_user_info(id"name"pname31)
        if( !
equali(pnameoldname) )
        {
            
set_user_info(id"name"oldname)
        }
    }


tested

Hunter-Digital 10-05-2011 07:02

Re: Restrict changename [unnamed error]
 
There are serval plugins that do what you need:

http://forums.alliedmods.net/showthread.php?p=240578
http://forums.alliedmods.net/showthread.php?p=221805
http://forums.alliedmods.net/showthread.php?p=154865

And that's what I found in a few seconds, there may be more.

tristanoff 10-05-2011 15:10

Re: Restrict changename [unnamed error]
 
Quote:

Originally Posted by keyblade (Post 1568671)
PHP Code:

#include <amxmodx>
#include <fakemeta>
 
#define PLUGIN "TEST"
#define VERSION "1.0"
#define AUTHOR "Ice-Action |#KeyBlade"
 
new bool:can_proced_to_tag[33]
 
public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_forward(FM_ClientUserInfoChanged"InfoChanged"1)
    
register_message(get_user_msgid("SayText"), "Message_SayText")
}
 
public 
Message_SayText(msg_idmsg_destmsg_entity)
{
    new 
Marg[32]
    
get_msg_arg_string(2Marg31)
    if( 
equal(Marg"#Cstrike_Name_Change") )
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}
public 
InfoChanged(id)
{
    if( 
is_user_connected(id) && !can_proced_to_tag[id] )
    {
        new 
pname[32], oldname[32]
        
pev(idpev_netnameoldname31)
        
get_user_info(id"name"pname31)
        if( !
equali(pnameoldname) )
        {
            
set_user_info(id"name"oldname)
        }
    }


tested

It's the same.. i got "unnamed" in players :grrr:

ConnorMcLeod 10-05-2011 15:23

Re: Restrict changename [unnamed error]
 
This is what you need : http://forums.alliedmods.net/showpos...27&postcount=3
Don't need to register message.

keyblade 10-05-2011 22:02

Re: Restrict changename [unnamed error]
 
Quote:

Originally Posted by tristanoff (Post 1568975)
It's the same.. i got "unnamed" in players :grrr:

...but i didn't get it...maybe you can try what digital posted in #3

tristanoff 10-06-2011 11:24

Re: Restrict changename [unnamed error]
 
Fixed, thanks bro!!


All times are GMT -4. The time now is 19:42.

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