forward Load_Player_Data( playerid, name[ ], value[ ] );
public Load_Player_Data( playerid, name[ ], value[ ] ) // This helps reading with INI_ParseFile
{
INI_Int( "MONEY", RPlayerData[ playerid ][ R_MONEY ] ); // Read Money
INI_Int( "SCORE", RPlayerData[ playerid ][ R_SCORE ] ); // Read Score
INI_Int( "LEVEL", RPlayerData[ playerid ][ R_LEVEL ] ); // Read Level
return 1;
}
LoadStats( playerid )
{
new UserFile[ 32 ];
format( UserFile, sizeof ( UserFile ), "Radmin/%s.ini", pName( playerid ) ); // Format the file...
INI_ParseFile( UserFile, "Load_Player_%s", .bExtra = true, .extra = playerid); // ParseFile( advanced reading )
}
SaveStats( playerid )
{
new UserFile[ 32 ];
format( UserFile, sizeof ( UserFile ), "Radmin/%s.ini", pName( playerid ) ); // Format the file...
new INI:file = INI_Open( UserFile ); // Create and open the file...
INI_SetTag( file, "Data" ); // Set the tag "Data"
INI_WriteInt( file, "MONEY", RPlayerData[ playerid ][ R_MONEY ] ); // Write Money
INI_WriteInt( file, "SCORE", RPlayerData[ playerid ][ R_SCORE ] ); // Write Score
INI_WriteInt( file, "LEVEL", RPlayerData[ playerid ][ R_LEVEL ] ); // Write Level
INI_Close( file ); // Close File
}
INI_Int name[] - Name of the INI textual identifier. variable - Variable to store to. Macro to ease the loading of integers from INI files. Data is passed to the loading callback as a string, this will convert it to an integer (using sscanf if possible, normal functions if not) and save in the given variable. First checks that the name of the data passed matches the given name. Note that for this macro to work the variables MUST be called "name" and "value". Examples: Save an integer: pawn Код:
pawn Код:
|