Player Inventory saving in file.
#1

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.
Reply
#2

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

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

Anyone?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)