SA-MP Forums Archive
Player can't login if he don't have "_" in his name - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Player can't login if he don't have "_" in his name (/showthread.php?tid=273813)



Player can't login if he don't have "_" in his name - -CaRRoT - 03.08.2011

Well.. i got Register / login System in my GM - If player has non-rp name , Ex: Batman , it kick him , only RP name such as Alex_Black , so i wanted to remove this , here :

ondialogresponse :

pawn Код:
if(dialogid == 1) //LOGIN
    {
        if(gPlayerLogged[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
            return 1;
        }
        if(response)
        {
            if(!strlen(inputtext))
            {
                DisplayDialogForPlayer(playerid, 1); //login
                SendClientMessage(playerid, COLOR_WHITE, "SERVER: You must enter a password.");
                return 1;
            }
            if(strlen(inputtext) >= 50)
            {
                DisplayDialogForPlayer(playerid, 1); //login
                SendClientMessage(playerid, COLOR_WHITE, "SERVER: Password is too long.");
                return 0;
            }
            new tmppass[64];
            //Store Player ID & TMP pass in echo to find string used to crash server
            new playername[MAX_PLAYER_NAME];
            strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
            GetPlayerName(playerid, playername, sizeof(playername));
//          printf("[login] [%s] %s", playername, inputtext[0]);
            if(strlen(playername) == 3)
            {
                if(strcmp(playername, "Smo", true) == 0)
                {
                    return 0;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_LIGHTRED, "Sorry, that name is too short, please change it.");
                    Kick(playerid);
                    return 1;
                }
            }
            Encrypt(tmppass);
            OnPlayerLogin(playerid,tmppass);
        }
        else
        {
            DisplayDialogForPlayer(playerid, 1); //login
        }
    }
    if(dialogid == 2) //REGISTER
    {
        if(gPlayerLogged[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
            return 1;
        }
        if(response)
        {
            if(strlen(inputtext) >= 50)
            {
                DisplayDialogForPlayer(playerid, 2); //register
                SendClientMessage(playerid, COLOR_WHITE, "SERVER: Password is too long.");
                return 0;
            }
            new sendername[MAX_PLAYER_NAME];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            {
                SendClientMessage(playerid, COLOR_YELLOW, "It would be cooler if your name be  Firstname_Lastname format.");
                return 1;
            }
            else
            {
                if(!strlen(inputtext))
                {
                    DisplayDialogForPlayer(playerid, 2); //register
                    SendClientMessage(playerid, COLOR_WHITE, "SERVER: You must enter a password.");
                    return 1;
                }
                new string[128];
                format(string, sizeof(string), "%s.ini", sendername);
//              if(dini_Exists(string))
                if(fexist(string))
                {
                    SendClientMessage(playerid, COLOR_YELLOW, "That name is already taken, please choose a different one.");
                    return 1;
                }
                new tmppass[64];
                strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
                Encrypt(tmppass);
                OnPlayerRegister(playerid,tmppass);
                OnPlayerLogin(playerid,tmppass);
                gPlayerAccount[playerid] = 1;
                gPlayerSpawned[playerid] = 1;
                SendClientMessage(playerid, COLOR_YELLOW, "Account registered, you have been logged in automatically.");
            }
        }
        else
        {
            DisplayDialogForPlayer(playerid, 2); //register
        }
    }

Can someoen help please in this ?


Re: Player can't login if he don't have "_" in his name - Snipa - 03.08.2011

pawn Код:
if(!strfind(name,"_", true) != -1) Kick(playerid);
Is that what you're looking for?


Re: Player can't login if he don't have "_" in his name - -CaRRoT - 03.08.2011

if i delete that , you won't be procedded to the tutorial


Re: Player can't login if he don't have "_" in his name - Scenario - 03.08.2011

Change "Kick(playerid);" to "return 1;"


Re: Player can't login if he don't have "_" in his name - -CaRRoT - 03.08.2011

Did it like this :

pawn Код:
new sendername[MAX_PLAYER_NAME];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new namestring = strfind(sendername, "_", true);
            if(namestring == -1)
            {
                SendClientMessage(playerid, COLOR_YELLOW, "Your name Would be Cooler if it is Firstname_Lastname format.");
                return 1;
            }
it complied but..he don't move to "Are you Male or Female" or what is your birthdate then the tutorial


Respuesta: Player can't login if he don't have "_" in his name - Sergio_MOW - 03.08.2011

Use strfind with "_".


Re: Player can't login if he don't have "_" in his name - -CaRRoT - 03.08.2011

what do you mean ?


Re: Player can't login if he don't have "_" in his name - iiKyle - 04.08.2011

I Dont Mean To Be An Arse, Sorry if i Come off as a 'Troll' or an 'Arse'.


But To me it Looks like you Dont have any idea on How to Script.
Atleast go Read an Pawno Lang Tut, or ... Pawno-lang.pdf Tutorial.

Unless you've Coded in D3D & C++ Read the Basic << Because the Synatx is the Same Basic C++

It Just Get a Bit Annoying time and time Again seeing Stuff like,

'Whats onPlayerSpawn do?'
'I Get This Error "Can't Read from file: Streamer"'

Sorry if i Come Across as im An Arse,
Just I Used to Code in C++ (Wont say Wont for)

But in C++ Forums this is Constructive Crit.


EDIT:
Код:
"Your name Would be Cooler if it is Firstname_Lastname format."
Cooler? Its for RP... Not to be Cool xD


Cheers iiKyle


NOTICE: Sorry for My Capitals, i Know it Looks Foul, I Know its Terrible, Its a Extremely bad Habbit; Im Working on it.