ARYDER Posted June 13 Share Posted June 13 Hello! Imagine that a vehicle has several body kits in the form of vehicle components. I can edit their visibility on the client side (setVehicleComponentVisible), but how do I do this on the server side for all players? Move client-side operations to server then back to client-side for all players? Or is there an easier way? Or is it possible to turn components (body kits) into upgrades? (Which have shared function addVehicleUpgrade) Link to comment
ARYDER Posted June 13 Author Share Posted June 13 I have found one of the solutions here: Is there a simpler solution? Link to comment
AngelAlpha Posted June 14 Share Posted June 14 Client side addDebugHook ("postFunction", function(sourceResource, functionName, isAllowedByACL, luaFilename, luaLineNumber, ... ) if sourceResource == getThisResource() then return end local args = {...} local veh = args[1] local comp = args[2] local visible = args[3] local compVisible = getElementData(veh, "component_visible") or {} compVisible[comp] = visible setElementData(veh, "component_visible", compVisible) end, {"setVehicleComponentVisible"}) addEventHandler ("onClientElementStreamIn", root, function() if getElementType(source) ~= "vehicle" then return end local compVisible = getElementData(source, "component_visible") or {} for comp, visible in pairs (compVisible) do setVehicleComponentVisible (source, comp, visible) end end) addEventHandler ("onClientElementDataChange", root, function(db, _, visible) if db ~= "component_visible" then return end if getElementType (source) ~= "vehicle" then return end local compVisible = getElementData(source, "component_visible") or {} for comp, visible in pairs (compVisible) do setVehicleComponentVisible (source, comp, visible) end end) 1 Link to comment
ARYDER Posted June 15 Author Share Posted June 15 Hope it works! I can't even test it with other players, but code looks RELIABLE, TY Am I supposed to use this outside of the resource, where I change the visibility of components? Link to comment
AngelAlpha Posted June 26 Share Posted June 26 On 15/06/2024 at 19:39, sadvely said: Hope it works! I can't even test it with other players, but code looks RELIABLE, TY Am I supposed to use this outside of the resource, where I change the visibility of components? No, you can use this code in outside resource 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