Skip to content

Other Components

imshooter edited this page Nov 3, 2026 · 1 revision

Other open.mp components can use the map and the bodies of 3DAndreas in C++, through include/3DAndreas.hpp. A damage component can check for walls between a shooter and a target, or an NPC component can find the ground under a point, without going through Pawn.

#include "3DAndreas.hpp"

A3D::IComponent3DAndreas* physics = nullptr;

void onInit(IComponentList* components) override {
	physics = components->queryComponent<A3D::IComponent3DAndreas>();
}

bool canSee(Vector3 from, Vector3 to) {
	return physics == nullptr || physics->isLineOfSight(from, to, -1, A3D::CollideMap | A3D::CollideObjects);
}

queryComponent gives nullptr when 3DAndreas is not loaded, so the other component keeps working without it.

Calls

Call What it does
isLineOfSight(from, to, world, flags) Whether nothing of the kinds in flags lies between two points.
castRay(from, to, world, flags, hit) The first thing a segment touches: its point, the side of the surface facing the ray, what it is, its id in Pawn and its surface.
findGround(point, depth, world, flags, z) The height of the first surface under a point, at most depth below it.

world is a virtual world, or -1 for every world. flags takes the values of Collision flags, which A3D::Collide names in C++. hit.type takes the values of Hit types.

Every call reads the world the server steps on its main thread, so it is made from that thread: in a tick, an event or a native, never from a worker thread.

Home

Guides

Reference

Functions

Creating objects
Motion
Placement
Behaviour
Display and data
Rays
Shapes
Players, vehicles and actors
Map probes
Screen
Map objects
Water
Models and surfaces
Rotations and offsets
Vehicles
Routes
Route display
Walking
Callbacks

Clone this wiki locally