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

@:value({ sync : true })staticinlinedelete(key:String, sync:Bool = true):Void

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.

@:value({ fallback : false })staticinlinegetBool(key:String, fallback:Bool = false):Bool

@:value({ fallback : 0 })staticinlinegetFloat(key:String, fallback:Float = 0):Float

@:value({ fallback : 0 })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.

staticgetJsonArray<T>(key:String):Array<T>

Reads a value written with setJson that holds an array.

@:value({ fallback : null })staticinlinegetString(key:String, ?fallback:String):String

Reads a string, or fallback when the key is unset.

@:value({ sync : true })staticinlinesetBool(key:String, value:Bool, sync:Bool = true):Void

@:value({ sync : true })staticinlinesetFloat(key:String, value:Float, sync:Bool = true):Void

@:value({ sync : true })staticinlinesetInt(key:String, value:Int, sync:Bool = true):Void

@:value({ sync : true })staticinlinesetJson(key:String, value:Dynamic, sync:Bool = true):Void

Stores a structure or array as JSON.

@:value({ sync : true })staticinlinesetString(key:String, value:String, sync:Bool = true):Void