Save and load GangZones
#8

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;
}
Reply


Messages In This Thread
Save and load GangZones - by KamilPolska - 07.02.2018, 23:46
Re: Save and load GangZones - by Weponz - 08.02.2018, 02:09
Re: Save and load GangZones - by Mugala - 08.02.2018, 10:58
Re: Save and load GangZones - by PepsiCola23 - 08.02.2018, 11:15
Re: Save and load GangZones - by KamilPolska - 08.02.2018, 14:59
Re: Save and load GangZones - by Mugala - 08.02.2018, 15:11
Re: Save and load GangZones - by KamilPolska - 08.02.2018, 15:48
Re: Save and load GangZones - by KamilPolska - 08.02.2018, 21:04
Re: Save and load GangZones - by Gammix - 08.02.2018, 21:23
Re: Save and load GangZones - by KamilPolska - 09.02.2018, 13:22

Forum Jump:


Users browsing this thread: 2 Guest(s)