To go into more detail, LUA does not support pointers.
local bone
local success = GetPedLastDamageBone(ped,bone)
This just copied the value of bone when calling the function, you’re just giving GetPedLastDamageBone nil as the 2nd argument, not giving it anything relating to the address of the bone variable, because LUA doesn’t support that like in C.
With any function that returns a pointer in C++'s version of the natives, FiveM makes a pointer for you and returns the result, resulting in what you did being correct. The first value doesn’t need to be an underscore though, you can still use it to make sure a valid bone was returned.
local success,bone = GetPedLastDamageBone(ped)
if success then
-- do something with bone
else
-- couldn't get the bone, uh oh
end
1 Like