SA-MP Forums Archive
SaveInventory causing server crash - 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: SaveInventory causing server crash (/showthread.php?tid=631378)



SaveInventory causing server crash - Crystallize - 28.03.2017

Fixed by doing this:
Код:
stock SaveInventory(playerid)
{
	gItemList="";
	new filename[48];
	GetPlayerName(playerid,filename,24);
	format(filename,48,"Inventory/%s.inv",filename);
	new File:handle1=fopen(filename,io_write);
	for(new item;item<MAX_ITEMS;item++)
	{
		if(!strlen(_GetItemNamePVar(playerid,item))||!_GetItemAmountPVar(playerid,item))continue;
		format(gItemList,sizeof(gItemList),"%s%s\n%d\n",gItemList,_GetItemNamePVar(playerid,item),_GetItemAmountPVar(playerid,item));
	}
	if(handle1)
	{
	fwrite(handle1,gItemList);
	fclose(handle1);
	GetPlayerName(playerid,filename,24);
	printf("[INV] %s[%d]'s inventory saved.",filename,playerid);
	}
	else
	print("Failed to open file \"file.txt\".");
}



Re: SaveInventory causing server crash - ISmokezU - 28.03.2017

Crash log?


Re: SaveInventory causing server crash - jasperschellekens - 28.03.2017

Do you have the folder "Inventory" inside your scriptfiles folder?