I need help with player name
#4

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
Add:
PHP код:
stock IsValidRoleplayName(const name[]) {
    if (!
name[0] || strfind(name"_") == -1)
        return 
0;
    else for (new 
0len strlen(name); != len++) {
        if ((
== 0) && (name[i] < 'A' || name[i] > 'Z'))
            return 
0;
        else if ((
!= && len  && name[i] == '_') && (name[1] < 'A' || name[1] > 'Z'))
            return 
0;
        else if ((
name[i] < 'A' || name[i] > 'Z') && (name[i] < 'a' || name[i] > 'z') && name[i] != '_' && name[i] != '.')
            return 
0;
    }
    return 
1;

And OnPlayerConnect:
PHP код:
public OnPlayerConnect(playerid)
{
    new 
Name[128];
    
GetPlayerName(playeridNamesizeof(Name));
    if(!
IsValidRoleplayName(Name))
    {
        
SendClientMessage(playerid, -1"You were kicked because of your name. The server only accepts character names, i.e Kendrick_Lamar.");
    
KickEx(playerid);
    return 
false;
    }
        return 
true;

Thanks buddy!
Reply


Messages In This Thread
I need help with player name - by akib - 30.05.2017, 09:13
Re: I need help with player name - by Kane - 30.05.2017, 09:26
Re: I need help with player name - by StrikerZ - 30.05.2017, 09:35
Re: I need help with player name - by akib - 30.05.2017, 10:19
Re: I need help with player name - by Cadilab - 30.05.2017, 10:23
Re: I need help with player name - by GoldenLion - 30.05.2017, 16:39

Forum Jump:


Users browsing this thread: 1 Guest(s)