Raised This Month: $51 Target: $400
 12% 

Other way to block changing name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
m0skVi4a
Senior Member
Join Date: May 2011
Location: Rousse, Bulgaria
Old 11-04-2011 , 13:59   Other way to block changing name
Reply With Quote #1

Hello
I am making a Register System plugin and the beta version is almost reаdy. My problem is that when player change his name and hi is logged to block the name change. I found that and works properly
PHP Code:
public client_infochanged(id
{
        if(!
is_user_connected(id))
            return 
PLUGIN_HANDLED

        
new newname[32]
        
get_user_info(id,"name",newname,31)

        new 
oldname[32]
        
get_user_name(id,oldname,31)

        if(!
equal(newname,oldname))
        {
            
set_user_info(id,"name",oldname)
            return 
PLUGIN_HANDLED
        
}
            return 
PLUGIN_CONTINUE

and i change it to
PHP Code:
public client_infochanged(id
{
    if(
is_logged[id])
    {
        if(!
is_user_connected(id))
            return 
PLUGIN_HANDLED

        
new newname[32]
        
get_user_info(id,"name",newname,31)

        new 
oldname[32]
        
get_user_name(id,oldname,31)

        if(!
equal(newname,oldname))
        {
            
set_user_info(id,"name",oldname)
            return 
PLUGIN_HANDLED
        
}
    }
    else if(
is_registerd[id])
    {
        
is_registerd[id] = false
    
    
}
    

    return 
PLUGIN_CONTINUE

The problem is that when player putinserver the plugin makes the checks and if his name is in the file is_registered makes true. But when player connect (i suppose) client_infochanged makes is_registered to false and the player can't log in.

My question:
Is there any other way to block name changing, except client_infochanged and the fakemeta way with FM_ClientUserInfoChanged. Or how to do my code to work properly?
m0skVi4a is offline
Send a message via Skype™ to m0skVi4a
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-05-2011 , 01:17   Re: Other way to block changing name
Reply With Quote #2

The Fakemeta way is the best way that I've seen.
__________________
fysiks is offline
m0skVi4a
Senior Member
Join Date: May 2011
Location: Rousse, Bulgaria
Old 11-05-2011 , 04:10   Re: Other way to block changing name
Reply With Quote #3

OK
here is it
PHP Code:
register_forward(FM_ClientUserInfoChanged"NoNameChange")

...

public 
NoNameChange(idbuffer)
{
    if(
is_logged[id])
    {
        if(!
is_user_connected(id))
            return 
FMRES_IGNORED
    
        
static name[32], val[32];
    
        
get_user_name(idnamesizeof name 1)
        
engfunc(EngFunc_InfoKeyValuebuffer"name"valsizeof val 1)
    
        if(
equal(valname))
            return 
FMRES_IGNORED
    
        engfunc
(EngFunc_SetClientKeyValueidbuffer"name"name)
        
client_printcolor(id"%L"LANG_SERVER"NAME_CHANGE"prefix)
    }
    else if(
is_registerd[id])
    {
        
is_registerd[id] = false
    
}
    
    return 
FMRES_SUPERCEDE

The problem is the same:
From client_putinserver is_registered makes true, but that code makes it false and user can't login.
m0skVi4a is offline
Send a message via Skype™ to m0skVi4a
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-05-2011 , 04:49   Re: Other way to block changing name
Reply With Quote #4

You need to realize that this function is called several times before the user is connected completely so you can't supercede in those cases and you also will not have a proper/relevant value for is_logged[id] either.

In laymans terms, move the is_user_connected check so that when they aren't connected then no code gets executed and you return ignored.
__________________

Last edited by fysiks; 11-05-2011 at 04:50.
fysiks is offline
m0skVi4a
Senior Member
Join Date: May 2011
Location: Rousse, Bulgaria
Old 11-05-2011 , 14:42   Re: Other way to block changing name
Reply With Quote #5

Both methods don't work with is_user_connected in the start of the function..
Here is it the fakemeta method
PHP Code:
public NoNameChange(idbuffer
{
    if(!
is_user_connected(id))
        return 
FMRES_IGNORED
        
    
if(is_logged[id])
    {
        static 
name[32], val[32];
    
        
get_user_name(idnamesizeof name 1)
        
engfunc(EngFunc_InfoKeyValuebuffer"name"valsizeof val 1)
    
        if(
equal(valname))
            return 
FMRES_IGNORED
    
        engfunc
(EngFunc_SetClientKeyValueidbuffer"name"name)
        
client_printcolor(id"%L"LANG_SERVER"NAME_CHANGE"prefix)
    }
    else if(
is_registerd[id])
    {
        
is_registerd[id] = false
    
}
    
    return 
FMRES_SUPERCEDE

Is there any other way to find when player is changing his name except client_infochanged and the fakemeta userinfo changed but only for name change?
m0skVi4a is offline
Send a message via Skype™ to m0skVi4a
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-05-2011 , 15:10   Re: Other way to block changing name
Reply With Quote #6

PHP Code:
public plugin_init()
{
    
register_forward(FM_ClientUserInfoChanged"ClientUserInfoChanged")
}

public 
ClientUserInfoChanged(id)
{
    static const 
name[] = "name"
    
new szOldName[32], szNewName[32]
    
pev(idpev_netnameszOldNamecharsmax(szOldName))
    if( 
szOldName[0] )
    {
        
get_user_info(idnameszNewNamecharsmax(szNewName))
        if( !
equal(szOldNameszNewName) )
        {
            
// name change, to block or change use set_user_info and return FMRES_HANDLED (don't need to superceede)
        
}
    }
    else if( 
get_user_info(idnameszNewNamecharsmax(szNewName)) )
    {
        
// first time client name is taken in account
        // to change, use set_user_info and return FMRES_HANDLED (don't need to superceede)
    
}
    return 
FMRES_IGNORED

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 11-05-2011 at 15:11.
ConnorMcLeod is offline
m0skVi4a
Senior Member
Join Date: May 2011
Location: Rousse, Bulgaria
Old 11-05-2011 , 15:33   Re: Other way to block changing name
Reply With Quote #7

Thanks
I changed it to
PHP Code:
public NoNameChange(id
{
    static const 
name[] = "name"
    
new szOldName[32], szNewName[32]
    
pev(idpev_netnameszOldNamecharsmax(szOldName))
    if(
szOldName[0])
    {
        
get_user_info(idnameszNewNamecharsmax(szNewName))
        if(!
equal(szOldNameszNewName))
        {
            if(
is_logged[id])
            {
                
set_user_info(idnameszOldName)
                
client_printcolor(id"%L"LANG_SERVER"NAME_CHANGE"prefix)
                return 
FMRES_HANDLED
            
}
            else if(
is_registerd[id])
            {
                
is_registerd[id] = false
                remove_task
(id)
                return 
FMRES_HANDLED
            
}            
        }
    }
    return 
FMRES_IGNORED

Tomorrow i will write the description and i will post the plugin in the forum
m0skVi4a is offline
Send a message via Skype™ to m0skVi4a
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-05-2011 , 15:37   Re: Other way to block changing name
Reply With Quote #8

PHP Code:
            else if(is_registerd[id])
            {
                
is_registerd[id] = false
                remove_task
(id)
                return 
FMRES_HANDLED
            

You don't need to return HANDLED there since you changed nothing except plugin internal datas.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:15.


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