I'm having troubles with my login dialog. -
ivndosos - 22.01.2018
Hi, I'm having issues with a filterscript I've made using newbienoob's tutorial, So my problem is that I can login with whatever pass I want, and I've once tried set my score through the .ini file but when I logged it it was still 0.
What part of the code should I show you guys?
Re: I'm having troubles with my login dialog. -
ivndosos - 22.01.2018
just bumping this.. kinda need help, i've searched around for solutions didn't really find anything.
Re: I'm having troubles with my login dialog. -
RowdyrideR - 22.01.2018
You better show us the codes then
Re: I'm having troubles with my login dialog. -
ivndosos - 22.01.2018
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == dialogregister)
{
if(!response) return Kick(playerid);
if(response)
{
ShowPlayerDialog(playerid, dialogregister, DIALOG_STYLE_INPUT, "Server", "Welcome to LSDB!\nThis account is NOT registered\nPlease insert your password below in order to create an account.", "Register", "Quit");
return 1;
}
new hashpass[129];
WP_Hash(hashpass, sizeof(hashpass), inputtext);
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player Information");
INI_WriteString(file, "Password", hashpass);
INI_WriteInt(file, "AdminLevel", 0);
INI_WriteInt(file, "Money", 100);
INI_WriteInt(file, "Score", 0);
INI_WriteInt(file, "Kills", 0);
INI_WriteInt(file, "Deaths", 0);
INI_Close(file);
SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You have successfully registered an account!");
return 1;
}
if(dialogid == dialoglogin)
{
if(!response) return Kick(playerid);
if(response)
{
new hashpass[129];
WP_Hash(hashpass, sizeof(hashpass), inputtext);
if(strcmp(hashpass, pInfo[playerid][Pass], true))
{
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
SetPlayerScore(playerid, pInfo[playerid][Score]);
GivePlayerMoney(playerid, pInfo[playerid][Money]);
SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You have successfully logged in! You can start playing now.");
}
else
{
ShowPlayerDialog(playerid, dialoglogin, DIALOG_STYLE_INPUT, "Server", "{FF0000}You have entered an invalid password!\nPlease retry again.","Login","Quit");
return 1;
}
}
}
return 1;
}
Re: I'm having troubles with my login dialog. -
Rolux - 22.01.2018
You should check the password like this:
Код:
if(!strcmp(hashpass, pInfo[playerid][Pass], false))
because the strcmp function returns 0 when the 2 strings match each other.
Re: I'm having troubles with my login dialog. -
ivndosos - 22.01.2018
same problem
Re: I'm having troubles with my login dialog. -
Rolux - 22.01.2018
Could you show me your OnPlayerConnect callback?
Re: I'm having troubles with my login dialog. -
ivndosos - 22.01.2018
sure
Код:
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(fexist(Path(playerid)))
{
INI_ParseFile(Path(playerid), "loadaccount_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, dialoglogin, DIALOG_STYLE_INPUT, "Server", "Welcome back! This account is registered\nPlease type your password below in order to login","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, dialogregister, DIALOG_STYLE_INPUT, "Server", "Welcome to LSDB!\nThis account is NOT registered\nPlease insert your password below in order to create an account.", "Register", "Quit");
return 1;
}
return 1;
}
Re: I'm having troubles with my login dialog. -
Rolux - 22.01.2018
You should change
Код:
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
to:
Код:
INI_ParseFile(Path(playerid),"loadaccount_user",.bExtra = true, .extra = playerid);
Re: I'm having troubles with my login dialog. -
ivndosos - 22.01.2018
Doesn't work, and by the way when I put a password in the register dialog nothing happens it just reappears again and again, and when I relog it shows login dialog it says wrong password for w/e pass I use..
heres the edited code
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == dialogregister)
{
if(!response) return Kick(playerid);
if(response)
{
ShowPlayerDialog(playerid, dialogregister, DIALOG_STYLE_INPUT, "Server", "Welcome to LSDB!\nThis account is NOT registered\nPlease insert your password below in order to create an account.", "Register", "Quit");
return 1;
}
new hashpass[129];
WP_Hash(hashpass, sizeof(hashpass), inputtext);
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player Information");
INI_WriteString(file, "Password", hashpass);
INI_WriteInt(file, "AdminLevel", 0);
INI_WriteInt(file, "Money", 100);
INI_WriteInt(file, "Score", 0);
INI_WriteInt(file, "Kills", 0);
INI_WriteInt(file, "Deaths", 0);
INI_Close(file);
SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You have successfully registered an account!");
return 1;
}
if(dialogid == dialoglogin)
{
if(!response) return Kick(playerid);
if(response)
{
new hashpass[129];
WP_Hash(hashpass, sizeof(hashpass), inputtext);
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, dialoglogin, DIALOG_STYLE_INPUT, "Server", "{FF0000}You have entered an invalid password!\nPlease retry again.","Login","Quit");
{
INI_ParseFile(Path(playerid),"loadaccount_user",.bExtra = true, .extra = playerid);
SetPlayerScore(playerid, pInfo[playerid][Score]);
GivePlayerMoney(playerid, pInfo[playerid][Money]);
SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You have successfully logged in! You can start playing now.");
}
{
ShowPlayerDialog(playerid, dialoglogin, DIALOG_STYLE_INPUT, "Server", "{FF0000}You have entered an invalid password!\nPlease retry again.","Login","Quit");
return 1;
}
}
}
return 1;
}