Login Dialog
#1

Hello, I got a little problem here with login dialog..


My script

Код:
public OnPlayerRequestClass(playerid, classid)
{
	if (gPlayerAccount[playerid] != 0)
	{
		new s[128],pName[24];
		GetPlayerName(playerid, pName, 24);
		format(s,sizeof(s),"Welcome, %s!\n\nYou have to login for playing!\n\nPlease enter your password:",pName);
		ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Game login:",s,"Login","Cancel");
	}
	return 1;
}
Dialog will open very well when i start SA:MP

but if i wrote something in the dialog i just can't login


Код:
	if(dialogid == 2)
	{
	  if(!response)
	  {
			Kick(playerid);
	  }
	  else
	  {
			if(strcmp(PlayerInfo[playerid][pKey],inputtext, true ) == 0)
			{
			  SendClientMessage(playerid, COLOR_YELLOW, "You have been logged in, Welcome !");
			  SendClientMessage(playerid, COLOR_GREEN, "Press 'Spawn' to continue ");
			  gPlayerLogged[playerid] = 1;
If i now press Cancel button, then server close connection (i have been kicked) - that's correct

But if i write correct password , then i got message it's wrong password
And if i don't write anything, just press spawn button , then i have logged in..

So i can get in without password


Sorry about my bad english..
Reply
#2

That's probably because PlayerInfo[playerid][pKey] is blank.
You need to get the real password from the files or database (whatever you are using) and then save it in PlayerInfo[playerid][pKey] (Do that OnPlayerConnect)!
Reply
#3

Thank you for quick answer


My real login is :

Код:
dcmd_login(playerid, params[])
{
	new tmppass[64];
	if(gPlayerLogged[playerid] == 1)
	{
		SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "You have been already logged in.");
		return 1;
	}
	if(sscanf(params, "s", tmppass))
	{
		SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "KASUTUS: /login [password]");
		return 1;
	}
	OnPlayerLogin(playerid, MD5_Hash(tmppass));
	return 1;
}
How i can make that inputtext = password..

Код:
if(strcmp(MD5_Hash(tmppass),inputtext, true ) == 0)
?? Or what :S
Reply
#4

May be.. you could show the code of OnPlayerLogin? or just tell what it is exactly doing?

EDIT:
Well, may be... you try that in OnDialogResponse...
Quote:

if(dialogid == 2)
{
if(!response)
{
Kick(playerid);
}
else
{
if(!strlen(inputtext)) {
SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "KASUTUS: /login [password]");
return 1;
} else {
OnPlayerLogin(playerid,MD5_Has(inputtext));
return 1;
}
}
}

Reply
#5

Quote:
Originally Posted by Abhishek
May be.. you could show the code of OnPlayerLogin? or just tell what it is exactly doing?

EDIT:
Well, may be... you try that in OnDialogResponse...
Quote:

if(dialogid == 2)
{
if(!response)
{
Kick(playerid);
}
else
{
if(!strlen(inputtext)) {
SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "KASUTUS: /login [password]");
return 1;
} else {
OnPlayerLogin(playerid,MD5_Has(inputtext));
return 1;
}
}
}

Thank you so so much !


(u can close the thread now)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)