#json datastoring methods
1 messages · Page 1 of 1 (latest)
if anyone can make it into a template-based kind of thing then uh oka that would be much appreciated
Alternatively, you could use yaml storage, load the files directly to memory. You'll need the skript-yaml plugin (which has examples on the wiki)
is that better than json?
it is somehow worse documented than skjson
not the wiki
don't know why that sent three times, that was weird
is saving like this not possible?
since i want all players data to be stored seperately
{
"data": {
"stats": {
"bounty": 0,
"experience": 0,
"level": 1
}
},
"profile": {
"created_at": "25/07/2025",
"last_ip": "127.0.0.1",
"last_login": "25/07/2025 20:38:50",
"last_played": "25/07/2025 20:39:05",
"playtime": 443698
}
}
mine works but then it stopped working after ;-;
it would not look like that
it works now dw, the only issue im having is that the data keep resetting to the template lol
@gaunt gorge
are you saving the json file straight after
you edit it
or
waiting like a tick
then saving it
if you aren't try it,
it might not be
writing fast enough
or smh
i found the issue i think
send "DATA BEFORE LOAD: %{player_data::%{_player}'s uuid%::data::stats::level}%" to console
delete {player_data::%{_player}'s uuid%::*}
set {_json} to json from file getDataFile({_player})
send "Loaded JSON: %{_json}%" to console # <-- DEBUG
map {_json} to {player_data::%{_player}'s uuid%::*}
send "DATA AFTER LOAD: %{player_data::%{_player}'s uuid%::data::stats::level}%" to console
the data obv isnt mapped before loading it
but after loading it
the data isnt mapped either
and then the join event checks for missing data
aka the entire thing from the server storage
so it writes the default value
i see..
i mean this is the correct syntax right??
map {_json} to {player_data::%{_player}'s uuid%::*}
is {player_data::%{_player}'s uuid%::*} set?
also isn't it suppost to be map {_json::*} nvm
by chance
i just did map {_json} to {player_data::%{_player}'s uuid%::*}
since its per player basis
try to map it to like {_test::*}
then broadcast {_test::*}
to see what happens
k
function loadPlayerData(player: offline player):
delete {player_data::%{_player}'s uuid%::*}
set {_json} to json from file getDataFile({_player})
map {_json} to {player_data::%{_player}'s uuid%::*}
send "JSON STUFF: %{player_data::%{_player}'s uuid%::*}%" to {_player}
can you broadcast {_json}
so its the issue
from the file
set {_json} to json from file getDataFile({_player})
is your issue
here waht the save file looks like:
"data": {
"race": {
"id_1": {
"crystal_slot_1": "none",
"crystal_slot_2": "none",
"crystal_slot_3": "none",
"obtained": true,
"stage": 1
},
"id_2": {
"crystal_slot_1": "none",
"crystal_slot_2": "none",
"crystal_slot_3": "none",
"obtained": false,
"stage": 1
},
"selected": 1
},
"stats": {
"bounty": 0,
"deaths": 0,
"experience": 0,
"kills": 0,
"level": 1
}
},
"profile": {
"last_ip": "127.0.0.1",
"last_played": "27/07/2025 00:06:28",
"playtime": 503110
}
}```
hmm i got idea lemme try something
hm no ida
since this is the example they given:
map {_json} to {_mapped::*}
send {_mapped::b} to console
can you do this, can you check if the file exists?
beucase in the wiki, they bind it to bind json file "plugins/Skript/playerdata/%player's uuid%.json" as "player-%player's uuid%"
so like skript-yaml, they save it as a ID
then get it from the ID thats saved in memory
if that makes any sense.
the file exists since this is checked before trying to load
local function hasData(player: offline player) :: boolean:
if json file getDataFile({_player}) exists:
return true
return false