01.05.2010, 07:36
The best method is to just use the raw functions, making sure to save all variables at once.
example:
and NOT like this
Because the second method uses 'format' and 'fwrite' per variable, it has to run far more functions (assuming you have more than 2 variables to save)
example:
pawn Код:
stock save(playerid)
{
new pname[24];
GetPlayerName(playerid,pname,24);
new File:file=fopen(pname,io_write);
new string[128];
format(string,128,"Score=%d\nCash=%d",GetPlayerScore(playerid,GetPlayerMoney(playerid));
fwrite(file,string);
}
pawn Код:
stock save(playerid)
{
new pname[24];
GetPlayerName(playerid,pname,24);
new File:file=fopen(pname,io_write);
new string[128];
format(string,128,"Score=%d\n",GetPlayerScore(playerid));
fwrite(file,string);
format(string,128,"Cash=%d",GetPlayerMoney(playerid));
fwrite(file,string);
}