data — Player Data API
Phase: Server
Persistent per-player key/value storage. Data is stored as JSON files at:
<gameDir>/atomicoffe/playerdata/<uuid>.json
Values can be strings, numbers, or booleans. Tables are not supported — use config for shared config or serialize to JSON yourself.
data.set(uuid, key, value)
Stores a value for a player. Saves to disk immediately.
data.set(player.uuid, "coins", 100)
data.set(player.uuid, "vip", true)
data.set(player.uuid, "lastSeen", "2025-01-01")
data.get(uuid, key) → value | nil
Retrieves a previously stored value, or nil if the key doesn't exist.
local coins = data.get(player.uuid, "coins") or 0
player.tell("You have " .. coins .. " coins.")
data.has(uuid, key) → boolean
Returns true if the key exists for the player.
if not data.has(player.uuid, "welcomed") then
player.tell("Welcome to the server!")
data.set(player.uuid, "welcomed", true)
end
data.delete(uuid, key)
Removes the key from the player's data and saves.
data.delete(player.uuid, "tempBuff")
data.getAll(uuid) → table
Returns a Lua table with all stored key/value pairs for the player.
local all = data.getAll(player.uuid)
for k, v in pairs(all) do
print(k, v)
end
data.clear(uuid)
Removes all stored data for the player.
data.clear(player.uuid)
player.tell("Your data has been reset.")
Full Example
onEvent("player.join", function(e)
local p = e.player
local visits = (data.get(p.uuid, "visits") or 0) + 1
data.set(p.uuid, "visits", visits)
p.tell("Welcome back! This is visit #" .. visits)
end)