y_ini errors
#1

Код:
new string[128];
	new
	INI:ini = INI_Open("testi.ini");
	INI:testi.ini[TESTINGTAG](name[], value[]) // LINE 21
	{
	    INI_String("EXAMPLESTRING", string, sizeof(string));
	}
	printf("%s", string);
Compiler errors
Код:
error 029: invalid expression, assumed zero
error 017: undefined symbol "@INI_testi"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
All of the errors are at line 21

I'm trying to read the value from the file,and i'm reading from the y_ini topic : https://sampforum.blast.hk/showthread.php?tid=175565
Reply
#2

It should be outside of any callback. An example:
pawn Код:
new sz_String[128];

main( )
{
    /*
    new
        INI:ini = INI_Open("testi.ini")
    ;
    INI_SetTag(ini, "TESTINGTAG");
    INI_WriteString(ini, "EXAMPLESTRING", "Hello Tagathron!");
    INI_Close(ini);
    */


    INI_Load("testi.ini");
   
    printf( "EXAMPLESTRING: \"%s\"", sz_String );
}

INI:testi[TESTINGTAG](name[], value[])
{
    INI_String("EXAMPLESTRING", sz_String, sizeof(sz_String));
    return 0;
}
pawn Код:
// OUTPUT:
[12:42:08] EXAMPLESTRING: "Hello Tagathron!"
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It should be outside of any callback. An example:
pawn Код:
new sz_String[128];

main( )
{
    /*
    new
        INI:ini = INI_Open("testi.ini")
    ;
    INI_SetTag(ini, "TESTINGTAG");
    INI_WriteString(ini, "EXAMPLESTRING", "Hello Tagathron!");
    INI_Close(ini);
    */


    INI_Load("testi.ini");
   
    printf( "EXAMPLESTRING: \"%s\"", sz_String );
}

INI:testi[TESTINGTAG](name[], value[])
{
    INI_String("EXAMPLESTRING", sz_String, sizeof(sz_String));
    return 0;
}
pawn Код:
// OUTPUT:
[12:42:08] EXAMPLESTRING: "Hello Tagathron!"
So if i want to use it under a callback,i would do testi[TESTINGTAG] (name[], value[]); .... ?
Reply
#4

No, the INI:testi[TESTINGTAG](name[], value[]) thing should not be inside any callback. However, you can use INI_Load("testi.ini"); anywhere else.
Reply
#5

But what if i want to for example,when player enters a car, i load the car ID from the file,and using a loop print which car he enter depending on the ID from the file?
I can't use it in callback?Why would i use it just in main?
Reply
#6

Quote:
Originally Posted by Tagathron
Посмотреть сообщение
But what if i want to for example,when player enters a car, i load the car ID from the file,and using a loop print which car he enter depending on the ID from the file?
I can't use it in callback?Why would i use it just in main?
You misread my post, I never mentioned main.

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
[..] However, you can use INI_Load("testi.ini"); anywhere else.
INI_Load can be used anywhere else, it's not obligatory in main (it was just an example!).
Reply
#7

Alright i understand it perfectly now.
Thanks for helping.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)