Hello I made a Zone capture system it's also saving zone data on gamemode exit. But the problem is it's not saving the correct data on the file at gamemode exit plz someone help me here's the code
pawn Код:
//OnGameModeInit
new fstr[50];
for(new i = 0; i < sizeof(ZONEINFO); i++)
{
ZONEID[i] = GangZoneCreate( ZONEINFO[i][zminx], ZONEINFO[i][zminy], ZONEINFO[i][zmaxx], ZONEINFO[i][zmaxy]);
DZONEID[i] = CreateDynamicRectangle( ZONEINFO[i][zminx], ZONEINFO[i][zminy], ZONEINFO[i][zmaxx], ZONEINFO[i][zmaxy]);
format(fstr, sizeof(fstr), ZONEPATH, i + 1);
if(!fexist(fstr))
{
new INI:zfile = INI_Open(fstr);
INI_SetTag(zfile, "Zone data");
INI_WriteString(zfile, "Zone_Name", ZONEINFO[i][zname]);
INI_WriteBool(zfile, "Zone_Owned", false);
INI_WriteHex(zfile, "Zone_Color", 0xC0C0C066);
INI_WriteInt(zfile, "Zone_Owned_Team_ID", -1);
INI_WriteString(zfile, "Zone_Owned_Team", "No_Team");
INI_Close(zfile);
INI_ParseFile(fstr, "LoadZoneData", .bExtra = true, .extra = i);
}
else
{
INI_ParseFile(fstr, "LoadZoneData", .bExtra = true, .extra = i);
}
}
//loading data from file (Im not loading zone name because it's not changing [Zone names are in the script])
forward LoadZoneData(i, name[], value[]);
public LoadZoneData(i, name[], value[])
{
INI_Bool("Zone_Owned", ZONEINFO[i][zowned]);
INI_Hex("Zone_Color", ZONEINFO[i][zcolor]);
INI_Int("Zone_Owned_Team_ID", ZONEINFO[i][zteamid]);
INI_String("Zone_Owned_Team", ZONEINFO[i][zteam], 45);
return 1;
}
//When someone captured the zone
ZONEINFO[i][zteamid] = ZoneAttacker[i];
ZONEINFO[i][zcolor] = GetTeamZoneColor(ZoneAttacker[i]);
ZONEINFO[i][zteam] = GetTeamName(ZoneAttacker[i]);
ZONEINFO[i][zowned] = true;
//and when exiting gamemode
new fstr[128];
for(new i = 0; i < sizeof(ZONEINFO); i++)
{
format(fstr, sizeof(fstr), ZONEPATH, i + 1);
new INI:zfile = INI_Open(fstr);
INI_SetTag(zfile, "Zone data");
INI_WriteBool(zfile, "Zone_Owned", ZONEINFO[i][zowned]);
INI_WriteHex(zfile, "Zone_Color", ZONEINFO[i][zcolor]);
INI_WriteInt(zfile, "Zone_Owned_Team_ID", ZONEINFO[i][zteamid]);
INI_WriteString(zfile, "Zone_Owned_Team", ZONEINFO[i][zteam]);
INI_Close(zfile);
}
Bump..