alberto2345 Posted January 11, 2016 Share Posted January 11, 2016 Hi everyone, I was thinking today that it would be cool to have a truck with more than 1 trailer. There is a truck in the game called a Road Train, and like I've seen in Australia, these kinds of trucks usually have more than 1 trailer. I created a simple script that allows this! Download link: https://community.multitheftauto.com/index.php?p= ... s&id=12529 Screenshot: How it works: It basically created an invisible truck at the trailer, so when you back the trailer up into another trailer, they connect! Hope you enjoy and maybe someone will find it useful. Link to comment
Olle Risk Posted January 11, 2016 Share Posted January 11, 2016 Nice work, but just for curiosity, have you disabled collisions for the invisible truck? and did you managed to solve the desynchronize issue that occurs during stream in and out. You know the one where trailers upon stream in spawn at random locations around the truck. It get's even worse with multiple trailers if you know what I mean Link to comment
alberto2345 Posted January 12, 2016 Author Share Posted January 12, 2016 The sync with the trucks is an MTA sync issue, so I'd say it still would appear with this as well which is a shame. But once it gets fixed, this script should be alot better and more useful. And ye, the collisions with the invisible trucks are disabled, along with them being damage proof and locked. Link to comment
Tekken Posted January 12, 2016 Share Posted January 12, 2016 Simple but good, I like it, nice work. Link to comment
alberto2345 Posted January 12, 2016 Author Share Posted January 12, 2016 Thanks man, I appreciate it Link to comment
Mega9 Posted January 12, 2016 Share Posted January 12, 2016 I've made something like this a while back, allowing any amount of trailers, but there would always be a heavy desync after 5th/6th trailer even for local player. Not sure if anything has changed but it was pretty bad back then; it's probably why we don't see them in use on servers. All in all good job! Link to comment
killeryoyo Posted January 12, 2016 Share Posted January 12, 2016 there is always a big problem in syncing the trailers. you can see it attached well in your truck and other players can see it flying and out of truck far away. did anyone solve that problem till now? Link to comment
Noki Posted January 12, 2016 Share Posted January 12, 2016 I love seeing experimental stuff like this. Link to comment
Olle Risk Posted January 14, 2016 Share Posted January 14, 2016 there is always a big problem in syncing the trailers. you can see it attached well in your truck and other players can see it flying and out of truck far away.did anyone solve that problem till now? The only solution I know is this: addEventHandler("onClientElementStreamIn", getRootElement( ), function ( ) if not getElementData(source, "GTWvehicles.isTrailerTowingVehile") then return end local trailer = getElementData(source, "GTWvehicles.attachedTrailer") attachTrailerToVehicle(source, trailer) end ); addEventHandler( "onClientElementStreamOut", getRootElement( ), function ( ) if getElementData(source, "GTWvehicles.isTrailerTowingVehile") then local trailer = getElementData(source, "GTWvehicles.attachedTrailer") if isElementStreamedIn(source) and isElementStreamedIn(trailer) then detachTrailerFromVehicle(source, trailer) end elseif getElementData(source, "GTWvehicles.isTrailer") then local tower = getElementData(source, "GTWvehicles.towingVehicle") if isElementStreamedIn(tower) and isElementStreamedIn(source) then detachTrailerFromVehicle(tower, source) end end end ); From GTW-RPG, the truck knows it's trailer and the trailer knows it's truck. That's what's stored as element data but the whole resource is a big mess and this is the important part. So the problem appears to be when the vehicles is streaming out as it doesn't happen the same time, not even when attached and that's why some players sees it as attached and others don't. In theory if you detach them client side when streaming out and attach them when streaming in it should provide perfect sync. Not sure if it works tho. Link to comment
Captain Cody Posted January 24, 2016 Share Posted January 24, 2016 Something that worked for when I was working on a train script, is to set it so when someone enters the truck it sets the elements streamer to the driver of the truck and only the driver of the truck. This prevents the trailers from destreaming and breaking, keeps all the trailers on the same streamer. Forgot the exact function but you can find it on the wiki easily. Shouldn't cause any extra lag unless you have 50+ simis, which you probably wont. Link to comment
Tekken Posted January 25, 2016 Share Posted January 25, 2016 Something that worked for when I was working on a train script, is to set it so when someone enters the truck it sets the elements streamer to the driver of the truck and only the driver of the truck. This prevents the trailers from destreaming and breaking, keeps all the trailers on the same streamer. Forgot the exact function but you can find it on the wiki easily. Shouldn't cause any extra lag unless you have 50+ simis, which you probably wont. You mean setElementSyncer? Link to comment
Captain Cody Posted January 25, 2016 Share Posted January 25, 2016 https://wiki.multitheftauto.com/wiki/Se ... Streamable Das is what I was thinking of, wrong description, setting the element non streamable will prevent the element from streaming out, preventing the trailers from going wack. 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