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


Messages In This Thread
Player Inventory saving in file. - by CaHbKo - 22.11.2009, 10:39
Re: Player Inventory saving in file. - by yom - 22.11.2009, 13:00
Re: Player Inventory saving in file. - by CaHbKo - 22.11.2009, 16:04
Re: Player Inventory saving in file. - by CaHbKo - 23.11.2009, 09:27

Forum Jump:


Users browsing this thread: 1 Guest(s)