Y_INI related..
#1

I already searched other topics, and also gone on y_ini ****** topic, and didn't find what I wanted. I just want to know how to read from a file..

I'm really confuse with y_ini. And need a help to starting some functions, that I'm not getting...

For example:
pawn Код:
else // Before that has a ' if ', checking if the file exists
    {
        new amount;
        INI_Open(COUNTER); // I have that defined
        amount = INI_Int("Count", amount);
        printf(" File count.ini already exists ");
        printf(" Amount of gangs on database: %d/250"); // I want to load the amount, using INI_Int...
    }

And now what that gives...
Quote:

C:\Documents and Settings\F e L i P e\Desktop\SAMP SERVER 0.3C\filterscripts\gangs.pwn(49) : error 029: invalid expression, assumed zero
C:\Documents and Settings\F e L i P e\Desktop\SAMP SERVER 0.3C\filterscripts\gangs.pwn(49) : error 017: undefined symbol "name"
C:\Documents and Settings\F e L i P e\Desktop\SAMP SERVER 0.3C\filterscripts\gangs.pwn(49) : error 001: expected token: ";", but found "return"
C:\Documents and Settings\F e L i P e\Desktop\SAMP SERVER 0.3C\filterscripts\gangs.pwn(49) : fatal error 107: too many error messages on one line

Would make anyone angry, since that's senseless...

Without this code I gave, it absolutely compiles, without errors... Everything else on script works and compiles
Also, if possible, tell me how to use:
Код:
 INI_Int, INI_String
And any other reading structures, since I learnt how to write, already. Thx. Really need it :X
Reply
#2

Have you tried reading through the y_ini topic? It explains reading in there, and use of those functions.

https://sampforum.blast.hk/showthread.php?tid=175565
Reply
#3

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Have you tried reading through the y_ini topic? It explains reading in there, and use of those functions.

https://sampforum.blast.hk/showthread.php?tid=175565
Ya, I did. And thought might be that the begin of my question:

pawn Код:
INI:myini[](name[], value[])
{
    INI_String("a", gA);
    INI_String("b", gB);
    INI_String("c", gC);
    return 0; // This is now required.
}
Just explain me what have to do these things:
Код:
 gA, gB, gC
About INI:myini should be my file, like:
pawn Код:
new INI:file = INI_Open( PLAYER );
Reply
#4

It clearly says in the y_ini thread how to read from a file:

pawn Код:
new gName[MAX_PLAYER_NAME];
new gScore;
new Float:gHealth;
First create the function that gets called when you load a file:
pawn Код:
INI:NAME_OF_THE_FILE[](name[], value[])
{
    INI_String("NAME", gName, sizeof(gName));
    INI_Int("SCORE", gScore);
    INI_Float("HEALTH", gHealth);
    return 0;
}
Then somewhere in your code, read the file with this function:
pawn Код:
INI_Load("NAME_OF_THE_FILE.ini");
Writing obviously goes like this:
pawn Код:
new INI:ini = INI_Open("NAME_OF_THE_FILE.ini");
INI_WriteString(ini, "NAME", "******");
INI_WriteInt(ini, "SCORE", 1337);
INI_WriteFloat(ini, "HEALTH", 100.0);
INI_Close(ini);
Example script for you:
pawn Код:
new gName[MAX_PLAYER_NAME];
new gScore;
new Float:gHealth;

INI:NAME_OF_THE_FILE[](name[], value[])
{
    INI_String("NAME", gName, sizeof(gName));
    INI_Int("SCORE", gScore);
    INI_Float("HEALTH", gHealth);
    return 0;
}

public OnGameModeInit()
{
    new INI:ini = INI_Open("NAME_OF_THE_FILE.ini");
    INI_WriteString(ini, "NAME", "******");
    INI_WriteInt(ini, "SCORE", 1337);
    INI_WriteFloat(ini, "HEALTH", 100.0);
    INI_Close(ini);
   
    INI_Load("NAME_OF_THE_FILE.ini");
   
    printf("%s %d %f", gName, gScore, gHealth);
    return 1;
}
Reply
#5

Thank really finn. I just wasn't understaning that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)