SaveInventory causing server crash
#1

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\".");
}
Reply
#2

Crash log?
Reply
#3

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


Forum Jump:


Users browsing this thread: 1 Guest(s)