fivem-ts

a library to speed up the development of Fivem scripts and frameworks


Project maintained by Purpose-Dev Hosted on GitHub Pages — Theme by mattgraham

fivem-ts - Documentation v0.7.5Docs


fivem-ts - Documentation v0.7.5 / Shared / Config

Function: Config()

Config(settings): (target, propertyKey?, _descriptor?) => void

A decorator for attaching configuration settings to a class or method in game environment. This allows for easy retrieval and management of settings via metadata.

Parameters

settings: object

An object containing configuration settings to associate with the class or method.

Returns

Function

Parameters

target: any

propertyKey?: string

_descriptor?: PropertyDescriptor

Returns

void

Example

@Config({ maxPlayers: 32, gameMode: 'deathmatch' })
class GameConfig {

}

class PlayerSettings {
  @Config({ maxHealth: 100, canRespawn: true })
  configurePlayer() {

  }
}

// Retrieve configuration metadata
const configMetadata = Reflect.getMetadata('config', GameConfig);
const playerSettings = Reflect.getMetadata('configurePlayer', PlayerSettings.prototype);
console.log(configMetadata, playerSettings);

Remarks

Defined in

shared/decorators/game/Config.ts:32