Y_INI Problem
#1

Hello, i have a problem with reading using Y_INI.
When i disconnect server it write the data but when i join...it doesen't load..

Here is the code:
pawn Код:
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
}
Reply
#2

Anyone ?...
Reply
#3

By ******:

Quote:
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 Код:
INI:filename[tag](name[], value[])
{
    INI_Int("LEVEL", gLevel);
}
Save an integer for a player (assuming you used a matching INI_Load call):
pawn Код:
INI:filename[tag](playerid, name[], value[])
{
    INI_Int("PLAYER_LEVEL", gLevel[playerid]);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)