مشكله الول مره كان شغال بس عدلته وزبطته يوممم اضغط كي تضهر قئمة كي اختصار ضوء سييارة ميضهرة قئامة
مافي شيء في دبوق
local lights = {
"High Quality",
"Blue Doom",
"Blue Estrellas",
"Blue Flecha",
"Blue Neon HQ",
"Blue Oblique",
"Blue X",
"Colored",
"Green FFS",
"Green Mustang",
"Green Onda",
"Green Paradise",
"Grey Audi I",
"MEME Derp HQ",
"MEME Me Gusta HQ",
"MEME Troll HQ",
"Orange Cupido",
"Orange Led",
"Orange Lines",
"Pink Dots",
"Purple I",
"Purple II",
"Red Alfa Romeo",
"Red Alien",
"Red Angry Mouth",
"Red Angry Shape",
"Red Audi I",
"Red Audi II",
"Red Audi III",
"Red BMW I",
"Red BMW II",
"Red BMW M5",
"Red Canibus",
"Red Chevrolet Malibu",
"Red Citroen Survolt",
"Red Cupido",
"Red Curve",
"Red Curves HQ",
"Red Dino",
"Red Double Oval",
"Red Double Ring",
"Red Double Ring Led",
"Red Double Rounded Restangles HQ",
"Red Double Stripes",
"Red Fast Line",
"Red FFS",
"Red Infiniti Electric",
"Red KIA",
"Red Lamborghini",
"Red Lexus",
"Red Lines",
"Red Metropolis",
"Red Mustang",
"Red Passat",
"Red Peugeot",
"Red Rhombus",
"Red Ring",
"Red Sexy",
"Red Slanted Stripes",
"Red Spray",
"Red Subaru",
"Red The N",
"Red The X",
"Red The Y",
"Red Triangles",
"Red Triple Stripes",
"Red Volkswagen",
"Violet Lilac",
"White Slanted Stripes",
"White Snake"
}
local shaders = {}
local currentLight = "high quality"
local drawLights = true
addEventHandler("onClientResourceStart",resourceRoot,
function ()
currentLight = getCookieOption("lights") or "high quality"
setElementData(localPlayer,"vehiclelight",currentLight,true)
if getCookieOption("draw") ~= "false" then
for i,vehicle in ipairs (getElementsByType("vehicle")) do
loadVehicleLights(vehicle)
end
end
end
)
addEventHandler("onClientElementStreamIn",root,
function ()
if getElementType(source) == "vehicle" then
loadVehicleLights(source)
end
end
)
addEventHandler("onClientVehicleEnter",root,
function ()
loadVehicleLights(source)
end
)
function loadVehicleLights (vehicle)
local controller = getVehicleController(vehicle)
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],"vehiclelights128",vehicle)
engineApplyShaderToWorldTexture(shaders[image],"vehiclelightson128",vehicle) -- needs messing with alpha
end
function unloadVehicleLights (vehicle)
local controller = getVehicleController(vehicle)
if not controller then return end
local image = getElementData(controller,"vehiclelight")
if not image then return end
engineRemoveShaderFromWorldTexture(shaders[image],"vehiclelights128",vehicle)
engineRemoveShaderFromWorldTexture(shaders[image],"vehiclelightson128",vehicle)
end
function saveChanges (btn)
if btn ~= "left" then return end
if guiCheckBoxGetSelected(drawlightsCheckBox) ~= drawLights then
local drawlights = guiCheckBoxGetSelected(drawlightsCheckBox)
if drawlights then
for i,vehicle in ipairs (getElementsByType("vehicle")) do
loadVehicleLights(vehicle)
end
else
for i,vehicle in ipairs (getElementsByType("vehicle")) do
unloadVehicleLights(vehicle)
end
for name,shader in pairs (shaders) do
destroyElement(shader)
shaders[name] = nil
end
end
setCookieOption("draw",tostring(drawlights))
end
local image = guiComboBoxGetItemText(lightsComboBox,guiComboBoxGetSelected(lightsComboBox))
if image ~= currentLight then
currentLight = image
setElementData(localPlayer,"vehiclelight",image)
setCookieOption("lights",image)
end
guiSetVisible(lightsWindow,false)
showCursor(false)
end
function closeWindow (btn)
if btn ~= "left" then return end
guiStaticImageLoadImage(previewStaticImage,"images/"..currentLight..".jpg")
guiSetVisible(lightsWindow,false)
showCursor(false)
end
function changeLights ()
local image = guiComboBoxGetItemText(lightsComboBox,guiComboBoxGetSelected(lightsComboBox))
guiStaticImageLoadImage(previewStaticImage,"images/"..image..".jpg")
end
addEventHandler("onClientElementDataChange",root,
function (key,oldvalue)
if key == "vehiclelight" then
local vehicle = getPedOccupiedVehicle(source)
if vehicle then
loadVehicleLights(vehicle)
end
end
end
)
--GUI:
local screenW, screenH = guiGetScreenSize ( )
function startGui ( )
lightsWindow = guiCreateStaticImage(screenW - 623 - 10, (screenH - 443) / 2, 623, 443, "led.png", false)
previewStaticImage = guiCreateStaticImage(211, 195, 208, 171, "images/"..currentLight..".jpg", false, lightsWindow)
lightsComboBox = guiCreateComboBox(201, 113, 233, 22, "Default", false, lightsWindow)
drawlightsCheckBox = guiCreateCheckBox(205, 141, 35, 30, "", false, false, lightsWindow)
saveChangesButton = guiCreateButton(212, 373, 70, 30, "", false, lightsWindow)
closeWindowButton = guiCreateButton(349, 373, 70, 30, "", false, lightsWindow)
for i,light in ipairs (lights) do
local id = guiComboBoxAddItem (lightsComboBox,light)
if light == currentLight then
guiComboBoxSetSelected(lightsComboBox,id)
end
end
guiSetAlpha(closeWindowButton, 0.18)
guiSetAlpha(saveChangesButton, 0.18)
guiSetAlpha(drawlightsCheckBox, 0.22)
guiSetProperty(saveChangesButton, "NormalTextColour", "FFAAAAAA")
guiSetProperty(closeWindowButton, "NormalTextColour", "FFAAAAAA")
addEventHandler("onClientGUIClick",saveChangesButton,saveChanges,false)
addEventHandler("onClientGUIClick",closeWindowButton,closeWindow,false)
addEventHandler("onClientGUIComboBoxAccepted",lightsComboBox,changeLights)
end
bindKey("F5","Down",
function()
if lightsWindow then
guiSetVisible(lightsWindow,not guiGetVisible(lightsWindow))
showCursor(guiGetVisible(lightsWindow))
else
showCursor (true)
startGui()
end
end, false)