10.06.2012, 19:52
Hey, another problem with my faction system. Basically I use /createfaction in game and it creates. However I then use the same command to make a different faction and it overwrites the first file. Anyone spot the problem?
Creating the faction
Loading them.
Creating the faction
pawn Код:
stock CreateFaction(FName[])
{
for(new i = 1; i < MAX_FACTIONS; i++)
{
new Factionfile[256];
format(Factionfile, sizeof(Factionfile), "factions/Faction_%d.ini", i);
dini_Create(Factionfile);
dini_Set(Factionfile, "FactionName", FName);
dini_Set(Factionfile, "FactionRank1", "Default");
dini_Set(Factionfile, "FactionRank2", "Default");
dini_Set(Factionfile, "FactionRank3", "Default");
dini_Set(Factionfile, "FactionRank4", "Default");
dini_Set(Factionfile, "FactionRank5", "Default");
dini_Set(Factionfile, "FactionRank6", "Default");
dini_Set(Factionfile, "FactionRank7", "Default");
printf("[SYSTEM] Faction created: %s", FName);
}
return LoadFactions();
}
pawn Код:
stock LoadFactions()
{
new Factionfile[256];
for(new i = 1; i < MAX_FACTIONS; i++)
{
format(Factionfile, sizeof(Factionfile), "factions/Faction_%d.ini", i);
if(fexist(Factionfile) )
{
format(Faction[i][FactionName], MAX_STRING, "%s",dini_Get(Factionfile, "FactionName" ));
format(Faction[i][FactionRank1], MAX_STRING, "%s",dini_Get(Factionfile, "FactionRank1" ));
format(Faction[i][FactionRank2], MAX_STRING, "%s",dini_Get(Factionfile, "FactionRank2" ));
format(Faction[i][FactionRank3], MAX_STRING, "%s",dini_Get(Factionfile, "FactionRank3" ));
format(Faction[i][FactionRank4], MAX_STRING, "%s",dini_Get(Factionfile, "FactionRank4" ));
format(Faction[i][FactionRank5], MAX_STRING, "%s",dini_Get(Factionfile, "FactionRank5" ));
format(Faction[i][FactionRank6], MAX_STRING, "%s",dini_Get(Factionfile, "FactionRank6" ));
format(Faction[i][FactionRank7], MAX_STRING, "%s",dini_Get(Factionfile, "FactionRank7" ));
printf( "[SYSTEM] Faction %d spawned.", i);
}
}
return 1;
}