I cannot seem to get my attach entity to entity to work. I’m using it to get the closest model by the hash “boattrailer” but I get nothing
Can you post how you have your code?
x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
vX, vY, vZ = table.unpack(GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), false), true))
xRot, yRot, zRot = table.unpack(GetEntityRotation(GetVehiclePedIsIn(GetPlayerPed(-1), false), 0))
AttachEntityToEntityPhysically(GetVehiclePedIsIn(-1, false), GetClosestVehicle(x, y, z, 10, "boattrailer", 70), GetEntityBoneIndexByName(GetVehiclePedIsIn(-1, false), "chassis"), GetEntityBoneIndexByName(GetClosestVehicle(x, y, z, 10, "boattrailer", 70), "chassis"), vX, vY, vZ, vX, vY, vZ, xRot, yRot, zRot, false, false, false, false, 2, true)
This is what Im trying to use…
x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
vX, vY, vZ = table.unpack(GetEntityCoords(GetVehiclePedIsIn(GetPlayerPed(-1), false), true))
xRot, yRot, zRot = table.unpack(GetEntityRotation(GetVehiclePedIsIn(GetPlayerPed(-1), false), 0))
Have you used the table.unpack(GetEntityCoords(…)) before? I’m no expert, but I just have not seen that before.
I usually see something like this when it comes to coords:
pos = GetEntityCoords(GetPlayerPed(-1))
vehicle = GetClosestVehicle(pos['x'], pos['y'], pos['z'], ...otherParameters...)
However if your method works the same then try using GetHashKey(“boattrailer”) instead of just "boattrailer". I believe that the function GetClosestVehicle uses the vehicle hash and not the name.
Unpacking works. I can get the correct coords. I will try the hash thing later
Still nothing
Hmm, try changing some of the parameters at the end maybe?
After rotation your parameters are:
… false, false, false, false, 2, true)
Try changing to:
… 25.0, 1, false, 0, 0, 2)
Also, are you getting any errors in the console?
No errors just doesnt work
This might help you with how I get coords instead of using table.unpack
local Pos = GetEntityCoords(GetPlayerPed(-1), true)
local Count , entity1 = GetClosestPed(Pos["x"], Pos["y"], Pos["z"], 99.99,1,1,0)
Did this ever work???
did you ever get this to work