28.03.2017, 12:57
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\"."); }