25.12.2012, 19:49
pawn Код:
stock LoadDoors()
{
if(!fexist("Doors.cfg")) return 1;
new
szFileStr[512],
File: iFileHandle = fopen("Doors.cfg", io_read),
iIndex, string[128];
while(iIndex < MAX_DOORS && fread(iFileHandle, szFileStr)) {
if(!sscanf(szFileStr, "p<|>ds[64]s[40]dddffffffff",
DoorData[iIndex][dExists],
DoorData[iIndex][dName],
DoorData[iIndex][dPass],
DoorData[iIndex][deVW],
DoorData[iIndex][diVW],
DoorData[iIndex][diInt],
DoorData[iIndex][dePos][0],
DoorData[iIndex][dePos][1],
DoorData[iIndex][dePos][2],
DoorData[iIndex][dePos][3],
DoorData[iIndex][diPos][0],
DoorData[iIndex][diPos][1],
DoorData[iIndex][diPos][2],
DoorData[iIndex][diPos][3]))
if(DoorData[iIndex][dExists] == 1) {
format(string, sizeof(string), "[ %s ]\n[ Press 'C' to enter the door ]", DoorData[iIndex][dName]);
DoorData[iIndex][dLabel] = Create3DTextLabel(string, COLOR_WHITE, DoorData[iIndex][dePos][0], DoorData[iIndex][dePos][1], DoorData[iIndex][dePos][2], 10.0, DoorData[iIndex][deVW], 0);
DoorData[iIndex][dPickup] = CreateDynamicPickup(1318, 23, DoorData[iIndex][dePos][0], DoorData[iIndex][dePos][1], DoorData[iIndex][dePos][2], DoorData[iIndex][deVW], 0, -1, 10.0);
DoorData[iIndex][dName] = DoorData[iIndex][dName];
DoorData[iIndex][dLoaded] = 1;
}
}
printf("%d doors loaded.", iIndex);
return fclose(iFileHandle);
}
pawn Код:
stock SaveDoors() {
new
szFileStr[512],
File: fHandle = fopen("Doors.cfg", io_write);
for(new iIndex; iIndex < MAX_DOORS; iIndex++) {
if(DoorData[iIndex][dLoaded] == 1) {
format(szFileStr, sizeof(szFileStr), "%d|%s|%s|%d|%d|%d|%f|%f|%f|%f|%f|%f|%f|%f\r\n",
DoorData[iIndex][dExists],
DoorData[iIndex][dName],
DoorData[iIndex][dPass],
DoorData[iIndex][deVW],
DoorData[iIndex][diVW],
DoorData[iIndex][diInt],
DoorData[iIndex][dePos][0],
DoorData[iIndex][dePos][1],
DoorData[iIndex][dePos][2],
DoorData[iIndex][dePos][3],
DoorData[iIndex][diPos][0],
DoorData[iIndex][diPos][1],
DoorData[iIndex][diPos][2],
DoorData[iIndex][diPos][3]
);
fwrite(fHandle, szFileStr);
}
}
return fclose(fHandle);
}
Basically, it will save all the door data, then when it tries to load, it doesn't - It print's saying it's loaded 0 doors and nothing creates in-game.
And also, for eg: You create a door in-game, save it, reload server, then it's still in the file, then you reload the server again then it like resets the doors.cfg