29.08.2008, 14:31
whow, thatґs nice
Thanks Draco, gonna change everything from dini to DJson now :P
Thanks Draco, gonna change everything from dini to DJson now :P
djAutocommit(false);
format(str, sizeof(str), "%s/Password", player);
djSetInt("Accounts.json", str, udb_hash(params));
format(str, sizeof(str), "%s/Money", player);
djSetInt("Accounts.json", str, GetPlayerMoney(playerid));
format(str, sizeof(str), "%s/Score", player);
djSetInt("Accounts.json", str, GetPlayerScore(playerid));
format(str, sizeof(str), "%s/Health", player);
GetPlayerHealth(playerid, pHealth);
djSetFloat("Accounts.json", str, pHealth);
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
format(str, sizeof(str), "%s/X", player);
djSetFloat("Accounts.json", str, Pos[0]);
format(str, sizeof(str), "%s/Y", player);
djSetFloat("Accounts.json", str, Pos[1]);
format(str, sizeof(str), "%s/Z", player);
djSetFloat("Accounts.json", str, Pos[2]);
djCommit("Accounts.json");
djAutocommit(true);
Originally Posted by Wadabak
I have tried turning the Autocommit of at the beginning of all the data writing, then I commited the file and at the end I turned Autocommit on again.
The time that it takes is still around 2-5 seconds. |
Originally Posted by Wadabak
And I've maybe found a bug. When I registered directly after a gmx, it didn't stored all the data that I was going to save, it only saved 2 of the 7 savings to the file.
Here is my code: pawn Код:
|
The startup usually takes up to 3 or 4 seconds, due to the fact that the sqlite database is slow at startup, which djson uses as cache. Do you mean that? |
{"Antironix":{"Health":100.000000,"Money":0,"Password":256115588,"Score":0,"X":135.146362,"Y":-67.085334,"Z":1.578125}}
{"Antironix":{"Health":100.000000,"Z":-42.978889}}
Originally Posted by JwLoaDing
I dont know if it's a noob question... but....
I have the players' data, vehicles, houses and properties stored in individual files through the dini... Then, how i can readapt all my gm for diniІ? Because exists several script lines with dini! Sorry bad english |
Originally Posted by Cezar
I think it was asked and I missed it, hopefully not. Is DJson faster than pawno's file system?
|
PlayerName=NoPlayerName HealthSpawn=70 Money=145789 Deaths=7 Kills=15
Originally Posted by JwLoaDing
Thks for reply Draco...
I got convert my gm... But I have a problem... The data in the files were not loaded Djson can load data in file as Dini? In each line? Code:
PlayerName=NoPlayerName HealthSpawn=70 Money=145789 Deaths=7 Kills=15 |
{"data":[{"1":"2"},{"3":"4"}]}
{"data":[1,2,3,4]}
#include <a_samp>
#include <djson>
forward testtimer();
new count, t_timer;
main()
{
new str[129];//below is my name hashed with whirlpool (129 cells)
format(str, sizeof(str), "362C5AE16755FB404B2C5B507522AE358F1DB630EBAE9836422E8C2E9FCAC537BA08A2EEF982CBBDAFFFC5D72F9595AF22400C1C0FEAD955FDA22ADC9916511D");
djSet("test.json","test/pass",str);
t_timer = SetTimer("testtimer",2000,true);
}
public OnGameModeInit(){djson_GameModeInit();return 1;}
public OnGameModeExit(){djson_GameModeExit();return 1;}
public testtimer()
{
count ++;
if(count == 5)KillTimer(t_timer);
printf("attempt %d\n%s", count, dj("test.json","test/pass"));
}
[08:37:59] --------------- [08:37:59] Loaded 0 filter scripts. [08:37:59] Number of vehicle models: 0 [08:38:01] attempt 1 [08:38:03] attempt 2 [08:38:05] attempt 3 [08:38:08] attempt 4 [08:38:10] attempt 5 [08:38:28] --- Server Shutting Down.
[08:44:34] --------------- [08:44:34] Loaded 0 filter scripts. [08:44:34] Number of vehicle models: 0 [08:44:36] attempt 1 362C5AE16755FB404B2C5B507522AE358F1DB630EBAE9836422E8C2E9FCAC537BA08A2EEF982CBBDAFFFC5D72F9595AF22400C1C0FEAD955FDA22ADC9916511D [08:44:39] attempt 2 362C5AE16755FB404B2C5B507522AE358F1DB630EBAE9836422E8C2E9FCAC537BA08A2EEF982CBBDAFFFC5D72F9595AF22400C1C0FEAD955FDA22ADC9916511D [08:44:41] attempt 3 362C5AE16755FB404B2C5B507522AE358F1DB630EBAE9836422E8C2E9FCAC537BA08A2EEF982CBBDAFFFC5D72F9595AF22400C1C0FEAD955FDA22ADC9916511D [08:44:43] attempt 4 362C5AE16755FB404B2C5B507522AE358F1DB630EBAE9836422E8C2E9FCAC537BA08A2EEF982CBBDAFFFC5D72F9595AF22400C1C0FEAD955FDA22ADC9916511D [08:44:46] attempt 5 362C5AE16755FB404B2C5B507522AE358F1DB630EBAE9836422E8C2E9FCAC537BA08A2EEF982CBBDAFFFC5D72F9595AF22400C1C0FEAD955FDA22ADC9916511D [08:45:32] --- Server Shutting Down.
I seem to have found a bug with reading large strings before the server is restarted. For example if i used a register command it would save the password to a file good, but when i try to read that password it returns null untill the server is restarted. Here is some example code.
pawn Код:
Код:
[08:37:59] --------------- [08:37:59] Loaded 0 filter scripts. [08:37:59] Number of vehicle models: 0 [08:38:01] attempt 1 [08:38:03] attempt 2 [08:38:05] attempt 3 [08:38:08] attempt 4 [08:38:10] attempt 5 [08:38:28] --- Server Shutting Down. Код:
[08:44:34] --------------- [08:44:34] Loaded 0 filter scripts. [08:44:34] Number of vehicle models: 0 [08:44:36] attempt 1 362C5AE16755FB404B2C5B507522AE358F1DB630EBAE9836422E8C2E9FCAC537BA08A2EEF982CBBDAFFFC5D72F9595AF22400C1C0FEAD955FDA22ADC9916511D [08:44:39] attempt 2 362C5AE16755FB404B2C5B507522AE358F1DB630EBAE9836422E8C2E9FCAC537BA08A2EEF982CBBDAFFFC5D72F9595AF22400C1C0FEAD955FDA22ADC9916511D [08:44:41] attempt 3 362C5AE16755FB404B2C5B507522AE358F1DB630EBAE9836422E8C2E9FCAC537BA08A2EEF982CBBDAFFFC5D72F9595AF22400C1C0FEAD955FDA22ADC9916511D [08:44:43] attempt 4 362C5AE16755FB404B2C5B507522AE358F1DB630EBAE9836422E8C2E9FCAC537BA08A2EEF982CBBDAFFFC5D72F9595AF22400C1C0FEAD955FDA22ADC9916511D [08:44:46] attempt 5 362C5AE16755FB404B2C5B507522AE358F1DB630EBAE9836422E8C2E9FCAC537BA08A2EEF982CBBDAFFFC5D72F9595AF22400C1C0FEAD955FDA22ADC9916511D [08:45:32] --- Server Shutting Down. |
Exelent nice1 it works, do you know why that happened? I mean the string was way less than 255
|
Question: Well, i created this vehicle ownership that saves the player's vehicle ( List most vehicles ownership save type ) and it also saves all possible mods a vehicle can have. So my question is, is it better and faster to save ^ my system using djson, or MySQL would be a better option?
|