Shape testsClient4 outputs

getShapeTestResult

GET_SHAPE_TEST_RESULT0x3D87450E15D98694

The GTA V native GET_SHAPE_TEST_RESULT of the SHAPETEST namespace, as LS:MP client scripts call it: the global function getShapeTestResult, in JavaScript and in Lua.

SignatureJavaScript
getShapeTestResult(shapeTestHandle: number): [
  result: number,
  hit: boolean,
  endCoords: { x: number, y: number, z: number },
  surfaceNormal: { x: number, y: number, z: number },
  entityHit: Entity
]
SignatureLua
getShapeTestResult(
  shapeTestHandle: integer
): integer, boolean, Vector3, Vector3, Entity

Usage

JavaScript
const [result, hit, endCoords, surfaceNormal, entityHit] =
  getShapeTestResult(shapeTestHandle);
Lua
local result, hit, endCoords, surfaceNormal, entityHit =
    getShapeTestResult(shapeTestHandle)

Parameters

ParameterTypeJavaScriptLua
shapeTestHandleintnumberinteger

Returns

5 values, in this order: an array in JavaScript, multiple return values in Lua.

#ValueTypeJavaScriptLuaDescription
1resultintnumberintegerThe native’s own return value.
2hitBOOLbooleanbooleanoutput
3endCoordsVector3{ x: number, y: number, z: number }Vector3output
4surfaceNormalVector3{ x: number, y: number, z: number }Vector3output
5entityHitEntitynumberintegeroutput

On LS:MP

✓
Friendlier helper

lsmp.raycast wraps a synchronous shape test and this call, and returns { hit, position, normal, entity }.

Notes

From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.

Returns the result of a shape test: 0 if the handle is invalid, 1 if the shape test is still pending, or 2 if the shape test has completed, and the handle should be invalidated.

When used with an asynchronous shape test, this native should be looped until returning 0 or 2, after which the handle is invalidated.

Reference

Namespace
Shape tests SHAPETEST
In the game
int GET_SHAPE_TEST_RESULT(int shapeTestHandle, BOOL* hit, Vector3* endCoords, Vector3* surfaceNormal, Entity* entityHit)
Hash
0x3D87450E15D98694
Formerly
_GET_RAYCAST_RESULT

Open in the interactive natives reference