# Display a notification
# Prerequisites
You must have a menu installed on your project (or you must create it yourself) To install default menu:
npm install @rpgjs/default-gui
- In
src/modules/index.ts
file, add:
import defaultGui from '@rpgjs/default-gui'
export default [
defaultGui
]
# Use Notification
You have two ways to display a notification:
- The message property is the message that will be displayed in the notification.
- The time property is the time in milliseconds that the notification will be displayed.
- The icon property is the icon that will be displayed in the notification. Remember to create the client-side spritesheet before
- The sound property is the sound that will be played when the notification is displayed. Remember to create the client-side sound before. If you don't want to put any sound, put the
null
value
# Client Side
Use RpgGui
:
import { RpgGui, PrebuiltGui } from '@rpgjs/client'
RpgGui.display(PrebuiltGui.Notification, {
message: 'You have unlocked the secret passage',
time: 2000,
icon: 'icon_id',
sound: 'sound_id'
})
# Server Side
Use player.showNotification()
:
player.showNotification('You have unlocked the secret passage', {
time: 2000,
icon: 'icon_id',
sound: 'sound_id'
})
# Custom Notification UI
Go to src/config/theme.scss
file and add notification SCSS variables
Example:
$notification-background-color: rgba(0, 0, 0, 0.7);
$notification-font-color: white;
$notification-font-family: 'lato';