SA-MP Forums Archive
[CODE] Name restrictions - help please - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [CODE] Name restrictions - help please (/showthread.php?tid=331793)



[CODE] Name restrictions - help please - squomp - 06.04.2012

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.


Re: [CODE] Name restrictions - help please - DR3AD - 06.04.2012

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


Re: [CODE] Name restrictions - help please - squomp - 06.04.2012

yeah it worked thanks


Respuesta: Re: [CODE] Name restrictions - help please - junkbuster - 06.04.2012

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


Re: [CODE] Name restrictions - help please - squomp - 06.04.2012

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


Re: Respuesta: Re: [CODE] Name restrictions - help please - DR3AD - 06.04.2012

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