22.01.2012, 19:42
Well, I'm having a problem with the ParseFile function in my user system..
I have this;
The ParseFile doesn't seem to be working, the password saves correctly to my file, but if I have:
It will let any password log in.
but, if I do:
It works properly.
What's wrong? I really need to get this working, and I can't seem to figure it out.
I have this;
pawn Код:
enum pData
{
Password[64]
}
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_String( "Password", p_Data[playerid][Password], 64);
return 1;
}
pawn Код:
stock FetchTheirAccountLocation(playerid)
{
new
string[MAX_PLAYER_NAME],
p_Name[MAX_PLAYER_NAME]
;
GetPlayerName(playerid, p_Name, sizeof(p_Name));
format(string, sizeof(string), USERDATA_PATH, p_Name);
return string;
}
pawn Код:
public OnPlayerConnect(playerid)
{
if(fexist( FetchTheirAccountLocation(playerid) )) {
INI_ParseFile(FetchTheirAccountLocation(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, d_Login, DIALOG_STYLE_PASSWORD, "{009AC9}Welcome back!", "{FFFFFF}Please type your {2A9107}password {FFFFFF}below to access your account information!", "Connect", "Quit");
}
else {
ShowPlayerDialog(playerid, d_Register, DIALOG_STYLE_PASSWORD, "{009AC9}Welcome!", "{FFFFFF}Please type your {2A9107}password {FFFFFF}below to create your account and {2A9107}save {FFFFFF}your information!", "Join", "Quit");
}
p_LoggedIn{playerid} = false;
return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case d_Register: {
if(response) { //They clicked Register!
if(!strlen(inputtext))
return ShowPlayerDialog(playerid, d_Register, DIALOG_STYLE_PASSWORD, "{009AC9}Welcome!", "{FFFFFF}Please type your {2A9107}password {FFFFFF}below to create your account and {2A9107}save {FFFFFF}your information!", "Join", "Quit");
new
INI:AccountData = INI_Open(FetchTheirAccountLocation(playerid))
;
INI_SetTag(AccountData, "Account Data");
new pwStr[64];
format(pwStr, 64, "%s", inputtext);
p_Data[playerid][Password] = pwStr;
INI_WriteString(AccountData,"Password", pwStr);
INI_Close(AccountData);
p_LoggedIn{playerid} = true;
}
else {
SendClientMessage(playerid, COLOR_ERROR, "Sorry! You are required to register before playing!");
return Kick(playerid);
}
}
case d_Login: {
if(!response) {
SendClientMessage(playerid, COLOR_ERROR, "Sorry! You are required to register before playing!");
return Kick(playerid);
}
if(!strlen(inputtext))
return ShowPlayerDialog(playerid, d_Login, DIALOG_STYLE_PASSWORD, "{009AC9}Welcome back!", "{FFFFFF}Please type your {2A9107}password {FFFFFF}below to access your account information!", "Connect", "Quit");
if(strcmp(inputtext, p_Data[playerid][Password], true) == 0) {
INI_ParseFile(FetchTheirAccountLocation(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
}
else return ShowPlayerDialog(playerid, d_Login, DIALOG_STYLE_PASSWORD, "{009AC9}Welcome back!", "{FFFF00}You have entered an incorrect password!\n{FFFFFF}Please type your {2A9107}password {FFFFFF}below to access your account information!", "Connect", "Quit");
}
}
return 1;
}
pawn Код:
if(strcmp(inputtext, p_Data[playerid][Password], true) == 0) {
but, if I do:
pawn Код:
if(strcmp(inputtext, "test", true) == 0) {
What's wrong? I really need to get this working, and I can't seem to figure it out.