How to save this enum? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to save this enum? (
/showthread.php?tid=458556)
How to save this enum? -
RALL0 - 17.08.2013
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();
Re: How to save this enum? -
gtakillerIV - 17.08.2013
pawn Код:
format(string, sizeof(string), "%d\n",
StoreInfo[id][sProducts]
To:
pawn Код:
format(string, sizeof(string), "%d\n", StoreInfo[id][sProducts]);
You forgot a closing bracket and a semicolon.
Re: How to save this enum? -
RALL0 - 17.08.2013
Ah, thanks I got rid of the errors thanks to you.