SA-MP Forums Archive
Y_INI question - 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)
+--- Thread: Y_INI question (/showthread.php?tid=553643)



Y_INI question - Lidor124 - 30.12.2014

All the systems i have seen used by Y_INI are saved by number of files, for exmaple:
https://sampforum.blast.hk/showthread.php?tid=349466

Код:
forward SaveBusiness(id);
public SaveBusiness(id)
{
    new file4[40];
    format(file4, sizeof(file4), BPATH, id); // #define BPATH "/Business/%i.ini"
    new INI:File = INI_Open(file4);
    INI_SetTag(File,"data");
biz system saved on folder called Businesses - 1,2,3,4,5,6 ....
How to switch it to one file "biz.cfg" for exmaple, all the 100 business will be saved there in one file on scriptfiles without any folder?

+REP


Re: Y_INI question - Lidor124 - 30.12.2014

Quote:
Originally Posted by ******
Посмотреть сообщение
Change:

INI_Open(file4);

To:

INI_Open("biz.cfg");
and what about loading? in the following public there is a specific id of business.
I tried it in the past but with no success.

Код:
forward loadbiz_data(idx, name[], value[]);
public loadbiz_data(idx, name[], value[])
{
    INI_Int("bOwned", BusinessInfo[idx][bOwned]);
    bla bla bla....
    return 1;
}



Re: Y_INI question - Lidor124 - 31.12.2014

Just to be clear:

The IDs of business in businesses folder: http://prntscr.com/5mz6vo (as well YINI with player accounts but with different names of players)

Only one file in scriptfiles without any folder: http://prntscr.com/5mz8mi That what i need.


The writing values function:
Quote:

stock SaveBizEx()
{
for(new idx = 1; idx < MAX_BIZ; idx++)
{
new var[32], INI:File = INI_Open("INIbiz.cfg");
// INI_SetTag(File, "Businesses"); // Is that necessary for one file?

format(var, 32, "b%dOwner", idx);
INI_WriteString(File, var, BizInfo[idx][bOwner]);
format(var, 32, "b%dType", idx);
INI_WriteInt(File, var, BizInfo[idx][bType]);
format(var, 32, "b%dLocked", idx);
INI_WriteInt(File, var, BizInfo[idx][bLocked]);
format(var, 32, "b%dMoney", idx);
INI_WriteInt(File, var, BizInfo[idx][bMoney]);
format(var, 32, "b%dProducts", idx);
INI_WriteInt(File, var, BizInfo[idx][bProducts]);
format(var, 32, "b%dSold", idx);
INI_WriteInt(File, var, BizInfo[idx][bSold]);
format(var, 32, "b%dLevel", idx);
INI_WriteInt(File, var, BizInfo[idx][bLevel]);
format(var, 32, "b%dPrice", idx);
INI_WriteInt(File, var, BizInfo[idx][bPrice]);
format(var, 32, "b%dAP", idx);
INI_WriteInt(File, var, BizInfo[idx][bAP]);
format(var, 32, "b%dFee", idx);
INI_WriteInt(File, var, BizInfo[idx][bFee]);
format(var, 32, "b%dInt", idx);
INI_WriteInt(File, var, BizInfo[idx][bInt]);
format(var, 32, "b%dExtX", idx);
INI_WriteFloat(File, var, BizInfo[idx][bExtX]);
format(var, 32, "b%dExtY", idx);
INI_WriteFloat(File, var, BizInfo[idx][bExtY]);
format(var, 32, "b%dExtZ", idx);
INI_WriteFloat(File, var, BizInfo[idx][bExtZ]);
format(var, 32, "b%dExtFA", idx);
INI_WriteFloat(File, var, BizInfo[idx][bExtFA]);
format(var, 32, "b%dIntX", idx);
INI_WriteFloat(File, var, BizInfo[idx][bIntX]);
format(var, 32, "b%dIntY", idx);
INI_WriteFloat(File, var, BizInfo[idx][bIntY]);
format(var, 32, "b%dIntZ", idx);
INI_WriteFloat(File, var, BizInfo[idx][bIntZ]);
format(var, 32, "b%dIntFA", idx);
INI_WriteFloat(File, var, BizInfo[idx][bIntFA]);
INI_Close(File);
return 1;
}
return 1;
}

What it really writes on INIBiz.cfg: http://prntscr.com/5mz8wu (There is only one business with value, it should write all the MAX_BIZ (100))

The Loading function: (I dont know - public LoadDynamic_Businesses(bizid,name[],value[]) what to change here to get no errors)
Quote:

forward LoadDynamic_Businesses(bizid,name[],value[]);
public LoadDynamic_Businesses(bizid,name[],value[])
{
new var[32];
format(var, 32, "b%dOwner", bizid);
INI_String(var, BizInfo[bizid][bOwner], 32);
format(var, 32, "b%dType", bizid);
INI_Int(var, BizInfo[bizid][bType]);
format(var, 32, "b%dLocked", bizid);
INI_Int(var, BizInfo[bizid][bLocked]);
format(var, 32, "b%dMoney", bizid);
INI_Int(var, BizInfo[bizid][bMoney]);
format(var, 32, "b%dProducts", bizid);
INI_Int(var, BizInfo[bizid][bProducts]);
format(var, 32, "b%dSold", bizid);
INI_Int(var, BizInfo[bizid][bSold]);
format(var, 32, "b%dLevel", bizid);
INI_Int(var, BizInfo[bizid][bLevel]);
format(var, 32, "b%dPrice", bizid);
INI_Int(var, BizInfo[bizid][bPrice]);
format(var, 32, "b%dAP", bizid);
INI_Int(var, BizInfo[bizid][bAP]);
format(var, 32, "b%dFee", bizid);
INI_Int(var, BizInfo[bizid][bFee]);
format(var, 32, "b%dInt", bizid);
INI_Int(var, BizInfo[bizid][bInt]);
format(var, 32, "b%dExtX", bizid);
INI_Float(var, BizInfo[bizid][bExtX]);
format(var, 32, "b%dExtY", bizid);
INI_Float(var, BizInfo[bizid][bExtY]);
format(var, 32, "b%dExtZ", bizid);
INI_Float(var, BizInfo[bizid][bExtZ]);
format(var, 32, "b%dExtFA", bizid);
INI_Float(var, BizInfo[bizid][bExtFA]);
format(var, 32, "b%dIntX", bizid);
INI_Float(var, BizInfo[bizid][bIntX]);
format(var, 32, "b%dIntY", bizid);
INI_Float(var, BizInfo[bizid][bIntY]);
format(var, 32, "b%dIntZ", bizid);
INI_Float(var, BizInfo[bizid][bIntZ]);
format(var, 32, "b%dIntFA", bizid);
INI_Float(var, BizInfo[bizid][bIntFA]);
return 1;
}