15.04.2014, 18:22
Quote:
This works perfectly for me.
pawn Код:
|
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == REGISTER_REGISTER)
{
if(!response)
{
Kick(playerid);
}
if(response)
{
if(!strlen(inputtext))
{
SCM(playerid,COLOR_RED, "You must enter a password to register a account.");
ShowPlayerDialog(playerid, REGISTER_REGISTER, DIALOG_STYLE_INPUT, "Please register a account.", "Register", "Enter", "Leave");
return 1;
}
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player Data");
INI_WriteString(file,"Password",hashpass);
INI_WriteInt(file, "Kills", 0);
INI_WriteInt(file, "Deaths", 0);
INI_WriteInt(file, "Vip", 0);
INI_WriteInt(file, "Admin", 0);
INI_Close(file);
new string[128];
format(string,sizeof(string), "You've registered at Highschool Roleplay with the password %s", inputtext);
SCM(playerid,COLOR_GREEN, string);
ShowPlayerDialog(playerid,REGISTER_LOGIN,DIALOG_STYLE_INPUT,"Login","Enter your password to login.","Login","Quit");
}
}
if(dialogid == REGISTER_LOGIN)
{
if(!response) return Kick(playerid);
if(response)
{
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
if(!strcmp(hashpass, pInfo[playerid][pPass]))
{
INI_ParseFile(Path(playerid),"LoadAccount_%s",.bExtra = true, .extra = playerid);
SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");
}
else
{
ShowPlayerDialog(playerid,REGISTER_LOGIN,DIALOG_STYLE_INPUT,"Login","Incorrect Password.","Login","Quit");
return 1;
}
}
}
return 1;
}