Hello, so I recently switched up to using y_ini, and can someone please explain to me the 'INI_ParseFile' function, because I just don't get it in the topics. I'm trying to make the log in part of this code.
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case REGISTER_DIALOG:
{
if(!response) return Kick(playerid);
else if(!strlen(inputtext))
{
new DiStr[200];
format(DiStr, sizeof(DiStr), "{FFFFFF}Welcome {00C0FF}%s(%d){FFFFFF} to the server, you're {F81414}not{FFFFFF} registered\n\nPlease log in by inputting your password.", ReturnName(playerid), playerid);
ShowPlayerDialog(playerid, REGISTER_DIALOG, DIALOG_STYLE_INPUT, "{FFFFFF}Register", DiStr, "Register", "Leave");
}
else
{
new pFilePath[200], WPHash[129];
WP_Hash(WPHash, sizeof(WPHash), inputtext);
format(pFilePath, sizeof(pFilePath), PLAYER_FILE, ReturnName(playerid));
new INI:pFile = INI_Open(pFilePath);
INI_SetTag(pFile, "UserData");
INI_WriteString(pFile, "Name", ReturnName(playerid));
INI_WriteString(pFile, "PasswordHash", WPHash);
INI_WriteString(pFile, "Callsign", ReturnName(playerid)), format(P_DATA[playerid][Callsign], 64, "%s", ReturnName(playerid));
INI_WriteInt(pFile, "AdminLevel", 0), P_DATA[playerid][AdminLevel] = 0;
INI_WriteBool(pFile, "VIP", false), P_DATA[playerid][VIP] = false;
INI_WriteInt(pFile, "Deaths", 0), P_DATA[playerid][Deaths] = 0;
INI_WriteInt(pFile, "Money", 0), P_DATA[playerid][Money] = 0;
INI_WriteInt(pFile, "Score", 0), P_DATA[playerid][Score] = 0;
INI_WriteBool(pFile, "Jailed", false), P_DATA[playerid][Jailed] = false;
INI_WriteInt(pFile, "JailTime", 0), P_DATA[playerid][JailTime] = 0;
INI_WriteBool(pFile, "Muted", false), P_DATA[playerid][Muted] = false;
INI_WriteInt(pFile, "MuteTime", 0), P_DATA[playerid][MuteTime] = 0;
INI_WriteBool(pFile, "Frozen", false), P_DATA[playerid][Frozen] = false;
INI_WriteInt(pFile, "FreezeTime", 0), P_DATA[playerid][FreezeTime] = 0;
INI_WriteInt(pFile, "days", 0), P_DATA[playerid][days] = 0;
INI_WriteInt(pFile, "hours", 0), P_DATA[playerid][hours] = 0;
INI_WriteInt(pFile, "minutes", 0), P_DATA[playerid][minutes] = 0;
INI_WriteInt(pFile, "seconds", 0), P_DATA[playerid][seconds] = 0;
INI_Close(pFile);
new JoinMessage[128];
format(JoinMessage, sizeof(JoinMessage), "{80FF00}%s({FFFFFF}%i{80FF00}){FFFFFF} has connected to the server for the first time!", ReturnName(playerid), playerid);
SendClientMessageToAll(COLOR_WHITE, JoinMessage);
printf("Registering player %s(%d)!", ReturnName(playerid), playerid);
}
}
case LOGIN_DIALOG:
{
}
}
return 1;
}
That would be so much easier. Oh, and Y_Less if you happen to read this topic, would you consider adding that type of reading for Y_INI?
You can't just do ReadInt like in Dini. You'll need to use INI_ParseFile on a callback.
Check Y_Less's tutorial for y_ini. He explains it very well.