Jump to content

onTrailerAttach - cancelEvent() didn't work


Spc

Recommended Posts

Hey, I've got a problem.

function job_trailerAttach(veh)
	cancelEvent()
end
addEventHandler("onTrailerAttach", getRootElement(), job_trailerAttach)

I want to "turn off" the trailer attaching, but cancelEvent() didn't work. There's any solution?

Link to comment
On 5.03.2018 at 19:56, IIYAMA said:

In the description it didn't say that it wouldn't connect. Only that it de-attached directly after that.

So maybe the effect is normal.

 

Probably yes. But i want to disable attaching. Nonstop attaching / dettaching attach is not my goal.

Link to comment
36 minutes ago, Dimos7 said:

function job_trailerAttach(veh)
	cancelEvent()
  detachTrailerFromVehicle(veh, source)
end
addEventHandler("onTrailerAttach", getRootElement(), job_trailerAttach)

 

They're still attaching.

Link to comment

I solved it.

function job_trailerAttach(veh)
	cancelEvent()
	local x, y, z = getElementPosition(veh)
	local x2, y2, z2 = getElementPosition(source)
	local _,_,rz=getElementRotation(veh)
    local rrz=math.rad(rz)
    local x= x + (2 * math.sin(-rrz))
    local y= y + (2 * math.cos(-rrz))

    detachTrailerFromVehicle(veh, source)
	setElementPosition(veh, x, y, z)
	setElementPosition(source, x2, y2, z2)
end
addEventHandler("onTrailerAttach", getRootElement(), job_trailerAttach)

Thank you all for help.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...