rfmx Posted October 21, 2018 Share Posted October 21, 2018 I am using vehicle component functions (for custom visual tuning) but they are client side only. What is the best way to sync vehicle component manipulation (position, visibility) between players? Link to comment
Gordon_G Posted October 21, 2018 Share Posted October 21, 2018 Can you show us your code ? Link to comment
rfmx Posted October 21, 2018 Author Share Posted October 21, 2018 addCommandHandler("vcp", function() local theVeh = getPedOccupiedVehicle(localPlayer) local x, y, z = getVehicleComponentPosition(theVeh, "wheel_rf_dummy") setVehicleComponentPosition(theVeh, "wheel_rf_dummy", x+0.15, y, z) local x, y, z = getVehicleComponentPosition(theVeh, "wheel_rb_dummy") setVehicleComponentPosition(theVeh, "wheel_rb_dummy", x+0.15, y, z) local x, y, z = getVehicleComponentPosition(theVeh, "wheel_lf_dummy") setVehicleComponentPosition(theVeh, "wheel_lf_dummy", x-0.15, y, z) local x, y, z = getVehicleComponentPosition(theVeh, "wheel_lb_dummy") setVehicleComponentPosition(theVeh, "wheel_lb_dummy", x-0.15, y, z) end ) It is just a simple test script. I thought about using setElementData for vehicles and onClientElementStreamIn for clients to sync it. I'm just not shure if it's a good aproach or is there a better way of doing this. Link to comment
SaNoR Posted October 21, 2018 Share Posted October 21, 2018 Server side: addCommandHandler("vcp", function(player) local vehicle = getPedOccupiedVehicle(player) if isElement(vehicle) then triggerClientEvent(root, "syncVehicleComponents", vehicle) end end) Client side: addEvent("syncVehicleComponents", true) addEventHandler("syncVehicleComponents", root, function() if isElement(source) and getElementType(source) == "vehicle" then local x, y, z = getVehicleComponentPosition(source, "wheel_rf_dummy") setVehicleComponentPosition(source, "wheel_rf_dummy", x+0.15, y, z) local x, y, z = getVehicleComponentPosition(source, "wheel_rb_dummy") setVehicleComponentPosition(source, "wheel_rb_dummy", x+0.15, y, z) local x, y, z = getVehicleComponentPosition(source, "wheel_lf_dummy") setVehicleComponentPosition(source, "wheel_lf_dummy", x-0.15, y, z) local x, y, z = getVehicleComponentPosition(source, "wheel_lb_dummy") setVehicleComponentPosition(source, "wheel_lb_dummy", x-0.15, y, z) end end) Link to comment
JustinMTA Posted October 22, 2018 Share Posted October 22, 2018 This should work. --Add to client side in meta file addEventHandler("onClientVehicleEnter", getRootElement(), function() theVeh = getPedOccupiedVehicle(thePlayer) --Your following code end ) 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