On the server side, you can open the GUI and attach events to it
// server side (In a method where you have access to the player)
const gui = player.gui('my-gui')
gui.on('buyItem', (data) => {
console.log(data.amount) // 100
})
gui.open({ hello: 'world' })
// client side (VueJS file)
export default {
name: 'my-gui',
inject: ['rpgGuiInteraction'],
props: ['hello'],
mounted() {
console.log(this.hello) // world
},
methods: {
buy() {
this.rpgGuiInteraction('my-gui', 'buyItem', {
amount: 100
})
}
}
}
- Use the
on()
method to listen for interactions with the GUI (only if the GUI is open)
https://docs.rpgjs.dev/commands/gui.html#call-custom-gui
- Use
rpgGuiInteraction
to communicate with the server
https://docs.rpgjs.dev/classes/vue-inject.html#rpgguiinteraction