-
Notifications
You must be signed in to change notification settings - Fork 19
Markers
Distance markers are classic marker but they will init and appear only if a player is near them, rcore support event classic marker but please use always distance markers, it's good for optimization :)
Methods:
- createDistanceMarker(type, coords, distance,cb, options)
- removeDistanceMarker(id)
- removeDistanceMarkerByPos(pos)
- updateDistanceMarker(id, type, coords, distance, options)
- getDistanceMarkers()
- getDistanceMarker(id)
This method create distance marker, please be careful this method must be called only once! Never use this method in while cycle, all markers, distance text etc is called only once. This method returns ID
Params:
- type
Marker type, its integer, full list can be found here https://docs.fivem.net/docs/game-references/markers/
- coords
Vector3 type coordinates
- distance
Integer that set from which distance marker will be visible and initialized
- cb
callbacks onEnter, onEnterKey(key), onLeave, this is table of function with specific names, this callbacks are called only once so if player enter marker it call once onEnter, if a player in marker press any keys it called onEnterKey with specific key as a parameter, same at onLeave callback
- options
you can use all option which is in config.lua (see wiki page configs), these options are merged and use for your marker so you can rewrite only a few params and left will be used from config
rcore:createDistanceMarker(1, vector3(v.x,v.y,v.z), 50.0, {
onEnter = function()
rcore:showHelpNotification('Zmackni ~INPUT_CONTEXT~ pro otevreni menu')
end,
onEnterKey = function(key)
if key == rcore:getKeys()['E'] then
--TODO: Do something
end
end,
onLeave = function()
rcore:showNotification('Why are u leaving?')
end
})This method removes distance marker with its ID
Params:
- id
ID of distance marker which you get at creating distance marker
rcore:removeDistanceMarker(markerId)This method removes distance marker with its position
Params:
- pos
Coords in vector3, if some marker is found at same coords it will delete it
rcore:removeDistanceMarkerByPos(vector3(155.0,666.0,44.0))Method for updating marker position, parameters etc, you can use createDistanceMarker as well, rcore will check if marker exists at same pos and if yes it will automatically use update method.
(id, type, coords, distance, options) Params:
- id
id of distance marker
- type
type of marker same as createDistanceMarker method
- distance
distance which set from where can be marker visible, initialized
- options
use options that are in config.lua as MarkerOptions, same as createDistanceMarker
rcore:updatedistanceMarker(markerId, 1, vector3(x,y,z), 50.0, {scale = {
x = 5.0,
y = 5.0,
z = 0.5
}})Example of distance marker
rcore:createDistanceMarker(1, vector3(v.x,v.y,v.z), Config.ShowDistance, {
onEnter = function()
rcore:showHelpNotification('Zmackni ~INPUT_CONTEXT~ pro otevreni menu')
end,
onEnterKey = function(key)
if key == rcore:getKeys()['E'] then
TriggerEvent('esx_society:openBossMenu', 'bazar', function(data2, menu2)
menu2.close()
end)
end
end
},
{
jobs = { 'bazar' },
grades = { 'boss' },
})