26.03.2016, 05:08
Hello, so I am creating a faction system where the faction rank-names are dynamic, you set their strings in-game and they save in the faction's file. The saving works fine and the string gets written in the file properly, the problem is loading it as currently the code I used to load it is not working.
Here's the array I have to save the rank names.
Here's how I save the ranks..
I have other stuff and everything saves fine, but here's how I load it and that's where the problem occurs.
I have other variables that load aswell under that function and they load fine, those strings are the problem tho.
Help would be greatly appreciated.
PS: Just to clarify, the strings are saved properly and they are written in their files, the problem is with LOADING them into the game after restarting. Other variables under the same loading/saving functions work fine.
Here's the array I have to save the rank names.
Код:
new FactionARanks[MAX_FACTIONS][13][32];
Код:
SaveFaction(factionid) { new filename[64], line[256]; format(filename, sizeof(filename), FACTION_FILE_PATH "f%d.ini", factionid); new File:handle = fopen(filename, io_write); for(new j = 0; j < 13; j++) { format(line, sizeof(line), "FactionSkins[%d]=%d\r\n", j+1 ,FacInfo[factionid][FactionSkins][j]); fwrite(handle, line); format(line, sizeof(line), "FactionARanks[%d]=%s\r\n", j+1 ,FactionARanks[factionid][j]); fwrite(handle, line); } fclose(handle); }
Код:
LoadFactions() { new File:handle, count; new filename[64], line[256], s, key[64]; for(new i=0; i < MAX_FACTIONS; i++) { format(filename, sizeof(filename), FACTION_FILE_PATH "f%d.ini", i); if(!fexist(filename)) continue; handle = fopen(filename, io_read); while(fread(handle, line)) { StripNL(line); s = strfind(line, "="); if(!line[0] || s < 1) continue; strmid(key, line, 0, s++); for(new j = 0; j < 13; j++) { if(strcmp(key, "FactionSkins") == 0) FacInfo[i][FactionSkins][j] = strval(line[s]); else if(strcmp(key, "FactionARanks") == 0) sscanf(line[s], "s[32]", FactionARanks[i][j]); } } fclose(handle); if(FacIDTaken[i]) count++; } printf(" Loaded %d factions", count); }
Help would be greatly appreciated.
PS: Just to clarify, the strings are saved properly and they are written in their files, the problem is with LOADING them into the game after restarting. Other variables under the same loading/saving functions work fine.