ShayF Posted February 20, 2017 Share Posted February 20, 2017 (edited) I'm trying to change the color of a vehicle upgrade object. ID: 1001, name: spl_b_bab_m.dff. TXD not present. This is a spoiler. It changes the alpha and shade. However it only seems to toggle between white/grey and black. I need help with this. client.lua addEventHandler('onClientResourceStart',resourceRoot,function() shader = dxCreateShader('shader.fx',0,0,false,'object') setTimer(function() for i,v in pairs(getElementsByType('vehicle')) do if isElementStreamedIn(v) then local r,g,b = getVehicleColor(v) local a = getElementAlpha(v) dxSetShaderValue(shader,"red",(tonumber(r)/255)) dxSetShaderValue(shader,"green",(tonumber(g)/255)) dxSetShaderValue(shader,"blue",(tonumber(b)/255)) dxSetShaderValue(shader,"alpha",(tonumber(a)/255)) for _,attached in ipairs(getAttachedElements(v)) do local model = getElementModel(attached) if (model == 1001) then engineApplyShaderToWorldTexture(shader,'*',attached) end end end end end,50,0) end) shader.fx float red; float green; float blue; float alpha; technique simple { pass P0 { MaterialAmbient = float4(red,green,blue,alpha); } } meta.xml <meta> <script src="client.lua" type="client"/> <file src="shader.fx"/> <file src="mta-helper.fx"/> </meta> Alpha Change Shades Change (Normal is black) Edited February 20, 2017 by shay01 Link to comment
ShayF Posted February 20, 2017 Author Share Posted February 20, 2017 Never Mind, I made the script. Enjoy.https://community.multitheftauto.com/index.php?p=resources&s=details&id=14183 Link to comment
nikitafloy Posted February 20, 2017 Share Posted February 20, 2017 Teach me shader, pls, lol 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