Script data is reset when script is reloaded
ItsNathanG opened this issue · 2 comments
ItsNathanG commented
Referencing Build #14
The data that is passed to the placeholder scripts seems to be an entirely new data every time.
Reproducible example:
var dataLoc = "%player_name%.viewed";
function viewCount() {
var views = Data.exists(dataLoc) ? Data.get(dataLoc) : 0;
views++;
Data.set(dataLoc, views);
Placeholder.saveData();
return views;
}
viewCount();
This stores how many times a player has viewed the placeholder. The script itself works fine until PAPI is reloaded or the server is restarted.
ItsNathanG commented
Looks like when the script is loaded, getData() is called, but the data is always null (at the time this is reached) so a new script data is created.
Note that the data is loaded here, but by the time this is reached a new data was already created above.
extendedclip commented
Fixed 385dcc9