Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RedM] GET_SHAPE_TEST_RESULT_INCLUDING_MATERIAL - Extra Native Error #2453

Closed
Alexr03 opened this issue Apr 11, 2024 · 6 comments
Closed

[RedM] GET_SHAPE_TEST_RESULT_INCLUDING_MATERIAL - Extra Native Error #2453

Alexr03 opened this issue Apr 11, 2024 · 6 comments
Labels
bug RedM Issues/PRs related to RedM

Comments

@Alexr03
Copy link

Alexr03 commented Apr 11, 2024

What happened?

When attempting to use the GET_SHAPE_TEST_RESULT_INCLUDING_MATERIAL native that was introduced in #1495 an error is thrown.

RedM_b1491_GTAProcess_9ae96165-37cc-4ffb-a21e-3b0696639cde

Expected result

Shape test result returns normal data along with material hash

Reproduction steps

This should return the shape test result of the ground in front of you.

  1. client;.lua
local testCoords = GetEntityCoords(PlayerPedId()) + vector3(0.0, 0.5, 0.0)
local testEndCoords = testCoords + vector3(0.0, 0.0, -1.5)
local shapeTest = StartExpensiveSynchronousShapeTestLosProbe(testCoords.x, testCoords.y, testCoords.z, testEndCoords.x, testEndCoords.y, testEndCoords.z, 0, 0, 4)

local retval, hit, endCoords, surfaceNormal, materialHash, entityHit = Citizen.InvokeNative(0x4301E10C, shapeTest)

print('GET_SHAPE_TEST_RESULT_INCLUDING_MATERIAL', retval, hit, endCoords, surfaceNormal, materialHash, entityHit)
  1. Observe F8 console

Importancy

Slight inconvenience

Area(s)

RedM

Specific version(s)

RedM 7788

Additional information

No response

@Alexr03 Alexr03 added bug triage Needs a preliminary assessment to determine the urgency and required action labels Apr 11, 2024
@github-actions github-actions bot added the RedM Issues/PRs related to RedM label Apr 11, 2024
@Alexr03 Alexr03 changed the title GET_SHAPE_TEST_RESULT_INCLUDING_MATERIAL - Extra Native Error [RedM] GET_SHAPE_TEST_RESULT_INCLUDING_MATERIAL - Extra Native Error Apr 11, 2024
@thelindat
Copy link
Contributor

Can't you use the actual named native now, rather than invoking? GetShapeTestResultIncludingMaterial.
Otherwise pretty sure you'd need to pass pointer-args.

@Disquse
Copy link
Contributor

Disquse commented Apr 12, 2024

Thanks @thelindat, indeed if you want to return any pointer values from a raw Citizen.InvokeNative call, you should pass pointer catching arguments. Here's an example:

      local retval, hit, endCoords, surfaceNormal, materialHash, entityHit = Citizen.InvokeNative(GetHashKey("GET_SHAPE_TEST_RESULT_INCLUDING_MATERIAL") & 0xFFFFFFFF, shapeTest,
        Citizen.PointerValueInt(), Citizen.PointerValueVector(), Citizen.PointerValueVector(), Citizen.PointerValueInt(), Citizen.PointerValueInt(), Citizen.ReturnResultAnyway())

Let me know if this code will work for you.

@Alexr03
Copy link
Author

Alexr03 commented Apr 12, 2024

Ah perfect, yes the code above works, I had tried something similar but I was using ResultAs...() instead of PointerValue...() 😭.
I did try with a named native before, and just tried again to make sure I wasn't going mad, the named native doesn't seem to work, its nil and doesn't resolve to a function.
RedM_b1491_GTAProcess_f2bc0e49-7e78-4dbb-98a4-1054189e724a

@Sojobo
Copy link

Sojobo commented Apr 13, 2024

I seem to be getting the following hash returned as the material everywhere: -1775485061. I'm trying to get the ground material and I've messed around with the coords and using offsets and other shapetests, the method I use, which works on FiveM is just returning that same hash everywhere in RedM. Does the native work differently here? Is there a different method of grabbing the ground material that I should be using?

@Disquse
Copy link
Contributor

Disquse commented Apr 15, 2024

@Alexr03 The declaration for this native is currently only available on Canary.

@Sojobo if your code works in FiveM, it doesn't mean it's going to work on RedM without any changes. This is a perfect example of that. -1775485061 is a hash of the "DEFAULT" material name, but Red Dead Redemption 2 now expects material names to have a suffix containing their internal index. For example, "DEFAULT" becomes "DEFAULT_0", "PROP_ROCK" becomes "PROP_ROCK_207", and so on.

I'm attaching a small script for you guys to test it out:
https://pastebin.com/eqJk0Zhp
RedM_b1491_GTAProcess_sIuQUmkYHU

@Sojobo
Copy link

Sojobo commented Apr 15, 2024

Thanks for the example code there @Disquse - I've tested it out and it actually showcases my issue pretty well, it looks like most of the world is actually just default material, the solution for my use-case is probably just checking to make sure that it is default and nothing else. I'm trying to do a farming script and I don't want players putting crops on roofs or other places that don't make sense. Looks like roads and buildings all have something other than default while fields are all default though so yeah, checking for default probably works for me, thanks again!

@Disquse Disquse closed this as completed Apr 15, 2024
@github-actions github-actions bot removed the triage Needs a preliminary assessment to determine the urgency and required action label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug RedM Issues/PRs related to RedM
Projects
None yet
Development

No branches or pull requests

4 participants