SA-MP Forums Archive
Help with djson.. - 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: Help with djson.. (/showthread.php?tid=186189)



Help with djson.. - The_Moddler - 27.10.2010

I have djson in a Linux server, it creates the 'cache' file, it looks like this:

Code:
djson-db-cache.619
But the problem is that when you shutdown the server or simply restart it, the file doesn't get deleted, it's strange because in Windows this doesn't happend.

Thanks.


Re: Help with djson.. - Zamaroht - 28.10.2010

If the server is closed properly (that is, with the 'exit' rcon command), the file gets deleted.
If this is a major issue in your server, you could write some code in OnGameModeInit that checks if any file starting with djson-db-cache exists and delete it.


Re: Help with djson.. - The_Moddler - 28.10.2010

Quote:
Originally Posted by Zamaroht
View Post
If the server is closed properly (that is, with the 'exit' rcon command), the file gets deleted.
If this is a major issue in your server, you could write some code in OnGameModeInit that checks if any file starting with djson-db-cache exists and delete it.
I close it with the panel, OnGameModeExit get's called, so it's like doing 'exit'.

How would be the code to check if a file starts with djson.. ?

Thanks


Re: Help with djson.. - Zamaroht - 28.10.2010

It's weird, I usually have that problem with the cache files when the server gets closed incorrectly.
Anyway, this code might be a bit slow, but it isn't an issue since it's just called once when the server starts up:

pawn Code:
stock DeleteDJSonCacheFiles()
{
    new filename[24];
    for(new i; i < 1000; i ++)
    {
        format(filename, sizeof(filename), "djson-db-cache.%d", i);
        if(fexist(filename))
            fremove(filename);
    }

    return 1;
}
Make a call to the DeleteDJSonCacheFiles(); function inside OnGameModeInit, before djson_GameModeInit().


Re: Help with djson.. - iggy1 - 28.10.2010

I get this problem on linux too, it deletes fine with windoze though everytime. I'll be using that function too thanks Zamaroht.


Re: Help with djson.. - The_Moddler - 28.10.2010

Quote:
Originally Posted by Zamaroht
View Post
It's weird, I usually have that problem with the cache files when the server gets closed incorrectly.
Anyway, this code might be a bit slow, but it isn't an issue since it's just called once when the server starts up:

pawn Code:
stock DeleteDJSonCacheFiles()
{
    new filename[24];
    for(new i; i < 1000; i ++)
    {
        format(filename, sizeof(filename), "djson-db-cache.%d", i);
        if(fexist(filename))
            fremove(filename);
    }

    return 1;
}
Make a call to the DeleteDJSonCacheFiles(); function inside OnGameModeInit, before djson_GameModeInit().
Thanks, I just added a break;, because there will be only one file :P

Thanks Zarmoth

EDIT:

Just a little tweak you have to do, you must change:

Code:
format(filename, sizeof(filename), "djson-db-cache.%d", i);
To:

Code:
format(filename, sizeof(filename), "djson-db-cache.%d.db", i);
You forgot the .db part.


Re: Help with djson.. - The_Moddler - 30.10.2010

Mhh.. still not working on Linux :/

pawn Code:
new time = GetTickCount();
new file[24], files;
for(new i; i < 1000; i ++)
{
    format(file, 24, "djson-db-cache.%d.db", i);
    if(fexist(file))
    {
        files++;
        fremove(file);
    }
}
printf("Cache files deleted in: %d ms. Total cache files deleted: %d", GetTickCount()-time, files);
It counts the files, and the ms increases(meaning that it's prossesing it), but they don't get deleted.. why?


Re: Help with djson.. - Retardedwolf - 30.10.2010

http://dev.dracoblue.net/index.php/DJson#djRemoveFile


Re: Help with djson.. - The_Moddler - 30.10.2010

That code it's before djson_GameModeExit(), it should be deleted.


Re: Help with djson.. - The_Moddler - 31.10.2010

Bump!!..