GetShapeTestResultIncludingMaterial
Docslocal retval, hit, endCoords, surfaceNormal, materialHash, entityHit = GetShapeTestResultIncludingMaterial(shapeTestHandle)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.
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. |
Quick Snippet: Get CoordinatesendCoordssurfaceNormal
endCoordssurfaceNormalAdd this command to your client script to retrieve precise locations in-game.
-- Add this to your client.lua. Type /pos in-game to copy coords.
RegisterCommand('pos', function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local output = string.format("vector4(%.2f, %.2f, %.2f, %.2f)", coords.x, coords.y, coords.z, heading)
print(output)
TriggerEvent('chat:addMessage', { args = { '^4[COORD]^0', output } })
end)Quick Snippet: Get EntityentityHit
entityHitUse this to obtain an entity handle from the player's aim or crosshair.
-- Get the entity the player is aiming at
local ped = PlayerPedId()
local hit, entity = GetEntityPlayerIsFreeAimingAt(PlayerId())
if hit and entity ~= 0 then
print("Entity: " .. entity)
print("Model: " .. GetEntityModel(entity))
print("Type: " .. GetEntityType(entity)) -- 1=Ped, 2=Vehicle, 3=Object
endReturns
intReturns an integer value.