SA-MP Forums Archive
INI problem - 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: INI problem (/showthread.php?tid=403593)



INI problem - MattSlater - 30.12.2012

pawn Код:
stock LoadDoors()
{
    if(!fexist("Doors.cfg")) return 1;

    new szFileStr[1024], d, File: iFileHandle = fopen("Doors.cfg", io_read);
   
    while(d < MAX_DOORS && fread(iFileHandle, szFileStr)) {
        if(!sscanf(szFileStr, "p<|>s[64]s[40]dddffffffff",
        DoorData[d][dName],
        DoorData[d][dPass],
        DoorData[d][deVW],
        DoorData[d][diVW],
        DoorData[d][diInt],
        DoorData[d][dePos][0],
        DoorData[d][dePos][1],
        DoorData[d][dePos][2],
        DoorData[d][dePos][3],
        DoorData[d][diPos][0],
        DoorData[d][diPos][1],
        DoorData[d][diPos][2],
        DoorData[d][diPos][3]) && DoorData[d][deVW] == 0) createDoor(d++); printf("%d doors loaded", d);
    }
    return fclose(iFileHandle);
}
Help, it doesn't load, any idea why? It just says 0 doors loaded.

Save code;
pawn Код:
stock SaveDoors()
{
    new szFileStr[1024], File: fHandle = fopen("Doors.cfg", io_write);
    for(new d = 0; d < MAX_DOORS; d++) {
        format(szFileStr, sizeof(szFileStr), "%s|%s|%d|%d|%d|%f|%f|%f|%f|%f|%f|%f|%f|%d\r\n",
        DoorData[d][dName],
        DoorData[d][dPass],
        DoorData[d][deVW],
        DoorData[d][diVW],
        DoorData[d][diInt],
        DoorData[d][dePos][0],
        DoorData[d][dePos][1],
        DoorData[d][dePos][2],
        DoorData[d][dePos][3],
        DoorData[d][diPos][0],
        DoorData[d][diPos][1],
        DoorData[d][diPos][2],
        DoorData[d][diPos][3]);
        fwrite(fHandle, szFileStr);
    }
    return fclose(fHandle);
}



Re: INI problem - Hiddos - 30.12.2012

Well you could try this:

pawn Код:
stock LoadDoors()
{
    if(!fexist("Doors.cfg")) return 1;

    new szFileStr[1024], d, File: iFileHandle = fopen("Doors.cfg", io_read);
   
    while(d < MAX_DOORS && fread(iFileHandle, szFileStr)) {
        if(!sscanf(szFileStr, "p<|>s[64]s[40]dddffffffff",
        DoorData[d][dName],
        DoorData[d][dPass],
        DoorData[d][deVW],
        DoorData[d][diVW],
        DoorData[d][diInt],
        DoorData[d][dePos][0],
        DoorData[d][dePos][1],
        DoorData[d][dePos][2],
        DoorData[d][dePos][3],
        DoorData[d][diPos][0],
        DoorData[d][diPos][1],
        DoorData[d][diPos][2],
        DoorData[d][diPos][3]))
        {
            if(DoorData[d][deVW] == 0)
            {
                createDoor(d); //Not sure which of these should go first, but this seems the most logical
                d++;
            }
        }
    }
    printf("%d doors loaded", d);
    return fclose(iFileHandle);
}
In your current code the 'd' variable never goes up. The following:
pawn Код:
createDoor(d++);
Actually means:
pawn Код:
createDoor(d + 1);
Whereas what you're trying to do is:
pawn Код:
createDoor(d);
d++;
Also I split the if(...) statement in two statements as the second part was dependent on the sscanf in the first part and I'm not too sure about how that works out normally speaking (should work out just fine btw)


Re: INI problem - MattSlater - 30.12.2012

Didn't work ;/


Re: INI problem - MattSlater - 30.12.2012

It work's!
But when I save the doorsand rcon gmxthen load it etc, then rcon gmx, it doesn't save the door name


Re: INI problem - MattSlater - 31.12.2012

anyone :/


Re: INI problem - Dragonborn - 31.12.2012

i don't sure if it works but...

Try to remove the last placeholder (%d) on the format of the save stock... This :
pawn Код:
format(szFileStr, sizeof(szFileStr), "%s|%s|%d|%d|%d|%f|%f|%f|%f|%f|%f|%f|%f|%d\r\n"
because have 14 placeholders and 13 vars in the format function...


i think is not the problem but doesn't hurt to try


Re: INI problem - MattSlater - 31.12.2012

Didn't fix the problem ;/


Re: INI problem - Dragonborn - 31.12.2012

Hm...

Can you explain the problem again ?


Re: INI problem - MattSlater - 31.12.2012

I create a door, then I reload the server(auto saves) and it load's perfectly fine, then I reload the server again, and it loads but the door name is missing and in the file it's just "" - It's blank.


Re: INI problem - Dragonborn - 31.12.2012

The name are the only is missing ("") ?