Spc Posted March 5, 2018 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?
NeXuS™ Posted March 5, 2018 Posted March 5, 2018 Maybe try detachTrailerFromVehicle. Did I help you? NeXuS™#0001
Spc Posted March 5, 2018 Author Posted March 5, 2018 It's not it.The trailer is attaching and dettaching nonstop.
Moderators IIYAMA Posted March 5, 2018 Moderators Posted March 5, 2018 https://wiki.multitheftauto.com/wiki/OnTrailerDetach see example Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Spc Posted March 5, 2018 Author Posted March 5, 2018 18 minutes ago, IIYAMA said: https://wiki.multitheftauto.com/wiki/OnTrailerDetach see example I want to disable ATTACHING.
Moderators IIYAMA Posted March 5, 2018 Moderators 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) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Moderators IIYAMA Posted March 5, 2018 Moderators Posted March 5, 2018 Does the event gets executed? Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Moderators IIYAMA Posted March 5, 2018 Moderators 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. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
_DrXenon Posted March 6, 2018 Posted March 6, 2018 Maybe try disabling collisions between the truck and the trailer? I think this will work. Maybe try it onTrailerAttach? ●●● Rage Gaming Society Coming Soon ●●●
Spc Posted March 8, 2018 Author 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.
Dimos7 Posted March 8, 2018 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
Spc Posted March 8, 2018 Author 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.
Spc Posted March 8, 2018 Author 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.
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