Skip to content

Commit

Permalink
fix(datastore/server): decode JSON string
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Feb 14, 2022
1 parent d5661c1 commit 843f395
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [esx_addons]/esx_datastore/server/classes/datastore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function CreateDataStore(name, owner, data)

self.name = name
self.owner = owner
self.data = data
self.data = type(data) == 'string' and json.decode(data) or data

local timeoutCallbacks = {}

Expand Down
6 changes: 3 additions & 3 deletions [esx_addons]/esx_datastore/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ AddEventHandler('onResourceStart', function(resourceName)
DataStoresIndex[#DataStoresIndex + 1] = data.name
DataStores[data.name] = {}
end
DataStores[data.name][#DataStores[data.name] + 1] = CreateDataStore(data.name, data.owner, data.data)
DataStores[data.name][#DataStores[data.name] + 1] = CreateDataStore(data.name, data.owner, json.decode(data.data))
else
if data.data then
SharedDataStores[data.name] = CreateDataStore(data.name, nil, data.data)
SharedDataStores[data.name] = CreateDataStore(data.name, nil, json.decode(data.data))
else
newData[#newData + 1] = {data.name, '\'{}\''}
end
Expand All @@ -26,7 +26,7 @@ AddEventHandler('onResourceStart', function(resourceName)
MySQL.prepare('INSERT INTO datastore_data (name, data) VALUES (?, ?)', newData)
for i = 1, #newData do
local new = newData[i]
SharedDataStores[new[1]] = CreateDataStore(new[1], nil, new[2])
SharedDataStores[new[1]] = CreateDataStore(new[1], nil, {})
end
end
end
Expand Down

0 comments on commit 843f395

Please sign in to comment.