How to save this enum?
#1

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();
Reply
#2

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.
Reply
#3

Ah, thanks I got rid of the errors thanks to you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)