Client/WebView Events
Server Enviroment
Decorators
Name | Arguments | Description |
---|---|---|
@OnPlayer() | name?: string | Listens to client events. |
@OncePlayer() | name?: string | Listens to client events once. |
@OnWebView() | id: string | number, name?: string | Listens to WebView events. |
@OnceWebView() | id: string | number, name?: string | Listens to WebView events once. |
@OnPlayer()
The OnPlayer
decorator is used to listen to client events.
@Controller()
export class DeliciousMangoController {
@Inject(LOGGER_SERVICE) private readonly loggerService: LoggerService;
@OnPlayer('eat')
public onEat(@Player() player: alt.Player) {
this.loggerService.log(`${player.name} ate a mango!`);
}
}
ts
@OncePlayer()
The OncePlayer
decorator is used to listen to client events once.
@Controller()
export class DeliciousMangoController {
@Inject(LOGGER_SERVICE) private readonly loggerService: LoggerService;
@OncePlayer('eat')
public onEat(@Player() player: alt.Player) {
this.loggerService.log(`${player.name} ate a mango!`);
}
}
ts
@OnWebView()
The OnWebView
decorator is used to listen to WebView events.
@Controller()
export class DeliciousMangoController {
@Inject(LOGGER_SERVICE) private readonly loggerService: LoggerService;
@OnWebView('my_webview_id', 'eat')
public onEat(@Player() player: alt.Player) {
this.loggerService.log(`${player.name} ate a mango!`);
}
}
ts
@OnceWebView()
The OnceWebView
decorator is used to listen to WebView events once.
@Controller()
export class DeliciousMangoController {
@Inject(LOGGER_SERVICE) private readonly loggerService: LoggerService;
@OnceWebView('my_webview_id', 'eat')
public onHello(@Player() player: alt.Player) {
this.loggerService.log(`${player.name} ate a mango!`);
}
}
ts
On this page