SA-MP Forums Archive
Save weapons using fread & fwrite - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Save weapons using fread & fwrite (/showthread.php?tid=611628)



Save weapons using fread & fwrite - TheSimpleGuy - 09.07.2016

Код:
SaveWeapons(playerid)
{
	new File:file = fopen(WeaponInventoryPath(playerid), io_append), weapons[13][2], string[128];
	for(new i = 0; i < 13; i++)
	{
		GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
		format(string, sizeof(string), "%s%d.%d|", string, weapons[i][0], weapons[i][1]);
	}
	fwrite(file, string);
	fclose(file);
	return 1;
}

LoadWeapons(playerid)
{
	if(!fexist(WeaponInventoryPath(playerid))) return 1;
	new File:file = fopen(WeaponInventoryPath(playerid), io_read), string[128], weapon, ammo;
	while(fread(file, string))
	{
		printf("%d %d", weapon, ammo);
	}
	return 1;
}
This is all what I can do... can somebody complete the puzzle?