OnDialogResponse troubles.
#1

Hello,
I have a little problem with a login/register (not my work) system that i tried to modify to work with dialogs. If you register, its saves the password in numbers. But's thats not my problem.
If you login, he says always that your password is wrong, its doesen't matter if your uses numbers of text. Here you see my piece of script:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	new string[256];
	new passstring[128];
	new tmp2[128];
	if(dialogid == 123)
	{
   		dini_Create(udb_encode(playername));
      dini_IntSet(udb_encode(playername), "password",strval(inputtext));
      dini_IntSet(udb_encode(playername), "adminlevel", 0);
      dini_IntSet(udb_encode(playername), "money", 0);
      format(string, sizeof(string), "Account %s succesfully created. You can now log in with the password: %s.", playername, strval(inputtext));
    	SendClientMessage(playerid, COLOR_YELLOW, string);
    	ShowPlayerDialog(playerid,124,DIAL1OG_STYLE_INPUT,"Login","Welcome to the International Clan.\nThis account exist, please log in.\n\nPassword:","Login","Cancel");
     }
     else
     {
      format(string, sizeof(string), "%s already is already registered, please choose another name.", playername);
      SendClientMessage(playerid, COLOR_RED, string);
     }
   }
	if(dialogid == 124)
	{
 			tmp2 = dini_Get(udb_encode(playername), "password");
   		if (strval(inputtext) != strval(tmp2))
    		{
     		SendClientMessage(playerid, COLOR_RED, "Wrong password!");
      }
      else
      {
      	logged[playerid] = 1;
      		money[playerid] = dini_Int(udb_encode(playername), "money");
       	adminlevel[playerid] = dini_Int(udb_encode(playername), "adminlevel");
       	format(string, sizeof(string), "You are succesfully logged in as %s.", playername);
       	SendClientMessage(playerid, COLOR_GREEN, string);
       	GivePlayerMoney(playerid, money[playerid]);
     	}
		}
 		else
  	{
   		format(string, sizeof(string), "The account %s don't exist, please create it.", playername);
    		SendClientMessage(playerid, COLOR_RED, string);
    		ShowPlayerDialog(playerid,123,DIALOG_STYLE_INPUT,"Create an account","Welcome to the International Roleplay Clan.\nYou don't have an account on this server\n Please create one by typing your new password below\n\nPassword:","Create","Cancel");
    	}}}
    	

#endif
I get no errors if i tty to compile it, please help me with this.
Greetz,
sean5874
Reply
#2

Quote:
Originally Posted by sean5874
Hello,
I have a little problem with a login/register (not my work) system that i tried to modify to work with dialogs. If you register, its saves the password in numbers. But's thats not my problem.
If you login, he says always that your password is wrong, its doesen't matter if your uses numbers of text. Here you see my piece of script:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	new string[256];
	new passstring[128];
	new tmp2[128];
	if(dialogid == 123)
	{
   		dini_Create(udb_encode(playername));
      dini_IntSet(udb_encode(playername), "password",strval(inputtext));
      dini_IntSet(udb_encode(playername), "adminlevel", 0);
      dini_IntSet(udb_encode(playername), "money", 0);
      format(string, sizeof(string), "Account %s succesfully created. You can now log in with the password: %s.", playername, strval(inputtext));
    	SendClientMessage(playerid, COLOR_YELLOW, string);
    	ShowPlayerDialog(playerid,124,DIAL1OG_STYLE_INPUT,"Login","Welcome to the International Clan.\nThis account exist, please log in.\n\nPassword:","Login","Cancel");
     }
     else
     {
      format(string, sizeof(string), "%s already is already registered, please choose another name.", playername);
      SendClientMessage(playerid, COLOR_RED, string);
     }
   }
	if(dialogid == 124)
	{
 			tmp2 = dini_Get(udb_encode(playername), "password");
   		if (strval(inputtext) != strval(tmp2))
    		{
     		SendClientMessage(playerid, COLOR_RED, "Wrong password!");
      }
      else
      {
      	logged[playerid] = 1;
      		money[playerid] = dini_Int(udb_encode(playername), "money");
       	adminlevel[playerid] = dini_Int(udb_encode(playername), "adminlevel");
       	format(string, sizeof(string), "You are succesfully logged in as %s.", playername);
       	SendClientMessage(playerid, COLOR_GREEN, string);
       	GivePlayerMoney(playerid, money[playerid]);
     	}
		}
 		else
  	{
   		format(string, sizeof(string), "The account %s don't exist, please create it.", playername);
    		SendClientMessage(playerid, COLOR_RED, string);
    		ShowPlayerDialog(playerid,123,DIALOG_STYLE_INPUT,"Create an account","Welcome to the International Roleplay Clan.\nYou don't have an account on this server\n Please create one by typing your new password below\n\nPassword:","Create","Cancel");
    	}}}
    	

#endif
I get no errors if i tty to compile it, please help me with this.
Greetz,
sean5874
replace:
Код:
dini_IntSet(udb_encode(playername), "password",strval(inputtext));
with:
Код:
dini_Set(file,"Password",inputtext);
than maybe will be better
Reply
#3

pawn Код:
dini_IntSet(udb_encode(playername), "password",udb_hash(inputtext));
that will hash your password so it will be saver
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)