31.05.2015, 05:34
For some reason it writes my stats in the ini file upside down.
Код:
[Player's Data] Deaths = 0 Kills = 0 VIP = 0 Money = 0 Score = 0 Admin = 5 Password = 988EEC2A02039635B6836CE3700EDA7DB441BE8B4675492A53C20A70CDA2A75C9852FB52DDFF2A0F51BB4A3E1EA46A228B36542B6E9F439382806E3AA80F3260
pawn Код:
public loadaccount_user(playerid, name[], value[])
{
INI_String("Password", pInfo[playerid][Pass],129);
INI_Int("Admin",pInfo[playerid][Admin]);
INI_Int("Score",pInfo[playerid][Score]);
INI_Int("Money",pInfo[playerid][Money]);
INI_Int("VIP",pInfo[playerid][VIP]);
INI_Int("Kills",pInfo[playerid][Kills]);
INI_Int("Deaths",pInfo[playerid][Deaths]);
return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteInt(file,"Admin",pInfo[playerid][Admin]);
INI_WriteInt(file,"Score",GetPlayerScore(playerid));
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
INI_WriteInt(file,"VIP",pInfo[playerid][VIP]);
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);
INI_Close(file);
return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == register)
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid,register,DIALOG_STYLE_PASSWORD,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
return 1;
}
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteString(file,"Password",hashpass);
INI_WriteInt(file,"Admin",0);
INI_WriteInt(file,"Score",0);
INI_WriteInt(file,"Money",0);
INI_WriteInt(file,"VIP",0);
INI_WriteInt(file,"Kills",0);
INI_WriteInt(file,"Deaths",0);
INI_Close(file);
INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
SendClientMessage(playerid,-1,"You have been successfully registered");
return 1;
}
}
if(dialogid == login)
{
if(!response) return Kick(playerid);
if(response)
{
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
if(!strcmp(hashpass, pInfo[playerid][Pass], false))
{
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
SetPlayerScore(playerid,pInfo[playerid][Score]);
GivePlayerMoney(playerid,pInfo[playerid][Money]);
SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");
}
else
{
ShowPlayerDialog(playerid,login,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
return 1;
}
}
}
return 1;
}