SA-MP Forums Archive
Player Inventory saving in file. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Player Inventory saving in file. (/showthread.php?tid=109777)



Player Inventory saving in file. - CaHbKo - 22.11.2009

Hello,

I got a problem. I am trying to make Player Inventory by Joe (http://forum.sa-mp.com/index.php?topic=116917.0) save in a file, but i am too new to saving and stuff. I read the guide about that but it's too complicated for me. I just want a good example of that and i will learn.

I tried this:
pawn Code:
if(!strcmp(cmdtext[1],"SaveInv",true,14))
    {
        new File:inventory = fopen("CRP_Scriptfiles/Inventories/inv.ini", io_write);
        new string[MAX_ITEM_NAME+20];
        new amount = strval(cmdtext[16]);
        GetPlayerName(amount,string,sizeof(string));
        for(new index;index<MAX_ITEMS;index++)
        {
            PlayerInventoryPlayerItemData(playerid,index,string,amount);
            format(string,sizeof(string),"%s -- %d",string,amount);
            fwrite(inventory, string);
        }
    fclose(inventory);
    }
I wanted to make it save when i enter the command (just for tests), but it crashes whole server.

Thanks.


Re: Player Inventory saving in file. - yom - 22.11.2009

Make sure the folders CRP_Scriptfiles/Inventories exists, as the default PAWN functions doesn't create folders and crash if they don't exist.


Re: Player Inventory saving in file. - CaHbKo - 22.11.2009

It exists, i forgot to mention that sorry. I checked, rechecked and checked again the path, still crashes.


Re: Player Inventory saving in file. - CaHbKo - 23.11.2009

Anyone?