Mittell Buurman Posted October 24, 2013 Share Posted October 24, 2013 explanation: the truck (linerunner) atteches to the trailer and runs a check, if the company names are not the same, it detaches. As far as the code goes, everything is working as it should and it does detach. The Issue: As soon as the trailer detaches it immediately re-attaches. How can I prevent the trailer from reattaching to the linerunner after it detaches? I did try cancelEvent, but it didn't detach NOTE: I'm asking for Experienced lua coders who know about GTA & MTA mechanics, you do not need any other code than the one that is currently listed. server: addEventHandler('onTrailerAttach', getRootElement(), function(truck) if(isElement(truck) and getElementType(truck)=='vehicle') then trailer = getVehicleTowedByVehicle(truck) local compTruck = getElementData(truck, "vehicle:company") local compTrailer = getElementData(trailer, "vehicle:company") local x, y, z = getElementPosition(truck) if (compTruck~=compTrailer) then outputChatBox("This trailer does not belong to your company.", ply, 255, 200, 0) detachTrailerFromVehicle(truck, trailer) end end end ) Link to comment
Dealman Posted October 24, 2013 Share Posted October 24, 2013 Not entirely sure how trailers work, but it might be that it's detached properly but not moved away enough to stay detached - thus it automatically re-attaches again. So one thing you could try would be to change the trailer's position slightly after it is detached. If that doesn't work, then it's something with the code for sure. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now