CheckPassword Help - 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: CheckPassword Help (
/showthread.php?tid=380324)
CheckPassword Help -
trapstar2020 - 24.09.2012
Код:
if(CheckPassword(playerid, inputtext)) <<<<<<<<<< my problem ****** gave me 0 answers to my problem how to define this????
pawn Код:
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_LOGIN)
{
if(!response) // If they clicked 'Cancel' or pressed esc
{
SendClientMessage(playerid, COLOR_RED, "You MUST login to play here. Please change your name.");
Kick(playerid);
}
else // Pressed ENTER or clicked 'Login' button
{
if(CheckPassword(playerid, inputtext))
{
SendClientMessage(playerid, COLOR_RED, "You are now logged in!");
}
else
{
SendClientMessage(playerid, COLOR_RED, "LOGIN FAILED.");
// Re-show the login dialog
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
}
}
return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
}
return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}
Re: CheckPassword Help -
trapstar2020 - 25.09.2012
bumb help plz
Re: CheckPassword Help -
Lordzy - 25.09.2012
You don't need to define it.
You can either use Whirlpool hasing or udb_checklogin method.
Here's
pawn Код:
//udb checklogin by Dracoblue.
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
Now using it.
pawn Код:
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_LOGIN)
{
if(!response) // If they clicked 'Cancel' or pressed esc
{
SendClientMessage(playerid, COLOR_RED, "You MUST login to play here. Please change your name.");
Kick(playerid);
}
else // Pressed ENTER or clicked 'Login' button
{
if(udb_hash(inputtext) == Linfo[playerid][Password]) //Replace Linfo[playerid][Password] it with your password saving.
{
SendClientMessage(playerid, COLOR_RED, "You are now logged in!");
}
else
{
SendClientMessage(playerid, COLOR_RED, "LOGIN FAILED.");
// Re-show the login dialog
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
}
}
return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
}
return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}
Re: CheckPassword Help -
trapstar2020 - 25.09.2012
not like im trying to create a password door
Re: CheckPassword Help -
Lordzy - 25.09.2012
pawn Код:
new doorpass = 1234; //Creating a password variable for the door.
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_LOGIN)
{
if(!response) // If they clicked 'Cancel' or pressed esc
{
SendClientMessage(playerid, COLOR_RED, "You MUST login to play here. Please change your name.");
Kick(playerid);
}
else // Pressed ENTER or clicked 'Login' button
{
if(inputtext == doorpass) //Detecting whether the entered text is the password of door or not.
{ //If yes, ...
SendClientMessage(playerid, COLOR_RED, "You are now logged in!");
}
else
{
SendClientMessage(playerid, COLOR_RED, "LOGIN FAILED.");
// Re-show the login dialog
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
}
}
return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
}
return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}
Re: CheckPassword Help -
YourLord - 25.09.2012
inputtext is not an integer.