class Kvp
package fivem.shared.core
The resource key/value store — FiveM's built-in persistence.
Data is scoped to the resource that wrote it and stored on disk by the
game (client-side) or the server, surviving restarts. It is the right place
for small, resource-owned settings: UI preferences, a cached login token,
feature toggles. It is not a database — there are no queries, no
indexes, and no cross-resource access. For anything relational, use
fivem.server.db.OxMysql.
Kvp.setInt("volume", 80);
var volume = Kvp.getInt("volume", 100);
Kvp.setJson("layout", {x: 0.8, y: 0.2});
var layout:{x:Float, y:Float} = Kvp.getJson("layout");
Every setter has a sync flag. Leaving it true (the default) flushes the
write to disk immediately; passing false keeps it in memory until the
next flush, which is much faster when writing many keys in a row.
Static methods
staticexists(key:String):Bool
Whether a key has ever been written.
Implemented as a key-prefix scan for an exact match, because FiveM exposes no direct existence check and the typed getters can't distinguish "unset" from a stored zero or empty string.
staticfind(prefix:String):Array<String>
Every key beginning with prefix. Pass "" to list everything this resource has stored.
staticinlinegetInt(key:String, fallback:Int = 0):Int
Reads an integer. Unset keys read as 0, which is indistinguishable from
a stored 0 — use exists first when that matters.
staticgetJson<T>(key:String):Null<T>
Reads and parses a value written with setJson. Returns null if the
key is unset or the stored text is malformed.
The result comes back as FiveM's decoded Lua tables, so object fields
read fine with dot access but a stored array arrives 1-based — see
Json.decode. Use getJsonArray for lists.
staticinlinegetString(key:String, ?fallback:String):String
Reads a string, or fallback when the key is unset.
staticinlinesetJson(key:String, value:Dynamic, sync:Bool = true):Void
Stores a structure or array as JSON.