HustraDev Posted August 20, 2016 Share Posted August 20, 2016 I have problem with this script it should change Vehicle Window Color .. But it Doesn't ~ Shader Fx :- technique tintedWindow { pass P0 { DepthBias = -0.0000; AlphaBlendEnable = TRUE; SrcBlend = SRCALPHA; DestBlend = INVSRCALPHA; } } technique fallback { pass P0 { } } Script client :- local tintShaders = {} local elementShaders = {vehicle} local availableTintedWindows = { [405] = "@hite", [543] = "@hite" } addEventHandler("onClientResourceStart", resourceRoot, function() for _, vehicle in ipairs(getElementsByType("vehicle", root, true)) do local vehicleHaveTintedWindow = getElementData(vehicle, "tuning.tintedWindow") or 0 if vehicleHaveTintedWindow ~= 0 then setVehicleWindowType(vehicle) end end end) addEventHandler("onClientElementStreamIn", root, function() if getElementType(source) == "vehicle" then local vehicleHaveTintedWindow = getElementData(source, "tuning.tintedWindow") or 0 if vehicleHaveTintedWindow ~= 0 then setVehicleWindowType(source) end end end) addEventHandler("onClientElementDestroy", root, function() if getElementType(source) == "vehicle" then destroyTintedWindowShader(source) end end) addEventHandler("onClientElementStreamOut", root, function() if getElementType(source) == "vehicle" then destroyTintedWindowShader(source) end end) addEvent("tuning->TintedWindow", true) function setVehicleWindowType(vehicle, adding) local vehicleModel = getElementModel(vehicle) local windowTexture = availableTintedWindows[vehicleModel] if adding == 0 then destroyTintedWindowShader(vehicle) else if windowTexture then applyTintedWindowShader(windowTexture, 100, vehicle) else destroyTintedWindowShader(vehicle) end end end addEventHandler("tuning->TintedWindow", root, setVehicleWindowType) function destroyTintedWindowShader(element) if elementShaders[element] then destroyElement(elementShaders[element][1][1]) elementShaders[element] = nil end end function applyTintedWindowShader(texture, distance, element) if element then destroyTintedWindowShader(element) end local this = #tintShaders + 1 tintShaders[this] = {} tintShaders[this][1] = dxCreateShader("files/textures/tintedWindow.fx", 0, 0, true) if not tintShaders[this][1] then tintShaders[this] = nil return end if element then if not elementShaders[element] then elementShaders[element] = {tintShaders[this], texture} end end if tintShaders[this][1] and tintShaders[this][2] then engineApplyShaderToWorldTexture(tintShaders[this][1], texture, element) end 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