a library to speed up the development of Fivem scripts and frameworks
fivem-ts - Documentation v0.7.5 • Docs
fivem-ts - Documentation v0.7.5 / Shared / DynamicProperty
DynamicProperty(
propertyName
): (target
,propertyKey
) =>void
A decorator for dynamically binding a class property to a FiveM resource KVP (Key-Value Pair). This allows for automatic persistence of the property’s value and synchronization across the network.
• propertyName: string
The name of the KVP to associate with the decorated property.
Function
• target: unknown
• propertyKey: string
void
class PlayerSettings {
// Bind the 'playerName' property to a KVP, automatically syncing changes across the network.
@DynamicProperty('playerNameKvp')
public playerName: string;
}
const settings = new PlayerSettings();
settings.playerName = 'NewName'; // Automatically sets the KVP and syncs across the network
console.log(settings.playerName); // Retrieves the current value from the KVP
@DynamicProperty
, any changes to that property will automatically update
the corresponding KVP and emit a network event to sync the new value with other clients.updateProperty:<propertyName>
.