RedM Natives

GET_SHAPE_TEST_RESULT_INCLUDING_MATERIAL

Returns the result of a shape test, also returning the material of any touched surface.

Hash0x4301E10C
Runtime nameGetShapeTestResultIncludingMaterial
NamespaceCFX
SideClient
NameOfficial
Docs

Signature

int GET_SHAPE_TEST_RESULT_INCLUDING_MATERIAL(int shapeTestHandle, BOOL* hit, Vector3* endCoords, Vector3* surfaceNormal, Hash* materialHash, Entity* entityHit);

Parameters

NameTypeDescription
shapeTestHandleint

A shape test handle.

hitBOOL*

Whether or not the shape test hit any collisions.

endCoordsVector3*

The resulting coordinates where the shape test hit a collision.

surfaceNormalVector3*

The surface normal of the hit position.

materialHashHash*

hash of the hit material or surface type, see materialFX.dat

entityHitEntity*

Any dynamic entity hit by the shape test.

Returns int — `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.

Description

Cfx.re native reference

Returns the result of a shape test, also returning the material of any touched surface.

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

Unless the return value is 2, the other return values are undefined.

Usage

Lua
local retval, hit, endCoords, surfaceNormal, materialHash, entityHit = GetShapeTestResultIncludingMaterial(shapeTestHandle)

-- always works, by hash
local retval, hit, endCoords, surfaceNormal, materialHash, entityHit = Citizen.InvokeNative(0x4301e10c, shapeTestHandle, Citizen.PointerValueInt() --[[ BOOL* ]], Citizen.PointerValueVector(), Citizen.PointerValueVector(), Citizen.PointerValueInt(), Citizen.PointerValueInt(), Citizen.ResultAsInteger())
JavaScript and C#
JavaScript
const [retval, hit, endCoords, surfaceNormal, materialHash, entityHit] = GetShapeTestResultIncludingMaterial(shapeTestHandle);

// by hash
const [retval, hit, endCoords, surfaceNormal, materialHash, entityHit] = Citizen.invokeNative('0x4301e10c', shapeTestHandle, Citizen.pointerValueInt() /* BOOL* */, Citizen.pointerValueVector(), Citizen.pointerValueVector(), Citizen.pointerValueInt(), Citizen.pointerValueInt(), Citizen.returnResultAnyway(), Citizen.resultAsInteger());
C#
var hit = new OutputArgument();
var endCoords = new OutputArgument();
var surfaceNormal = new OutputArgument();
var materialHash = new OutputArgument();
var entityHit = new OutputArgument();
int retval = Function.Call<int>((Hash)0x4301e10c, shapeTestHandle, hit, endCoords, surfaceNormal, materialHash, entityHit);
// hit.GetResult<bool>()
// endCoords.GetResult<Vector3>()
// surfaceNormal.GetResult<Vector3>()
// materialHash.GetResult<int>()
// entityHit.GetResult<int>()
  • Pointer (out) arguments are not passed in Lua/JS: their values are returned after the result, in order.

Sources

Cfx.re native reference

Something wrong or missing? Contribute a verified note — corrections ship through pull requests.