FileSystem
#1

Hi.

I wanted to know the best system to date for writing and loading data using a cache system.

Like, I load all the player data from a file and do all the operations during the player's session. After he disconnects, all the data is written to the file (so I need to be able to read the data from the cache aswell).

I'm trying to figure it out using Y_ini but I don't quite understand it yet... Do I have to make like a function for everything I wanna read?

Can SII do this aswell??

Do you use a cache system for reading/writing or just read/write everything from files?
Reply
#2

No you don't for y_ini. You just need to parse the file then load the data.

pawn Код:
INI_ParseFile(PlayerFile, "LoadUser", false, true, playerid, true, false);
^ Example on your login dialog.
Reply
#3

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
No you don't for y_ini. You just need to parse the file then load the data.

pawn Код:
INI_ParseFile(PlayerFile, "LoadUser", false, true, playerid, true, false);
^ Example on your login dialog.
Okey. Ill try figure it out then.

I still don't get it how parsefile works, hehe.
Reply
#4

Quote:
Originally Posted by clavador
Посмотреть сообщение
I still don't get it how parsefile works, hehe.
Hmm..... ( Honestly I dont know how it works too, hehe, but I got it working in my admin script like this... )

pawn Код:
#define nyancat_directory  "nyans%s.INI"

new
    nyanCats[ MAX_PLAYERS ]
;

public OnPlayerConnect( playerid )
{
    new
        ohai[ 64 + 24 ]
    ;
 
    format( ohai, sizeof ( ohai ), nyancat_directory, name( playerid ) ); // stock name( playerid ) { blablablabla }
 
    INI_ParseFile( ohai, "loadNyanCats", .bExtra = true, .extra = playerid );

    new
        lol[ 128 ]
    ;
   
    format( lol, sizeof ( lol ), "Your nyancats are : %i.", nyanCats[ playerid ] );

    SendClientMessage( playerid, -1, lol );

    return 1;
}

forward loadNyanCats( playerid, name[ ], value[ ] );
public loadNyanCats( playerid, name[ ], value[ ] )
{
    INI_Int( "Nyancats", nyanCats[ playerid ] );
    return 1;
}
Reply
#5

Quote:
Originally Posted by Basicz
Посмотреть сообщение
Hmm..... ( Honestly I dont know how it works too, hehe, but I got it working in my admin script like this... )

pawn Код:
#define nyancat_directory  "nyans%s.INI"

new
    nyanCats[ MAX_PLAYERS ]
;

public OnPlayerConnect( playerid )
{
    new
        ohai[ 64 + 24 ]
    ;
 
    format( ohai, sizeof ( ohai ), nyancat_directory, name( playerid ) ); // stock name( playerid ) { blablablabla }
 
    INI_ParseFile( ohai, "loadNyanCats", .bExtra = true, .extra = playerid );

    new
        lol[ 128 ]
    ;
   
    format( lol, sizeof ( lol ), "Your nyancats are : %i.", nyanCats[ playerid ] );

    SendClientMessage( playerid, -1, lol );

    return 1;
}

forward loadNyanCats( playerid, name[ ], value[ ] );
public loadNyanCats( playerid, name[ ], value[ ] )
{
    INI_Int( "Nyancats", nyanCats[ playerid ] );
    return 1;
}
Thanks for the example.

I was looking at Djson/Tweaking page and I've found that you can turn off the "auto commit" thing so files are get/set from cache instead from files.

I'll be sticking to it now, as I find Y_ini a little complicated with the syntax and all of that. I don't wanna break my head trying to understand something I'm doing for entertainment. I'm just trying to get the most efficient/easy way to manage my files.

Thank you for the responses!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)