Y_INI Load Help
#1

Hello,

I got this next command:
pawn Код:
new INI: itemsfile = INI_Open("Items.txt");
        new string[256];
        for(new i = 0; i < MAX_OBJ; i ++)
        {
            format(string, sizeof(string), "Item%d", i);
            INI_SetTag(itemsfile, string);
            format(string, sizeof(string), "Item%dItem", i);
            INI_WriteInt(itemsfile, string, 0);
            format(string, sizeof(string), "Item%dPosX", i);
            INI_WriteFloat(itemsfile, string, 0);
            format(string, sizeof(string), "Item%dPosY", i);
            INI_WriteFloat(itemsfile, string, 0);
            format(string, sizeof(string), "Item%dPosZ", i);
            INI_WriteFloat(itemsfile, string, 0);
        }
        INI_Close(itemsfile);
My question is, how can I make a load function using y_ini? This is my first time using y_ini and I didn't really understand the INI_ParseFile. This is the load function:
pawn Код:
stock LoadItems()
{
    new string[128], INI: file = INI_Open("Items.txt");
    for(new j = 0; j < MAX_OBJ; j ++)
    {
        format(string, 128, "Item%dItem", j);
        jData[j][Item] = INI_Int(file, string);
        format(string, 128, "Item%dPosX", j);
        jData[j][ItemX] = INI_Int(file, string);
        format(string, 128, "Item%dPosY", j);
        jData[j][ItemY] = INI_Int(file, string);
        format(string, 128, "Item%dPosZ", j);
        jData[j][ItemZ] = INI_Int(file, string);
    }
    INI_Close(file);
    return 1;
}
(I know its wrong, I just gave the basic)

By the way, I need it to load the whole 200 tags (200 items).

Thanks!
Reply
#2

INI Parse File have those parameters.
INI_ParseFile(filename[], functionname[], .extra = false, .bExtra = false);
At least from what can I see.. (its not really like that)

You dont need to set your variables to the INI_Int function, since that function is passed by reference.
pawn Код:
for(int itemid = 0; itemid < MAX_OBJ; itemid++)
   INI_ParseFile(GetItemID(itemid), "LoadItems", .extra = true, .bExtra = itemid);
That is just an example.
Reply
#3

Quote:
Originally Posted by XStormiest
Посмотреть сообщение
INI Parse File have those parameters.
INI_ParseFile(filename[], functionname[], .extra = false, .bExtra = false);
At least from what can I see.. (its not really like that)

You dont need to set your variables to the INI_Int function, since that function is passed by reference.
pawn Код:
for(int itemid = 0; itemid < MAX_OBJ; itemid++)
   INI_ParseFile(GetItemID(itemid), "LoadItems", .extra = true, .bExtra = itemid);
That is just an example.
I still don't understand. What GetItemID parameter means? should I remove the INI_Int functions?
If you need more codes, just tell me.
Reply
#4

As I said the GetItemID was just an IDEEA of a function that stocks your items id, so when the loops check for objects, it loads every single item, if that item is not real or does not exist, return -1 and ingore it.
Check Tutorials and ******'s Y_INI Page to learn more.
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
Have you actually read the official topics and tutorials? It helps far more if you say what exactly you didn't understand from them, not just say you don't know how to do something that is well documented.
I read all the tutorials, at SA-MP forums, at SA-MP wiki, and still didn't completely understand the INI_ParseFile.
Quote:
Originally Posted by XStormiest
Посмотреть сообщение
As I said the GetItemID was just an IDEEA of a function that stocks your items id, so when the loops check for objects, it loads every single item, if that item is not real or does not exist, return -1 and ingore it.
Check Tutorials and ******'s Y_INI Page to learn more.
The item can't be unreal.. However I still didn't understand.
I am sorry for being annoying to understand, I just used dini library untill now.
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
OK, so where in the tutorials do you get lost? There is no point explaining it all again from scratch because those explanations would be the same as the old explanations in the tutorials and still not help you.
I didn't understand the meaning of Function_%s.
Is the %s is name of the INI tag? if yes, how can I load 200 tags without creating 200 publics?
Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
Why do you have 200 tags!?
I am using one file instead of 200. (Unless you tell me its impossible to load these tags)
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
How many keys do you have?
4 per tag. Maybe I should do it using 200 files? I mean, dini was slow, not sure about y_ini.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)