Interface
Notifications, interactions and the controls card, the in-game UI built into Yecoyz Core.
Core has a small in-game UI that your own resources can use. It runs in Core's own NUI page, so there is nothing extra to install.
Notifications
Core.Notify shows a small notification in the top-right corner: an icon tile coloured for the type, an optional title and the message.
-- client
Core.Notify('Door locked', 'success')
Core.Notify('Not enough money', 'error', 4000, 'Bank')
Core.Notify('New message', 'info', 5000, 'Phone', 'smartphone')
-- server
Core.Notify(source, 'Welcome back', 'info', 5000, 'City Hall', 'building')| Argument | Description |
|---|---|
message |
The text |
type |
'info' (default), 'success', 'error' or 'warning'. Each type has its own icon and colour. |
duration |
Milliseconds on screen. Config.NotifyDuration by default. |
title |
Optional. Config.NotifyTitle by default. |
icon |
Optional. Any lucide name, for example 'bell'. Replaces the icon of the type. |
Config.Notify = 'yecoyz' is the default. Set it to 'auto', 'ox_lib', 'framework' or 'native' to show notifications somewhere else, see the configuration.
Interactions
A target system without the target key. Walk up to a prop, a door handle or a spot, and a menu appears on it. If it has several options, scroll the mouse wheel to switch between them and press E to use the selected one.
local id = Core.AddInteraction({
id = 'cityhall_door', -- optional; adding the same id again replaces it
coords = vec3(-544.9, -204.4, 38.2),
distance = 2.0, -- how close the player has to be
options = {
{ name = 'open', label = 'Open door', icon = 'door-open', onSelect = function(data) end },
{ name = 'lock', label = 'Lock door', icon = 'lock', jobs = 'police', serverEvent = 'cityhall:lock' },
{ name = 'knock', label = 'Knock', icon = 'hand', command = 'knock' },
},
})
Core.RemoveInteraction(id)AddInteraction returns the id. Registrations are removed when the resource that added them stops.
Where the menu appears
Use one of these fields:
| Field | Spot |
|---|---|
coords |
A fixed position |
entity / netId |
One entity. bone = 'door_dside_f' (or a list, the closest is used) or offset = vec3(...) pins the menu to a part of it, like a door handle. |
models = { 'prop_atm_01' } |
Every entity of these models |
global = 'vehicle' |
Every 'vehicle', 'ped' (not players), 'player' or 'object'. 'object' is heavy, prefer models. |
The options of one spot are shown together. When several spots are in range, the closest one is shown.
Options
| Field | Description |
|---|---|
label |
Required. The text of the option. |
name |
Identifies the option in onSelect |
icon |
A lucide name |
onSelect(data) |
Called with { entity, netId, coords, distance, name, id } |
event / serverEvent / command |
Alternatives to onSelect. serverEvent gets the data without entity, so use netId. |
distance |
A shorter range than the registration |
jobs, items |
Same forms as Core.HasJob and Core.HasItem. The option is hidden without them. |
canInteract(entity, distance, coords, name) |
Return false to hide the option |
inVehicle |
Also show while the player is in a vehicle (hidden by default) |
Warning
jobsanditemsonly decide what the player sees. Do the real check on the server in the event you trigger.
Other functions
| Function | Description |
|---|---|
SetInteractionsDisabled(state) |
Hide and pause every interaction, for example during a minigame |
GetActiveInteraction() |
The menu on screen as { index, options = { { name, label } } }, or nil |
Using ox_lib instead
Set Config.Interact.UI = 'ox_lib' to show the selected option as ox_lib's text UI instead of the menu on the spot:
[E] Lock door
Scroll 2 / 3Scrolling, the key and everything else work the same. Some things differ:
- ox_lib's text UI can't be pinned to the world, so it shows whenever the player is in range.
Config.Interact.OxPositionsets where it sits. - Option icons are passed on as they are. Use names that exist in both lucide and FontAwesome, such as
'lock','hand'and'door-open'. - If ox_lib isn't running, Core uses its own menu.
Controls card
Shows the keys of a mode and what they do, in the bottom-right corner. Use it for editors, placement modes and anything else with several keys.
Core.ShowControls({
{ keys = { 'LMB' }, label = 'Select' },
{ keys = { 'Shift', 'Scroll' }, label = 'Rotate' },
{ keys = { 'Del' }, label = 'Delete', dim = true }, -- dim: not available right now
}, 'Editor')
Core.HideControls()| Argument | Description |
|---|---|
rows |
A list of { keys, label, dim }. keys is a list of key names, or one string. |
title |
Optional heading of the card |
id |
Optional. Defaults to the calling resource. |
Each resource has its own card and the latest one is shown. Hiding it brings back the one below, and a resource's card is removed when it stops.