Jump to content

Bad truck trailer synchronisation


Kayl

Recommended Posts

Posted

First of all, I'm sorry if this was already discussed but doing a quick search I didn't find anything relevant either on the forum or mantis.

I am doing some tests with trucks and trailers and I have noticed the following:

- Case 1:

+ 2 players next to each other

+ Player A creates a truck & a trailer (either from script or using F1, which is, well, an other script :) )

+ Player A attaches the cab to the trailer

+ Player B can see all of it happening and sees the trailer moving

- Case 2:

+ 2 players far from each other

+ Player A creates a truck & a trailer (either from script or using F1, which is, well, an other script :) )

+ Player A attaches the cab to the trailer

+ Player A drives all the way to Player B

+ Player B sees Player A's truck but not the trailer

+ Player B warps elsewhere and back near Player A > still no trailer

+ Player B warps to the vicinity of where the trailer was created > no trailer there there BUT (see next point)

+ Player B warps back to Player A, and here only, the trailer appears and is towed.

Is it a known issue? Is there any known workaround for that? If it's not, I'll create a bug report but I first wanted to discuss it here.

Thank you in advance for your ideas & suggestions.

(Note: server & 2 clients: 1.0.3 windows)

Posted

First of all, I'm sorry if this was already discussed but doing a quick search I didn't find anything relevant either on the forum or mantis.

I am doing some tests with trucks and trailers and I have noticed the following:

- Case 1:

+ 2 players next to each other

+ Player A creates a truck & a trailer (either from script or using F1, which is, well, an other script :) )

+ Player A attaches the cab to the trailer

+ Player B can see all of it happening and sees the trailer moving

- Case 2:

+ 2 players far from each other

+ Player A creates a truck & a trailer (either from script or using F1, which is, well, an other script :) )

+ Player A attaches the cab to the trailer

+ Player A drives all the way to Player B

+ Player B sees Player A's truck but not the trailer

+ Player B warps elsewhere and back near Player A > still no trailer

+ Player B warps to the vicinity of where the trailer was created > no trailer there there BUT (see next point)

+ Player B warps back to Player A, and here only, the trailer appears and is towed.

Is it a known issue? Is there any known workaround for that? If it's not, I'll create a bug report but I first wanted to discuss it here.

Thank you in advance for your ideas & suggestions.

(Note: server & 2 clients: 1.0.3 windows)

Posted

I have tested several ways to hack around this bug (inside lua scripts).

+ I have tried to request the correct position of the trailer from the "driver" and set it on the clientside of players for which the truck is streamed in.

> Fail -> Doesn't work because the server itself doesn't know the correct position of the trailer and therefore puts it back where it belongs the next frame.

+ I have tried to set serverside the position of the trailer given by the "driver"

> Fail -> Due to normal lag it tends to detach the trailer for the driver, so it's not a suitable solution

+ And finally, I have tried, clientside only, to detach and reattach the truck and the trailer whenever the truck is streamed in

> Success. It doesn't affect the clientside of the driver and players warping to the driver see their trailer, as well as people simply driving/being in the vicinity of the driver.

Here is the code of the hack [clientside] (If you don't want to have a "table.find" you can remove the part with TRUCKLIST ):

---- TRAILER HACK ------
local TRUCKLIST = {403, 514, 515, 531, 525}
function onClientElementStreamIn()
local element = source
if not isElement(element) or getElementType(element) ~= "vehicle" or getVehicleType(element) ~= "Automobile" or getVehicleOccupant(element, 0) == g_Me then
return
end
local vehicle = element
if not table.find(TRUCKLIST, getElementModel(vehicle)) then
return
end
local trailer = getVehicleTowedByVehicle(vehicle)
if trailer then
detachTrailerFromVehicle (vehicle, trailer)
attachTrailerToVehicle (vehicle, trailer)
end
end
addEventHandler("onClientElementStreamIn", g_Root, onClientElementStreamIn)
---- TRAILER HACK ------

Posted

I have tested several ways to hack around this bug (inside lua scripts).

+ I have tried to request the correct position of the trailer from the "driver" and set it on the clientside of players for which the truck is streamed in.

> Fail -> Doesn't work because the server itself doesn't know the correct position of the trailer and therefore puts it back where it belongs the next frame.

+ I have tried to set serverside the position of the trailer given by the "driver"

> Fail -> Due to normal lag it tends to detach the trailer for the driver, so it's not a suitable solution

+ And finally, I have tried, clientside only, to detach and reattach the truck and the trailer whenever the truck is streamed in

> Success. It doesn't affect the clientside of the driver and players warping to the driver see their trailer, as well as people simply driving/being in the vicinity of the driver.

Here is the code of the hack [clientside] (If you don't want to have a "table.find" you can remove the part with TRUCKLIST ):

---- TRAILER HACK ------local TRUCKLIST = {403, 514, 515, 531, 525}function onClientElementStreamIn()	local element = source	if not isElement(element) or getElementType(element) ~= "vehicle" or getVehicleType(element) ~= "Automobile" or getVehicleOccupant(element, 0) == g_Me then		return	end	local vehicle = element	if not table.find(TRUCKLIST, getElementModel(vehicle)) then		return	end	local trailer = getVehicleTowedByVehicle(vehicle)	if trailer then		detachTrailerFromVehicle (vehicle, trailer)		attachTrailerToVehicle (vehicle, trailer)	endendaddEventHandler("onClientElementStreamIn", g_Root, onClientElementStreamIn)---- TRAILER HACK ------

Posted

wow, must try it out :)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

wow, must try it out :)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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...