Raised This Month: $ Target: $400
 0% 

[REQ] Name min. and max. lenght


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Denmla
Member
Join Date: Jul 2007
Old 12-26-2009 , 16:55   [REQ] Name min. and max. lenght
Reply With Quote #1

Hello, i want to request some small ( i think ) plugin. So i need plugin which will restrict that names can't have less then 3 characters and more then 26 characters, and please keep it very simple.

Thanks
Denmla is offline
trup1k
Member
Join Date: Nov 2009
Old 12-26-2009 , 16:57   Re: [REQ] Name min. and max. lenght
Reply With Quote #2

http://forums.alliedmods.net/showthread.php?t=17363
trup1k is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-26-2009 , 17:00   Re: [REQ] Name min. and max. lenght
Reply With Quote #3

What do u want to do to users who have these long or short names?
__________________
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-26-2009 , 17:23   Re: [REQ] Name min. and max. lenght
Reply With Quote #4

Names shorter than Min characters will have ReplaceChars appended: ie. Bu would be BuX ; P would be PXX
Names longer than Max will just be shortened.

PHP Code:
#include <amxmodx>
#include <amxmisc>

const g_NameMin 3;
const 
g_NameMax 26;
const 
g_ReplaceChar 'X';

public 
plugin_init() 
{
    
register_plugin"Name Length Restrict" "0.1" "bugsy" );
}

public 
client_putinserverid )
{
    
CheckNameid , { } );
}

public  
client_infochangedid 
{
    new 
szNew33 ] ,szOld33 ]; 
    
get_user_infoid "name" szNew 32 );
    
get_user_nameid szOld 32 );
    
    if ( !
equalszNew szOld ) )
        
CheckNameid szNew );
}

public 
CheckNameid , const szHaveName[] )
{
    new 
szName33 ] , iLen;
    
    if ( !
szHaveName] )
    {
        
iLen get_user_nameid szName 32 );
    }
    else
    {
        
iLen copyszName 32 szHaveName );
    }
    
    if ( 
iLen g_NameMin )
        
setcszNameiLen ] , g_NameMin iLen g_ReplaceChar );
    else if ( 
iLen g_NameMax )
        
szNameg_NameMax ] = EOS;
    else
        return 
PLUGIN_HANDLED;
    
    
set_user_infoid "name" szName );
    
    return 
PLUGIN_HANDLED;

__________________

Last edited by Bugsy; 12-26-2009 at 18:57.
Bugsy is offline
Denmla
Member
Join Date: Jul 2007
Old 12-26-2009 , 17:26   Re: [REQ] Name min. and max. lenght
Reply With Quote #5

Quote:
Originally Posted by trup1k View Post
I know for that plugin but i need just one function of that plugin and because this plugin is to big for me, and like i said, i just want it simple.


Quote:
Originally Posted by Bugsy View Post
This will add ReplaceChars to a name to make it atleast 3 chars or trim characters that make a name longer than 26.
Sorry for taking your time, but, can you make to rename them with less then 3 characters to "noob" and them with more then 26 characters to n00b2? And thank you very much for fast reply to my topic.

Last edited by Denmla; 12-26-2009 at 18:45.
Denmla is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-26-2009 , 18:47   Re: [REQ] Name min. and max. lenght
Reply With Quote #6

Untested.
PHP Code:
#include <amxmodx>
#include <amxmisc>

new const g_NameMin 3;
new const 
g_NameMax 26;
new const 
g_NameShort[] = "NoobShort";
new const 
g_NameLong[] = "NoobLong";

public 
plugin_init() 
{
    
register_plugin"Name Length Restrict" "0.1" "bugsy" );
}

public 
client_putinserverid )
{
    
CheckNameid );
}

public  
client_infochangedid 
{
    new 
szNew33 ] , szOld33 ]; 
    
get_user_infoid "name" szNew charsmaxszNew ) );
    
get_user_nameid szOld charsmaxszOld ) );
    
    if ( !
equalszNew szOld ) )
    {
        
CheckNameid );
    }
}

public 
CheckNameid )
{
    new 
szName33 ] , iLen;
    
iLen get_user_infoid "name" szName charsmaxszName ) );
    
    if ( 
iLen g_NameMin )
    {
        
set_user_infoid "name" g_NameShort );
    }
    else if ( 
iLen g_NameMax )
    {
        
set_user_infoid "name" g_NameLong );
    }
    
    return 
PLUGIN_HANDLED;

__________________

Last edited by Bugsy; 01-02-2010 at 01:15.
Bugsy is offline
Denmla
Member
Join Date: Jul 2007
Old 12-26-2009 , 19:01   Re: [REQ] Name min. and max. lenght
Reply With Quote #7

Looks like i have edited my last post to late because looks like you read the old last post. So i wanted if it's not too big deal that when somebody have nick less then 3 characters to get nick "Too Short Nick" and player who have nick with more then 26 characters get nick "To Long Nick".

I'm very sorry because i've edited my last post too late, if you have time you can make it if not i'll be grateful for what you code already.

Thanks
Denmla is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-26-2009 , 19:05   Re: [REQ] Name min. and max. lenght
Reply With Quote #8

Already edited it for you, just replace noob and n00b2 accordingly.
__________________
Bugsy is offline
Denmla
Member
Join Date: Jul 2007
Old 12-26-2009 , 19:07   Re: [REQ] Name min. and max. lenght
Reply With Quote #9

OK, thank you very much, you are really cool! + karma
Denmla is offline
Denmla
Member
Join Date: Jul 2007
Old 01-01-2010 , 22:45   Re: [REQ] Name min. and max. lenght
Reply With Quote #10

Hi, i tested plugin now and got some problems.

So when i connect with nick "a" on server, server changed my name to "Too Short Nick", but if i change nick in game back to "a" server won't change my nick to "Too Short Nick".
Denmla 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 00:31.


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