09.01.2011, 15:49
It clearly says in the y_ini thread how to read from a file:
First create the function that gets called when you load a file:
Then somewhere in your code, read the file with this function:
Writing obviously goes like this:
Example script for you:
pawn Код:
new gName[MAX_PLAYER_NAME];
new gScore;
new Float:gHealth;
pawn Код:
INI:NAME_OF_THE_FILE[](name[], value[])
{
INI_String("NAME", gName, sizeof(gName));
INI_Int("SCORE", gScore);
INI_Float("HEALTH", gHealth);
return 0;
}
pawn Код:
INI_Load("NAME_OF_THE_FILE.ini");
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);
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;
}