public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login to your account.","Type your password below to login.","Login","Quit");
return 1;
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Registering your acount.","Type your password below to register a new account.","Register","Quit");
}
return 1;
}
// The Dialog Response callback
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
new NKey[30];
format(NKey, sizeof(NKey), "%s",inputtext);
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Blank Password.","Please type your password below to register a new account.","Register","Quit");
SendClientMessage(playerid, COLOR_GREEN, "[CW:WW3] Your password can not be left blank. Please input password to register your account & proceed.");
}
new INI:File = INI_Open(UserPath(playerid));
INI_WriteString(File, "Key",NKey);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Banned",0);
INI_WriteInt(File,"DonateRank",0);
INI_WriteInt(File,"Warnings",0);
INI_WriteInt(File,"Jail",0);
INI_WriteInt(File,"JailTime",0);
INI_WriteInt(File,"Cash", 1000);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Muted",0);
INI_WriteInt(File,"Hide",0);
INI_WriteInt(File,"Spree",0);
INI_WriteInt(File,"DuelWon",0);
INI_WriteInt(File,"DuelLost",0);
INI_WriteInt(File,"Clan",0);
INI_WriteInt(File,"ClanRank",0);
INI_Close(File);
}
}
case DIALOG_CHANGEPASS:
{
new NKey[30];
format(NKey, sizeof(NKey), "%s",inputtext);
new INI:File = INI_Open(UserPath(playerid));
INI_WriteString(File, "Key", NKey);
INI_Close(File);
new str[128];
format(str, sizeof(str), "[CW:WW3] Your password has been changed to "COL_GREEN"%s",inputtext);
SendClientMessage(playerid, COLOR_RED, str);
return 1;
}
case DIALOG_LOGIN:
{
if (!response) return Kick (playerid);
if(response)
{
new NKey[30];
format(NKey, sizeof(NKey), "%s",inputtext);
if(strcmp(PlayerInfo[playerid][pKey],NKey , true) == 0)
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
SendClientMessage(playerid, COLOR_RED, ""COL_GREEN"You have successfully logged in!");
gPlayerLogged[playerid] = 1;
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
return 1;
}
}
}
//The callback which loads the user.
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_String("Key",PlayerInfo[playerid][pKey],30);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Banned",PlayerInfo[playerid][pBanned]);
INI_Int("DonateRank",PlayerInfo[playerid][pDonateRank]);
INI_Int("Warnings",PlayerInfo[playerid][pWarns]);
INI_Int("Jail",PlayerInfo[playerid][pJail]);
INI_Int("JailTime",PlayerInfo[playerid][pJailTime]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("Muted",PlayerInfo[playerid][pMuted]);
INI_Int("Hide",PlayerInfo[playerid][pHide]);
INI_Int("Spree",PlayerInfo[playerid][pSpree]);
INI_Int("DuelWon",PlayerInfo[playerid][pDuelWon]);
INI_Int("DuelLost",PlayerInfo[playerid][pDuelLost]);
INI_Int("Clan",PlayerInfo[playerid][pClan]);
INI_Int("ClanRank",PlayerInfo[playerid][pClanRank]);
return 1;
}
I am convinced that y_ini is bugged on 0.3e.
Another dude had the exact same problem in this thread: http://forum.sa-mp.com/showthread.ph...55#post1866055 INI_ParseFile wasn't parsing the file. |