08.02.2018, 21:04
Something is badly saved and loaded in a file. Will anyone help me?
Код:
LoadZones() { new PartOfString[12][64]; new FileString[128]; new File: file = fopen("TurfWar/Turfs/GWturfs.ini", io_read); if (file) { new idx; while (idx < sizeof(g_Turf)-1) while (idx < sizeof(g_Team)-1) { fread(file, FileString); split(FileString, PartOfString, ','); g_Turf[idx][turfId] = strval(PartOfString[0]); strmid(g_Team[idx][teamName], PartOfString[1], 0, strlen(PartOfString[1]), MAX_PLAYER_NAME); g_Turf[idx][turfOwner] = strval(PartOfString[2]); g_Team[idx][teamColor] = strval(PartOfString[3]); printf("ZoneID: %d ZoneOwner: %s ZoneOwnerID: %d Colour: %d", g_Turf[idx][turfId], g_Team[idx][teamName], g_Turf[idx][turfOwner], g_Team[idx][teamColor] ); idx++; } fclose(file); } return 1; } SaveZones() { new idx; new File: file2; while (idx < sizeof(g_Turf)) while (idx < sizeof(g_Team)) { new FileString[128]; format(FileString, sizeof(FileString), "%d,%s,%d,%d\r\n", g_Turf[idx][turfId], g_Team[idx][teamName], g_Turf[idx][turfOwner], g_Team[idx][teamColor] ); print(FileString); if(idx == 0) file2 = fopen("TurfWar/Turfs/GWturfs.ini", io_write); else file2 = fopen("TurfWar/Turfs/GWturfs.ini", io_append); fwrite(file2, FileString); idx++; fclose(file2); } return 1; }