Jareb hetha
Client side :
local shaders = {}
addEventHandler("onClientElementStreamIn",root,
function ()
if getElementType(localplayer ) == "vehicle" then
loadVehicleLights(localplayer )
end
end
)
addEventHandler("onClientVehicleEnter",root,
function ()
loadVehicleLights()
end
)
function loadVehicleLights ()
local controller = getVehicleController(localplayer )
if not controller then return end
local image = getElementData(controller,"vehiclelight")
if not image then return end
if not shaders[image] then
local texture = dxCreateTexture("images/"..image..".jpg","dxt3")
local shader = dxCreateShader("lights.fx")
dxSetShaderValue(shader,"gTexture",texture)
shaders[image] = shader
end
engineApplyShaderToWorldTexture(shaders[image],"vehiclepoldecals128",vehicle)
end
function unloadVehicleLights ()
local controller = getVehicleController(localplayer )
if not controller then return end
local image = getElementData(controller,"vehiclelight")
if not image then return end
engineRemoveShaderFromWorldTexture(shaders[image],"vehiclepoldecals128",vehicle)
end