17.08.2013, 13:45
Hey, I got enum for stores so it saves the amount of products in the store, so this is my code attempt.
pawn Код:
enum sInfo
{
sProducts,
};
new StoreInfo[MAX_STORES][sInfo];
SaveStoreSafe()
{
new id;
new File: file2;
while (id< sizeof(StoreInfo))
{
new string[20];
format(string, sizeof(string), "%d\n", //Error line: error 001: expected token: ",", but found "if"
StoreInfo[id][sProducts] //Error line: error 001: expected token: ",", but found "if"
if(id == 0) //Error line: error 001: expected token: ",", but found "if"
{
file2 = fopen("StoreSafe.cfg", io_write);
}
else
{
file2 = fopen("StoreSafe.cfg", io_append);
}
fwrite(file2, string);
id++;
fclose(file2);
}
return 1;
}
LoadStoreSafe()
{
if(!fexist("StoreSafe.cfg")) return 1;
new string[20], id, File: storefile = fopen("StoreSafe.cfg", io_read);
while (id< sizeof(StoreInfo) && fread(storefile, string))
{
sscanf(string, "p<|>i",
StoreInfo[id][sProducts]
);
++id;
}
return fclose(storefile);
}
// Under OnGameModeInit
LoadStoreSafe();
// Under a command
SaveStoreSafe();