Hello and welcome to the forum,
To remove an event from the map you need to use removeEvent()
on the RpgMap class
removeEvent()
In the hook you prefer, you can perform the action
const map = player.getCurrentMap()
map?.removeEvent('EVENT_ID')
Normally, you should do this in the onTouch
method of an event but, after some testing, I have the impression that there is a bug.
While waiting for the fix, here is how you can work around the problem:
In src/modules/main/server/player.ts
:
import { RpgPlayer, RpgPlayerHooks } from '@rpgjs/server'
export const player: RpgPlayerHooks = {
// others hooks and ...
onInput(player: RpgPlayer, { input }) {
if (player.otherPlayersCollision.length > 0) {
for (let event of player.otherPlayersCollision) {
if (event.name == 'EV-1') { // set event name
const map = player.getCurrentMap()
map?.removeEvent(event.id)
}
}
}
}