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 / NetEvent
NetEvent(
eventName
): (target
,propertyKey
,descriptor
) =>void
A decorator that subscribes a method to a network event.
The @NetEvent
decorator is used to associate a method with a network event. When the specified network event occurs, the decorated method will be automatically called with the event’s arguments.
Usage:
Example:
class NetworkHandler {
@NetEvent('playerJoined')
onPlayerJoined(playerId: number, playerName: string) {
console.log(`Player joined: ${playerName} (ID: ${playerId})`);
}
}
Parameters:
eventName
: The name of the network event to listen for. The method decorated with @NetEvent
will be called whenever this event is fired.Note: Ensure that the event name matches the one used in the network event system, and the method should match the expected signature of the event arguments.
• eventName: string
The name of the network event to subscribe to.
Function
A method decorator that subscribes the decorated method to the specified network event.
• target: object
• propertyKey: string
• descriptor: PropertyDescriptor
void