SA-MP Forums Archive
FileSystem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: FileSystem (/showthread.php?tid=266256)



FileSystem - clavador - 04.07.2011

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?


Re: FileSystem - Lorenc_ - 04.07.2011

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.


Respuesta: Re: FileSystem - clavador - 04.07.2011

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.


Re: Respuesta: Re: FileSystem - Basicz - 04.07.2011

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;
}



Respuesta: Re: Respuesta: Re: FileSystem - clavador - 04.07.2011

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!