01.03.2013, 00:00
Quote:
But what if one of the lines in the INI file is something like...
Faction = LSPD or does everything have to be integers? like.. Faction_ID = 3 Or what is bool? |
Say you wanted to read from "scriptfiles/settings.ini"...
pawn Code:
INI_ParseFile( "settings.ini", "LoadSettings_%s" );
// "settings.ini" is our file, and "LoadSettings" is our callback.
pawn Code:
public LoadSettings_info ( name[], value[] )
{
// Every time you write information to the settings file, you have to use INI_SetTag( fileVariable, "info" );
INI_Int( "OOC", ooc );
// This loads the integer "OOC" into the variable "ooc"
INI_String( "FACTION_0", FactionNames [ 0 ], 64 );
// This loads the string "Faction" into the variable "FactionNames [ 0 ]" with a length of 64 cells.
}
pawn Code:
new
INI: mySettingFile = INI_Open( "settings.ini" );
INI_SetTag( mySettingFile, "info" );
INI_WriteInt( mySettingFile, "OOC", 1 );
INI_WriteString( mySettingFile, "FACTION_0", "LSPD" );
INI_Close( mySettingFile );
// Don't forget to close the file after you're done working with it!