description |
---|
Distance markers |
rcore provides 2 ways to create markers, in the older version there was distance marker and classic marker but we remove classic marker because its not good for performance to create marker that is still rendering.
Newer version using object with function, better show to understand the difference of these methods.
{% code title="client_side.lua" %}
rcore = exports.rcore
function createMarker()
marker = rcore:createMarker();
marker.setPosition(vector3(1729.89,3313.33,40.22))
marker.render();
marker.on('enter',function()
dbg.info('On enter')
end)
marker.on('leave', function()
dbg.info('on leave')
end)
marker.setKeys({
keys['E'],
})
marker.on('key', function(pressed)
dbg.info('on key press %s',pressed)
end)
Citizen.Wait(20000)
marker.stopRender()
end
{% endcode %}
Simple function that create empty marker for you
Using vector3 as parameter to setup position of marker
Starts rendering the marker
Stops rendering
Marker on is a function that will provides you simple API to create 3 callbacks that you need and that is
- enter - on player enter the marker
- leave - on player leave the marker
- key - on player press any setup key when is in marker
{% hint style="warning" %} on key is calling only if you setup which keys it should monitoring, look at example, its using function setKeys {% endhint %}
Syntax
{% tabs %} {% tab title="Enter" %}
marker.on('enter',function()
print('On enter')
end)
{% endtab %}
{% tab title="Leave" %}
marker.on('leave', function()
print('on leave')
end)
{% endtab %}
{% tab title="Key" %}
rcore = exports.rcore
keys = rcore:getKeys()
marker.setKeys({
keys['E'],
})
marker.on('key', function(pressed)
print('on key press %s',pressed)
end)
{% endtab %} {% endtabs %}
Change type of marker, you can find all types in official documentation https://docs.fivem.net/docs/game-references/markers/
Default value for render distance is 20 if you need to be smaller or bigger just set it here
Set/Get direction of marker
Set/Get rotation of marker
Set/Get scale of marker
you can set color with RGBA table {r = 0, g= 0, b=255,a=255} or you can set every color by self
- setAlpha(alpha)
- getAlpha()
- setRed(red)
- getRed()
- setGreen(green)
- getGreen()
- setBlue(blue)
- getBlue()
Its not rotation of marker but if marker should rotate!
Set/Get radius for calling enter/leave function