GET_SHAPE_TEST_RESULT_INCLUDING_MATERIAL
Returns the result of a shape test, also returning the material of any touched surface.
Signature
int GET_SHAPE_TEST_RESULT_INCLUDING_MATERIAL(int shapeTestHandle, BOOL* hit, Vector3* endCoords, Vector3* surfaceNormal, Hash* materialHash, Entity* entityHit);Parameters
| Name | Type | Description |
|---|---|---|
shapeTestHandle | int | A shape test handle. |
hit | BOOL* | Whether or not the shape test hit any collisions. |
endCoords | Vector3* | The resulting coordinates where the shape test hit a collision. |
surfaceNormal | Vector3* | The surface normal of the hit position. |
materialHash | Hash* | hash of the hit material or surface type, see materialFX.dat |
entityHit | Entity* | 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
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
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#
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());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
Something wrong or missing? Contribute a verified note — corrections ship through pull requests.