INI problem
#1

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

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

Didn't work ;/
Reply
#4

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

anyone :/
Reply
#6

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

Didn't fix the problem ;/
Reply
#8

Hm...

Can you explain the problem again ?
Reply
#9

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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)