AttachEntityToEntity - car to trailer - need help, please!

Hello, dear community!

I am working on another small script which would allowed me to actually freeze car standing on top of car trailer without using any traditional trainer menu, since on our server, we have scripthook disabled.

This is what I’ve came up with so far. But it doesn’t work and leave no errors… Could someone point me a good direction here?? :slight_smile:

local targetVehicle = GetVehiclePedIsIn(GetPlayerPed(-1), false)
local isVehicleTrailer	= GetHashKey('cartr16')
local NearestCarTrailer = GetClosestVehicle(GetEntityCoords(isVehicleTrailer, true), 1000.0, 0, 4)	


Citizen.CreateThread(function()
while true do
Citizen.Wait(0)

	if IsControlPressed(0, Keys['E']) and if IsPedInVehicle(GetPlayerPed(-1), false) then 
		AttachEntityToEntity(targetvehicle, NearestCarTrailer, 20, -0.5, -12.0, 1.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)			
	end
end
		
	if IsControlPressed(0, 170) and IsPedInVehicle(targetVehicle) then 
		DetachEntity(targetVehicle, false, false)
		--vehicle = nil
	end
  end
end) 

I have been trying to find suitable car trailer and narrowed selection to two models online, but everyone has it’s pros and cons.

This first one is really great, even has detachtable ramp as an extra, but it’s buggy - you have to be in position of “driver” to be able to manipulate the ramp and sometimes, from uknown reason, you can’t get to driver seat anymore… So you can’t load your car on trailer again.

  • another annoying thing is that with every car with lower profile, you will loose doors, since it has very badly placed wheel base and it’s collision with anything that’s on top of the trailer…

Problem could be theoretically solved by editing the collision data, but I am noob and can’t do that yet (this trailer is unlocked)

This second one is better, doesn’t need ramp manipulation, it hasn’t have mentioned collision problems, but car on this trailer is even more unstable that on previous one.

From this reason, I want to create some sort of very simple car trailer menu allowing to players attach the one entity to another

(that could be even allowed under condition of owning the entity as we operate with SQL database, so trolls should be eliminated by this)

Does anybody have experience with this? Any advices? Thank you for all answers in advance :slight_smile:

2 Likes

@Lukepollie i belive this guy did it :slight_smile:

1 Like

I’ve left him a msg. Hopefully he will reply back (and with something cheerful, I am dead end now, lol). :slight_smile:

Hey! any news on this?

Not for now, I had different priorities lately. And it looks I will have to place a private order on custom trailer, since none of existing ones isn’t suitable for what I have in mind. Once I will have an updates, I will definitely post it here :slightly_smiling_face:

There is a few really great closed and normal trailers on gta-mods… just need a way to make the cars stay on them lol

Well, I have problem with many of them to be very glitchy when you are about to get into the car which is already on top of a trailer. BUT, if there would be additional platform for actual player model to step onto before going into the car, nothing will happen. But there is not such a trailer yet, unfortunatelly…

yeah that issue just persists with the attach… once we get it to attach to the trailer we won’t have any issues

Attach entity to entity isn’t what I am talking about. It’s hard to explain and I don’T have uploaded video. I will keep this thread informed when I will have more info on this :slight_smile:

Have you had any luck sir?

1 Like

Not yet, I have to focus on different things atm, but I will keep this updated once I will find something out.

I wanted to use this trailer but did not connect the vehicle and the trailer together.

With the completion of the rollback flatbed. Could something like that be used? I am really needing a car hauler!

Any update on this script?

omg that is so epic

btw guys, its wooder, not water

Anyone found a fix or got this to work by chance?

1 Like