[CODE] Name restrictions - help please
#1

I was wondering if anyone could show me how to put restrictions on names that can enter my server, im making a role playing server and I want the player to have to have First_Last name and not just first name.
Reply
#2

Hum.. this code for example, I dont know if it works but test it


put it under OnPlayerConnect(playerid)
Код:
new name[32];
GetPlayerName(playerid, name, sizeof(name));
if(strfind(name, "_", true) == -1)
{
      SendClientMessage(playerid, -1, "Introduce a valid name in the format <FirstName_LastName>");
      Kick(playerid);
}
strfind is a function that will search in a string for a specific character or a word that you want
In this case, it will search for the "_" character in the name.. the "-1" its when he doesnt find the character
Reply
#3

yeah it worked thanks
Reply
#4

Do you have idea of identifying if the name has numbers?
Reply
#5

I'll just manually change names that dont seem rp, like, Mike_Hunt
Reply
#6

Quote:
Originally Posted by junkbuster
Посмотреть сообщение
Do you have idea of identifying if the name has numbers?
Код:
new NumericArray[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; // I think this is the away you initialize an array with values in pawno
new name[24];
GetPlayerName(playerid, name, sizeof(name));
for(new i = 0; i <= strlen(name); ++i)
    for(new j = 0; j < 10; ++j)
        if(name[i] == NumericArray[j])
        {
              SendClientMessage(playerid, -1, "Invalid Name");
              Kick(playerid);
         }
Didn't test it.. but try it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)