Y_INI related..
#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


Messages In This Thread
Y_INI related.. - by blackwave - 09.01.2011, 15:36
Re: Y_INI related.. - by JaTochNietDan - 09.01.2011, 15:40
Re: Y_INI related.. - by blackwave - 09.01.2011, 15:42
Re: Y_INI related.. - by Finn - 09.01.2011, 15:49
Re: Y_INI related.. - by blackwave - 09.01.2011, 15:54

Forum Jump:


Users browsing this thread: 1 Guest(s)