enum pData
{
Password[64]
}
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_String( "Password", p_Data[playerid][Password], 64);
return 1;
}
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;
}
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;
}
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;
}
if(strcmp(inputtext, p_Data[playerid][Password], true) == 0) {
if(strcmp(inputtext, "test", true) == 0) {
https://sampforum.blast.hk/showthread.php?tid=273088
works for me |
How are "Account Data" and "data" the same thing? I REALLY need to finish my new y_ini tutorial for slow people with nice big pictures showing that if you WRITE a tag then READ that tag, they need to be THE SAME, as that for some reason is the hardest thing for people to grasp!
Or just use y_users and y_uvar, which require no effort at all. |
you make your releases sometimes a little complex for new people.
|
you make your releases sometimes a little complex for new people.
|