#define DIALOG_REGISTER 0
#define DIALOG_LOGIN 1
#define DIALOG_QUIT 2
#define DIALOG_PASSLEN 3
#define DIALOG_WRONGPASS 4
public OnPlayerConnect(playerid)
{
new PlrFile[128];
format(PlrFile, sizeof(PlrFile), "/Users/%s.txt", RetPlrName(playerid));
if(!fexist(PlrFile))
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registration", "Please type your future password below:", "Register", "Cancel");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Logging-in", "Please type your password below:", "Login", "Cancel");
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REGISTER)
{
if(response == 0)
{
ShowPlayerDialog(playerid, DIALOG_QUIT, DIALOG_STYLE_MSGBOX, "Cancelled", "Use /q to exit", "OK", "");
Kick(playerid);
}
else if(response == 1)
{
new KeyLen = strlen(inputtext);
if(KeyLen <= 5 || KeyLen >= 33)
{
ShowPlayerDialog(playerid, DIALOG_PASSLEN, DIALOG_STYLE_MSGBOX, "Notice", "The password must be between 6 and 32 symbols", "OK", "");
}
else
{
new PlrFile[128], File:PlrFileOpen;
format(PlrFile, sizeof(PlrFile), "/Users/%s.txt", RetPlrName(playerid));
PlrFileOpen = fopen(PlrFile, io_write);
fwrite(PlrFileOpen, inputtext);
fclose(PlrFileOpen);
}
}
}
else if(dialogid == DIALOG_LOGIN)
{
if(response == 0)
{
ShowPlayerDialog(playerid, DIALOG_QUIT, DIALOG_STYLE_MSGBOX, "Cancelled", "Use /q to exit", "OK", "");
Kick(playerid);
}
else if(response == 1)
{
new PlrFile[128], File:PlrFileOpen, pass[128];
format(PlrFile, sizeof(PlrFile), "/Users/%s.txt", RetPlrName(playerid));
PlrFileOpen = fopen(PlrFile, io_read);
fread(PlrFileOpen, pass);
if(strcmp(inputtext, pass, false, 32))
{
SendClientMessage(playerid, 0xFFFFFFAA, "You have successfully logged-in");
}
else
{
ShowPlayerDialog(playerid, DIALOG_WRONGPASS, DIALOG_STYLE_MSGBOX, "Error", "You have typed wrong password", "OK", "");
}
fclose(PlrFileOpen);
}
}
else if(dialogid == DIALOG_PASSLEN)
{
if(response == 1)
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registration", "Please type your future password below:", "Register", "Cancel");
}
}
else if(dialogid == DIALOG_WRONGPASS)
{
if(response == 1)
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Logging-in", "Please type your password below:", "Login", "Cancel");
}
}
return 1;
}
Guy use [PAWN] not [PHP]
try this IF you want i have create one > There is my system try to compare it with ur code And Can someone help meHERE |
else if(dialogid == DIALOG_LOGIN)
{
if(!response)
{
ShowPlayerDialog(playerid, DIALOG_QUIT, DIALOG_STYLE_MSGBOX, "Cancelled", "Use /q to exit", "OK", "");
Kick(playerid);
}
else if(response)
{
new PlrFile[128], File:PlrFileOpen, pass[128];
format(PlrFile, sizeof(PlrFile), "/Users/%s.txt", RetPlrName(playerid));
PlrFileOpen = fopen(PlrFile, io_read);
fread(PlrFileOpen, pass);
if(!strcmp(inputtext, pass, false, 32))
{
SendClientMessage(playerid, 0xFFFFFFAA, "You have successfully logged-in");
}
else
{
ShowPlayerDialog(playerid, DIALOG_WRONGPASS, DIALOG_STYLE_MSGBOX, "Error", "You have typed wrong password", "OK", "");
}
fclose(PlrFileOpen);
}
}
Does this work?
Strcmp actually returns 0 if the two strings are the same. !Strcmp will counter it. pawn Код:
|