Hi Peopl! How to write inventory save and load script MYSQL R41-2??
Please Write me! Thank You AND ALL RESPECT BRO.
Please Write me! Thank You AND ALL RESPECT BRO.
Code:
stock SaveItems(playerid)
{
new m[128];
format(itemfile,sizeof(itemfile),"/Inv/%s.ini",GetNamei(playerid));
for(new i; i<MAX_ITEMS; i++)
{
format(m,128,"Item%d",i);
dini_Set(itemfile,m,ItemName[playerid][i]);
format(m,128,"Itemamount%d",i);
dini_IntSet(itemfile,m,ItemAmount[playerid][i]);
}
return 1;
}
stock LoadItems(playerid)
{
new m[128];
format(itemfile,sizeof(itemfile),"/Inv/%s.ini",GetNamei(playerid));
if(dini_Exists(itemfile))
{
ResetPlayerItems(playerid);
for(new i; i<MAX_ITEMS; i++)
{
format(m,128,"Item%d",i);
new item[128];
format(item,128,"%s",dini_Get(itemfile,m));
format(ItemName[playerid][i],128,"%s",item);
format(m,128,"Itemamount%d",i);
ItemAmount[playerid][i] = dini_Int(itemfile,m);
}
}
else
{
dini_Create(itemfile);
ResetPlayerItems(playerid);
SaveItems(playerid);
}
return 1;
}