Attach Boat To Trailer


#1

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


#2

Can you post how you have your code?


#3
	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…


#4
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.


#5

Unpacking works. I can get the correct coords. I will try the hash thing later


#6

Still nothing :expressionless:


#7

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?


#8

No errors just doesnt work :frowning:


#9

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)

#10

Did this ever work???


#11

did you ever get this to work


#12

Try with this maybe
https://runtime.fivem.net/doc/reference.html#_0x3C7D42D58F770B54