Local Events
Server Enviroment
Client Enviroment
Decorators
Name | Arguments | Description |
---|---|---|
@On() | name?: string | Listens to local events. |
@Once() | name?: string | Listens to local events once. |
@On()
The On
decorator is used to listen to local events.
@Controller()
export class MangoController {
@On('myCustomEvent')
public onMyCustomEvent() {
// ...
}
}
ts
@Once()
The Once
decorator is used to listen to local events once.
@Controller()
export class MangoController {
@Once('myCustomEvent')
public onMyCustomEvent() {
// ...
}
}
ts
Internal Events
Every internal event has its own decorator. For example, the @OnPlayerConnect()
decorator is used to listen to the playerConnect
event.
import { Controller, OnPlayerConnect, Player } from '@altv-mango/server';
@Controller()
export class MangoController {
@Inject(LOGGER_SERVICE) private readonly loggerService: LoggerService;
@OnPlayerConnect()
public onPlayerConnect(@Player() player: Player) {
this.loggerService.log(`${player.name} connected`);
}
}
ts
On this page