11.04.2012, 08:49
Hello, My Faction system won't detect the faction type, which means I have to use /fedit all the time when I should only be needing to use it once.
pawn Код:
SaveFactions()
{
new idx;
new File: file2;
while (idx < sizeof(FactionInfo))
{
new coordsstring[512];
format(coordsstring, sizeof(coordsstring), "%s|%s|%s|%s|%s|%s|%s|%s|%s|%d|%d\r\n",
FactionInfo[idx][FactionName],
FactionInfo[idx][FactionMOTD],
FactionInfo[idx][FactionLeader],
FactionInfo[idx][FactionRank1],
FactionInfo[idx][FactionRank2],
FactionInfo[idx][FactionRank3],
FactionInfo[idx][FactionRank4],
FactionInfo[idx][FactionRank5],
FactionInfo[idx][FactionRank6],
FactionInfo[idx][FactionType],
FactionInfo[idx][FactionSlot]);
if(idx == 0)
{
file2 = fopen("Configs/factions.cfg", io_write);
}
else
{
file2 = fopen("Configs/factions.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
LoadFactions()
{
new arrCoords[12][64];
new strFromFile2[512];
new File: file = fopen("Configs/factions.cfg", io_read);
if(file)
{
new idx;
while (idx < sizeof(FactionInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
strmid(FactionInfo[idx][FactionName], arrCoords[0], 0, strlen(arrCoords[0]), 255);
strmid(FactionInfo[idx][FactionMOTD], arrCoords[1], 0, strlen(arrCoords[1]), 255);
strmid(FactionInfo[idx][FactionLeader], arrCoords[2], 0, strlen(arrCoords[2]), 255);
strmid(FactionInfo[idx][FactionRank1], arrCoords[3], 0, strlen(arrCoords[3]), 255);
strmid(FactionInfo[idx][FactionRank2], arrCoords[4], 0, strlen(arrCoords[4]), 255);
strmid(FactionInfo[idx][FactionRank3], arrCoords[5], 0, strlen(arrCoords[5]), 255);
strmid(FactionInfo[idx][FactionRank4], arrCoords[6], 0, strlen(arrCoords[6]), 255);
strmid(FactionInfo[idx][FactionRank5], arrCoords[7], 0, strlen(arrCoords[7]), 255);
strmid(FactionInfo[idx][FactionRank6], arrCoords[8], 0, strlen(arrCoords[8]), 255);
strmid(FactionInfo[idx][FactionType] = strval(arrCoords[10]);
strmid(FactionInfo[idx][FactionSlot] = strval(arrCoords[11]);
printf("[Dynamic Faction] Faction Name: %s, Type: %d, Slot: %d, ID: %d",FactionInfo[idx][FactionName],FactionInfo[idx][FactionType],FactionInfo[idx][FactionSlot],idx);
idx++;
}
fclose(file);
}
return 1;
}