Spc Posted March 5, 2018 Share Posted March 5, 2018 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
NeXuS™ Posted March 5, 2018 Share Posted March 5, 2018 Maybe try detachTrailerFromVehicle. Link to comment
Spc Posted March 5, 2018 Author Share Posted March 5, 2018 It's not it.The trailer is attaching and dettaching nonstop. Link to comment
Moderators IIYAMA Posted March 5, 2018 Moderators Share Posted March 5, 2018 https://wiki.multitheftauto.com/wiki/OnTrailerDetach see example Link to comment
Spc Posted March 5, 2018 Author Share Posted March 5, 2018 18 minutes ago, IIYAMA said: https://wiki.multitheftauto.com/wiki/OnTrailerDetach see example I want to disable ATTACHING. Link to comment
Moderators IIYAMA Posted March 5, 2018 Moderators Share Posted March 5, 2018 function job_trailerAttach(veh) cancelEvent() setElementVelocity ( source, 0, 0, 0 ) end addEventHandler("onTrailerAttach", getRootElement(), job_trailerAttach) or function job_trailerAttach(veh) cancelEvent() setElementVelocity ( source, 0, 0, 0.1 ) end addEventHandler("onTrailerAttach", getRootElement(), job_trailerAttach) (untested) Link to comment
Spc Posted March 5, 2018 Author Share Posted March 5, 2018 I still can attach to the trailer. Link to comment
Moderators IIYAMA Posted March 5, 2018 Moderators Share Posted March 5, 2018 Does the event gets executed? Link to comment
Moderators IIYAMA Posted March 5, 2018 Moderators Share Posted March 5, 2018 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. Link to comment
_DrXenon Posted March 6, 2018 Share Posted March 6, 2018 Maybe try disabling collisions between the truck and the trailer? I think this will work. Maybe try it onTrailerAttach? Link to comment
Spc Posted March 8, 2018 Author Share Posted March 8, 2018 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
Dimos7 Posted March 8, 2018 Share Posted March 8, 2018 (edited) function job_trailerAttach(veh) cancelEvent() detachTrailerFromVehicle(veh, source) end addEventHandler("onTrailerAttach", getRootElement(), job_trailerAttach) Edited March 8, 2018 by Dimos7 1 Link to comment
Spc Posted March 8, 2018 Author Share Posted March 8, 2018 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
Spc Posted March 8, 2018 Author Share Posted March 8, 2018 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
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