How to make a password confirmation?
#1

I wanted to create a password confirmation on registration of a user using dialogs

I tried to check y_extra_users.inc which does the same but couldnt get anythng

Can anyone get me a working code that does this?

Thanks
Reply
#2

What do you mean? Showing two password dialogs after each other, or?
Reply
#3

The user enters a password at the first dialog
The server shuld show another dialog and ask the user to re-enter the password
Then it should compare the two passwords.


If same, then it registers, else it return an error


You can see this system at Crazybobs cops nd robbers server
Reply
#4

If you're willing to paste your code, I could try to make something similar.
Reply
#5

This is from ******. I dont want to include this to my gamemode but want to implement it

Код:
stock Extra_DoRegister(playerid, string:pw[])
{
	if (Player_IsLoggedIn(playerid))
	{
		Text_Send(playerid, $YSI_LOGIN_ALREADY);
		return 1;
	}
	else if (Player_IsRegistered(playerid))
	{
		//Text_Send(playerid, $YSI_LOGIN_ALREADY);
		Text_Send(playerid, $YSI_REG_TAKEN);
		Extra_DoLogin(playerid, NULL);
		return 1;
	}
	if (isnull(pw))
	{
		// Enter password.
		inline Response1(pid1, dialogid1, response1, listitem1, string:text1[])
		{
			#pragma unused listitem1, dialogid1, pid1
			if (response1)
			{
				switch (strlen(text1))
				{
					case 0:
					{
						Text_Send(playerid, $YSI_LOGIN_ENTER);
					}
					case 1:
					{
						if (isnull(text1)) Text_Send(playerid, $YSI_LOGIN_ENTER);
						else Text_Send(playerid, $YSI_LOGIN_LENGTH);
					}
					case 2 .. 5:
					{
						Text_Send(playerid, $YSI_LOGIN_LENGTH);
					}
					default:
					{
						// Can add code here to test the strength of the pass.
						Extra_DoRegister(playerid, text1);
						return 1;
					}
				}
				Extra_DoRegister(playerid, NULL);
			}
		}
		Text_PasswordBox(playerid, using inline Response1, $YSI_EXTRA_REGISTER_TITLE, $YSI_EXTRA_REGISTER_PROMPT, $DIALOG_OK, $DIALOG_CANCEL);
	}
	else
	{
		// Store the password localy in the function and get confirmation.
		new
			pass[32];
		strcpy(pass, pw);
		inline Response2(pid2, dialogid2, response2, listitem2, string:text2[])
		{
			#pragma unused listitem2, dialogid2, pid2
			if (response2)
			{
				switch (strlen(text2))
				{
					case 0:
					{
						Text_Send(playerid, $YSI_LOGIN_ENTER);
					}
					case 1:
					{
						if (isnull(text2)) Text_Send(playerid, $YSI_LOGIN_ENTER);
						else Text_Send(playerid, $YSI_LOGIN_LENGTH);
					}
					case 2 .. 5:
					{
						Text_Send(playerid, $YSI_LOGIN_LENGTH);
					}
					default:
					{
						if (strcmp(pass, text2))
						{
							Text_Send(playerid, $YSI_EXTRA_REGISTER_MISMATCH);
						}
						else
						{
							Player_TryRegister(playerid, text2);
							return 1;
						}
					}
				}
				// Try again.
				Extra_DoRegister(playerid, pass);
			}
		}
		Text_PasswordBox(playerid, using inline Response2, $YSI_EXTRA_REGISTER_TITLE, $YSI_EXTRA_CONFIRM_PROMPT, $DIALOG_OK, $DIALOG_CANCEL);
	}
	return 1;
}

YCMD:register(playerid, params[], help)
{
	if (help)
	{
		Text_Send(playerid, $YSI_REGISTER_HELP);
	}
	else
	{
		Extra_DoRegister(playerid, params);
	}
	return 1;
}
Reply
#6

I'm not telling you as the way of YSI as I haven't used it. Here's the normal way tips:

On the response of the password dialog, store that password in an array or perhaps HASH and store it. Then re-direct them to another dialog and on it's response, compare that inputtext with the array you used for storing the password using strcmp function.
Reply
#7

i already kmow that, but i'm looking for a way to get the input text from both the dialogs in one function

Can OnDialogResponse return string?
Reply
#8

Quote:
Originally Posted by Xtreme Brotherz
Посмотреть сообщение
i already kmow that, but i'm looking for a way to get the input text from both the dialogs in one function

Can OnDialogResponse return string?
That's what I said first, to assign the inputtext on an array. Here's an example:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == something) {
        format(myArray[playerid], 128, inputtext); //Stores inputtext.
    }
    if(dialogid == something2) {
        if(!strcmp(inputtext, myArray[playerid], false)) { //if both the texts are equal (case-sensitive)
        //Stuffs
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)