Marker / TriggerEvent

Any chance some has a code for a marker that if u step in it it will trigger an event?

Sure.

// Put this somewhere (not in a loop obviously)
Vector3 markerPosition = new Vector3(0f, 0f, 0f);
Vector3 markerSize = new Vector3(5f, 5f, 3f);
float halfMarkerWidth = markerSize.X / 2f;
int[] markerColor = new int[4] { 255, 0, 0, 100 }; // RED, GREEN , BLUE, ALPHA

while (true) {
	// Player position
	Vector3 p = GetEntityCoords(PlayerPedId(), LocalPlayer.IsAlive);
	float distance = GetDistanceBetweenCoords(p.X, p.Y, p.Z, markerPosition.X, markerPosition.Y, markerPosition.Z, true);

	// Cap the draw distance (no need to draw marker if player is too far away)
	if (distance < 100f) {
		DrawMarker(1, markerPosition.X, markerPosition.Y, markerPosition.Z, 0f, 0f, 0f, 0f, 0f, 0f, markerSize.X, markerSize.Y, markerSize.Z, markerColor[0], markerColor[1], markerColor[2], markerColor[3], false, true, 2, false, null, null, false);

		if (distance <= halfMarkerWidth) {
			SetTextComponentFormat("STRING");
			AddTextComponentString("Press ~INPUT_CONTEXT~ to XXX.");
			DisplayHelpTextFromStringLabel(0, false, true, -1);

            if (IsControlJustReleased(1, 38)) {
                // Player is in the marker and pressed E, therefore do something.
            }
		}
	}
	await Delay(0);
}
1 Like

yeap got it working with another code but thanks alo!

1 Like

small question any idea how i could accomplish this?

The example I provided you with does exactly the same thing except it does not use any other color than default one.

http://server.edgu.lt/edgu/2018-07-27_18-40-34.png

To change the color of the text you can check this forum post: