Skip to content

A3D_GetScreenTarget

imshooter edited this page Oct 17, 2026 · 1 revision

Find what a point of the screen of a player shows, such as the place they clicked on a grid of text draws.

The player and the vehicle they are in are never hit.

native bool:A3D_GetScreenTarget(
    playerid,
    Float:screenX,
    Float:screenY,
    &Float:x,
    &Float:y,
    &Float:z,
    &A3D_HIT:type = A3D_HIT_MAP,
    &hitid = 0,
    &material = 0,
    Float:range = 100.0,
    A3D_COLLIDE:flags = A3D_COLLIDE_ALL
);

Parameters

Parameter Description Default
playerid Player whose screen it is.
Float:screenX Point across the screen.
Float:screenY Point down the screen.
&Float:x Point shown on the X axis.
&Float:y Point shown on the Y axis.
&Float:z Point shown on the Z axis.
&A3D_HIT:type What it shows. A3D_HIT_MAP
&hitid Model of the map object, or the physics object, static object, player, vehicle or actor. 0
&material Surface of the game it shows. 0
Float:range How far to look. 100.0
A3D_COLLIDE:flags What may be shown. A3D_COLLIDE_ALL

Returns

  • true when something shows there within range.
  • false when nothing, or the player sent no camera yet.

Remarks

The ray starts at the camera and goes through the point of the screen. The player and the vehicle they are in are never hit. Everything else follows A3D_RayCast.

A text draw that a player clicks gives no position, only which text draw it was. A grid of clickable text draws turns each click into a point of the screen, and this native turns that point into a place in the world.

Example

An air strike on the place a player clicks, on a grid of six cells.

static PlayerText:gCells[MAX_PLAYERS][6];

stock ShowStrikeGrid(playerid) {
    for (new i; i != 6; ++i) {
        gCells[playerid][i] = CreatePlayerTextDraw(playerid, 106.7 + float(i % 3) * 213.3, 112.0 + float(i / 3) * 224.0, "+");
        PlayerTextDrawTextSize(playerid, gCells[playerid][i], 40.0, 40.0);
        PlayerTextDrawSetSelectable(playerid, gCells[playerid][i], true);
        PlayerTextDrawShow(playerid, gCells[playerid][i]);
    }

    SelectTextDraw(playerid, 0xFF0000FF);
}

public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid) {
    new
        Float:x,
        Float:y,
        Float:z,
        A3D_HIT:type,
        hitid,
        material
    ;

    for (new i; i != 6; ++i) {
        if (gCells[playerid][i] != playertextid) {
            continue;
        }

        if (A3D_GetScreenTarget(playerid, 106.7 + float(i % 3) * 213.3, 112.0 + float(i / 3) * 224.0, x, y, z, type, hitid, material, 300.0)) {
            CreateExplosion(x, y, z, 7, 10.0);
        }

        return 1;
    }

    return 0;
}

Related

  • A3D_ScreenToWorld: Find the direction a point of the screen of a player looks into, from the position of their camera.
  • A3D_GetPlayerTarget: Find what a player looks at, from their camera.
  • A3D_RayCast: Find the first thing a segment between two points hits.

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