SA-MP Forums Archive
Login system bugged? - 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: Login system bugged? (/showthread.php?tid=394209)



Login system bugged? - James Bob - 21.11.2012

Okay, well I have made a login system which works on my local host but on my server you can type in any password and it works.

Код:
ShowMainMenuDialog(playerid, frame)
{
	new titlestring[64];
	new string[256];

	switch(frame)
	{
		case 1:
		{
			new ip[32];
			GetPlayerIp(playerid, ip, 32);
			format(titlestring, sizeof(titlestring), "Login - %s", GetPlayerNameEx(playerid));
			format(string, sizeof(string), "Welcome to High Street's Roleplay, %s.\n\nThis Account Is Registred Please Fill In Your Password To Login In", GetPlayerNameEx(playerid),  ip);
			ShowPlayerDialog(playerid,MAINMENU,DIALOG_STYLE_INPUT,titlestring,string,"Login","Exit");
		}
		case 2:
		{
			new ip[32];
			GetPlayerIp(playerid, ip, 32);
			format(titlestring, sizeof(titlestring), "Register - %s", GetPlayerNameEx(playerid));
			format(string, sizeof(string), "Welcome to High Street's Roleplay, %s.\n\nYou Have Not Yet Registerd Please Do And Fill Out The Password.", GetPlayerNameEx(playerid),  ip);
			ShowPlayerDialog(playerid,MAINMENU2,DIALOG_STYLE_INPUT,titlestring,string,"Register","Exit");
		}
		case 3:
		{
			new ip[32];
			GetPlayerIp(playerid, ip, 32);
			format(titlestring, sizeof(titlestring), "Login - %s", GetPlayerNameEx(playerid));
			format(string, sizeof(string), "Invalid Password!\n\nWelcome to High Street's Roleplay, %s.\n\nThis Account Is Registred Please Fill In Your Password To Login In", GetPlayerNameEx(playerid),  ip);
			ShowPlayerDialog(playerid,MAINMENU,DIALOG_STYLE_INPUT,titlestring,string,"Login","Exit");
		}
	}
}

public SafeLogin(playerid)
{

	// Main Menu Features.
	ShowMainMenuGUI(playerid);
	SetPlayerJoinCamera(playerid);
	ClearChatbox(playerid);
	SetPlayerVirtualWorld(playerid, 0);

	new playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername, sizeof(playername));
	if(doesAccountExist(playername))
	{
		gPlayerAccount[playerid] = 1;
		ShowMainMenuDialog(playerid, 1);
		return 1;
	}
	else
	{
		if( strfind( playername, "_", true) == -1 )
		{
			SendClientMessageEx( playerid, COLOR_WHITE, "Connection rejected. Please get a name in the correct format like: James_Bob." );
		}
		else
		{
			gPlayerAccount[playerid] = 0;
			ShowMainMenuDialog(playerid, 2);
		}

		return 1;
	}
}
Код:
if(dialogid == MAINMENU || dialogid == MAINMENU2)
	{
		if(dialogid == MAINMENU)
		{
			if( response == 0 )
			{
				SendClientMessageEx(playerid, COLOR_RED, "SERVER: You have been kicked out automatically.");
				Kick(playerid);
			}
			else
			{
				if(strlen(inputtext))
				{
					new tmppass[64];
					strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
					Encrypt(tmppass);
					OnPlayerLogin(playerid,tmppass);
				}
				else
				{
					new loginname[64];
					GetPlayerName(playerid,loginname,sizeof(loginname));
					ShowPlayerDialog(playerid,MAINMENU,DIALOG_STYLE_INPUT,"Login","Incorrect password. \n \nThat name is registered, you may now enter your password.","Login","Exit");
					gPlayerLogTries[playerid] += 1;
					if(gPlayerLogTries[playerid] == 2) { SendClientMessageEx(playerid, COLOR_RED, "SERVER: Wrong password, you have been kicked out automatically."); Kick(playerid); }
				}
			}
		}
		if(dialogid == MAINMENU2)
		{
			if(strlen(inputtext))
			{
				GetPlayerName(playerid, sendername, sizeof(sendername));
				if(doesAccountExist(sendername))
				{
					SendClientMessageEx(playerid, COLOR_YELLOW, "That username 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);
			}
		}
	}



Re: Login system bugged? - -=Dar[K]Lord=- - 21.11.2012

pawn Код:
if(strlen(inputtext))// here its bugged cuz strlen inputtext
                {
                    new tmppass[64];
                    strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
                    Encrypt(tmppass);
                    OnPlayerLogin(playerid,tmppass);
                }
                else
                {
                    new loginname[64];
                    GetPlayerName(playerid,loginname,sizeof(loginname));
                    ShowPlayerDialog(playerid,MAINMENU,DIALOG_STYLE_INPUT,"Login","Incorrect password. \n \nThat name is registered, you may now enter your password.","Login","Exit");
                    gPlayerLogTries[playerid] += 1;
                    if(gPlayerLogTries[playerid] == 2) { SendClientMessageEx(playerid, COLOR_RED, "SERVER: Wrong password, you have been kicked out automatically."); Kick(playerid); }
                }
dude inputtext means the text which u put in dialog .. so if u put any thing in dialog and say ok it will log u in so u neeed a hasher like whirlpool


Re: Login system bugged? - James Bob - 21.11.2012

Quote:
Originally Posted by -=Dar[K]Lord=-
Посмотреть сообщение
pawn Код:
if(strlen(inputtext))// here its bugged cuz strlen inputtext
                {
                    new tmppass[64];
                    strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
                    Encrypt(tmppass);
                    OnPlayerLogin(playerid,tmppass);
                }
                else
                {
                    new loginname[64];
                    GetPlayerName(playerid,loginname,sizeof(loginname));
                    ShowPlayerDialog(playerid,MAINMENU,DIALOG_STYLE_INPUT,"Login","Incorrect password. \n \nThat name is registered, you may now enter your password.","Login","Exit");
                    gPlayerLogTries[playerid] += 1;
                    if(gPlayerLogTries[playerid] == 2) { SendClientMessageEx(playerid, COLOR_RED, "SERVER: Wrong password, you have been kicked out automatically."); Kick(playerid); }
                }
dude inputtext means the text which u put in dialog .. so if u put any thing in dialog and say ok it will log u in so u neeed a hasher like whirlpool
Could you script me one working please, I'll +Rep.. Also, I kinda understand now.


Re: Login system bugged? - -=Dar[K]Lord=- - 21.11.2012

Quote:
Originally Posted by James Bob
Посмотреть сообщение
Could you script me one working please, I'll +Rep.. Also, I kinda understand now.
hmm sure just need ur login and register system so that i can fix it and i want full dont worry i wont steal it


Re: Login system bugged? - James Bob - 21.11.2012

Quote:
Originally Posted by -=Dar[K]Lord=-
Посмотреть сообщение
hmm sure just need ur login and register system so that i can fix it and i want full dont worry i wont steal it
Can you do it over TeamViewer? If you can i'll inbox you my TV ID , Password.


Re: Login system bugged? - -=Dar[K]Lord=- - 21.11.2012

yea i have it send me ur id and pass in pm