Hello, Guest

By registering with us, you'll be able to discuss, share and private message with other members of our community.
What's new

Adding markers and checkpoints to the rage:mp server

Alexalsaud

Administrative
Staff member
Admin
Joined
Aug 5, 2024
Messages
337
ICoins
1,501
Adding markers and checkpoints to the rage:mp server

In this tutorial, we'll look at working with markers and checkpoints in rage mp.

Markers

The mp.markers.new method is used to create a marker

JavaScript:
mp.markers.new(type, position, scale,
{
direction: direction,
rotation: rotation,
color: color,
visible: visible,
dimension: dimension
});

We have 3 mandatory arguments:
  • type - the appearance of the marker. A total of 45 options, a list of them can be found on the .
  • position - an object of the Vector3 type with the coordinates of the point at which the marker should be.
  • scale - the size of the marker. You can make markers of different sizes by controlling this through scale.
Example of use:

JavaScript:
mp.markers.new(1, {x: -412.3, y: 1218.3, z: 324.7}, 2);

1725038638284.png

As a standard, the marker is white, but we can change it using the optional parameters.

JavaScript:
mp.markers.new(1, {x: -412.3, y: 1218.3, z: 324.7}, 2, {
color: [255, 0, 0, 100] // [красный, зеленый, синий, альфа]
});
1725038664522.png
We can also change the direction and rotation (obviously, this will not make sense for all markers), as well as hide the marker via visible or move it to another dimension.

If necessary, we can change the properties of the marker after it has been created. All properties can be changed directly, e.g. marker.scale = 10;. The only exception is the color, which can be changed using the special setColor method:

JavaScript:
marker.setColor(r, g, b, a);

Checkpoints
Racing are separated into a separate entity and are created by a different method. But in fact, they have the same set of arguments (except for rotation, they are always round and there is no point in twisting them).

JavaScript:
mp.checkpoints.new(1, {x: -412.3, y: 1218.3, z: 324.7}, 2);



1725038706818.png
Otherwise, I don't see much difference from markers in terms of creation and parameters.


Marker / Checkpoint
Detection The main difference between markers and checkpoints is the way a player is determined to hit them. The following events are available for checkpoints:



For example,
JavaScript:
mp.events.add("playerEnterCheckpoint", (player, checkpoint) => {
// Код сработает при попадании игрока в чекпоинт
});

For markers, there are no such events (at least they are not documented on Wikipedia). Therefore, it is customary to additionally create colshapes for markers - invisible areas on the map of different shapes, the intersection with which can be detected, and there are separate events for this:



We just put a colshape of the same size and shape as the marker on the same coordinates. And when a player hits a colshape, it's like hitting a marker. An example of such an implementation can be found in the lesson on creating a trucker script.
 
Back
Top