From 15a264c3c976f0ba2d84cc91bb2c17686120884e Mon Sep 17 00:00:00 2001 From: Hakos47 <76844995+hakos47@users.noreply.github.com> Date: Thu, 23 Mar 2023 12:24:30 +0100 Subject: [PATCH 1/5] GetGroundHash returns the hash of the terrain you are on. quite useful for planting scripts --- client/functions.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/functions.lua b/client/functions.lua index e9f2ca8..f235581 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -991,4 +991,11 @@ function QBCore.Functions.GetGroundZCoord(coords) print(coords) return coords end -end \ No newline at end of file +end + +function QBCore.Functions.GetGroundHash(entity) + local coords = GetEntityCoords(entity) + local num = StartShapeTestCapsule(coords.x,coords.y,coords.z+4,coords.x,coords.y,coords.z-2.0, 1,1,veh,7) + local arg1, arg2, arg3, arg4, arg5 = GetShapeTestResultEx(num) + return arg5 +end From 66c88b51e05f8bbea44c58684e6de9f3d07d3307 Mon Sep 17 00:00:00 2001 From: Hakos47 <76844995+hakos47@users.noreply.github.com> Date: Thu, 23 Mar 2023 12:29:46 +0100 Subject: [PATCH 2/5] GetGroundHash returns the hash of the terrain you are on. quite useful for planting scripts --- client/functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/functions.lua b/client/functions.lua index f235581..8f1d03c 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -995,7 +995,7 @@ end function QBCore.Functions.GetGroundHash(entity) local coords = GetEntityCoords(entity) - local num = StartShapeTestCapsule(coords.x,coords.y,coords.z+4,coords.x,coords.y,coords.z-2.0, 1,1,veh,7) + local num = StartShapeTestCapsule(coords.x,coords.y,coords.z+4,coords.x,coords.y,coords.z-2.0, 1,1,entity,7) local arg1, arg2, arg3, arg4, arg5 = GetShapeTestResultEx(num) return arg5 end From 50d73ed52bf5199c3f9f760d0e789b1ed5dcb9e2 Mon Sep 17 00:00:00 2001 From: Hakos47 <76844995+hakos47@users.noreply.github.com> Date: Thu, 23 Mar 2023 12:44:34 +0100 Subject: [PATCH 3/5] fix lint failed return material hash , entity hit, surfaceNormal, end coords, hit, and retval --- client/functions.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/functions.lua b/client/functions.lua index 8f1d03c..8772363 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -996,6 +996,6 @@ end function QBCore.Functions.GetGroundHash(entity) local coords = GetEntityCoords(entity) local num = StartShapeTestCapsule(coords.x,coords.y,coords.z+4,coords.x,coords.y,coords.z-2.0, 1,1,entity,7) - local arg1, arg2, arg3, arg4, arg5 = GetShapeTestResultEx(num) - return arg5 + local retval --[[ integer ]], hit --[[ boolean ]], endCoords --[[ vector3 ]], surfaceNormal --[[ vector3 ]], materialHash --[[ Hash ]], entityHit --[[ Entity ]] = GetShapeTestResultEx(num) + return materialHash, entityHit, surfaceNormal, endCoords, hit, retval end From 6738c06d5502a46bb73b0e56ba1de1b6afb94fed Mon Sep 17 00:00:00 2001 From: Hakos47 <76844995+hakos47@users.noreply.github.com> Date: Thu, 23 Mar 2023 15:02:35 +0100 Subject: [PATCH 4/5] Update functions.lua --- client/functions.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/functions.lua b/client/functions.lua index 8772363..324b974 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -996,6 +996,6 @@ end function QBCore.Functions.GetGroundHash(entity) local coords = GetEntityCoords(entity) local num = StartShapeTestCapsule(coords.x,coords.y,coords.z+4,coords.x,coords.y,coords.z-2.0, 1,1,entity,7) - local retval --[[ integer ]], hit --[[ boolean ]], endCoords --[[ vector3 ]], surfaceNormal --[[ vector3 ]], materialHash --[[ Hash ]], entityHit --[[ Entity ]] = GetShapeTestResultEx(num) - return materialHash, entityHit, surfaceNormal, endCoords, hit, retval + local retval , success , endCoords, surfaceNormal, materialHash , entityHit = GetShapeTestResultEx(num) + return materialHash, entityHit, surfaceNormal, endCoords, success, retval end From 4ba2262a27f11b297729ffc472ebd7c5626422c1 Mon Sep 17 00:00:00 2001 From: Zerio <54480523+Z3rio@users.noreply.github.com> Date: Sat, 25 Mar 2023 14:19:51 +0100 Subject: [PATCH 5/5] Improve code readability --- client/functions.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/functions.lua b/client/functions.lua index 324b974..8185648 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -995,7 +995,7 @@ end function QBCore.Functions.GetGroundHash(entity) local coords = GetEntityCoords(entity) - local num = StartShapeTestCapsule(coords.x,coords.y,coords.z+4,coords.x,coords.y,coords.z-2.0, 1,1,entity,7) - local retval , success , endCoords, surfaceNormal, materialHash , entityHit = GetShapeTestResultEx(num) + local num = StartShapeTestCapsule(coords.x, coords.y, coords.z + 4, coords.x, coords.y, coords.z - 2.0, 1, 1, entity, 7) + local retval, success, endCoords, surfaceNormal, materialHash, entityHit = GetShapeTestResultEx(num) return materialHash, entityHit, surfaceNormal, endCoords, success, retval end