28.05.2014, 14:38
I am making a rep system for my server using y_ini The data saves nicely But when i Restart the server or change something is Scriptfiles Then it goes back to zero
Here it is :-
Please help me I am New with y_ini
Here it is :-
Код:
Reputation
#define UserPath "reputation/%s.ini"
enum PlayerInfo
{
Reputation,
}
new pInfo[MAX_PLAYERS][PlayerInfo];
stock Path(playerid)
{
new str[128],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),UserPath,name);
return str;
}
forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
INI_Int("Reputation",pInfo[playerid][Reputation]);
return 1;
}
In on player connect :-
new name[128];
GetPlayerName(playerid,name,sizeof(name));
if(fexist(Path(name)))
{
INI_ParseFile(Path(name),"loadaccount_%s", .bExtra = true, .extra = playerid);
}
else
{
return 1;
}
On player disconnect Reputation
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteInt(file,"Reputation",pInfo[playerid][Reputation]);
INI_Close(file);


anything else ?