Wysłany: 2016-06-09, 17:10
polaczkos
Wiek: 25 Na forum: 4085 dni Posty: 168
Nick w MP: polaczkos
Piwa : 3
Kod:
local cs =createColCuboid(-2086.88,1398.54,3.70, 12.9384765625, 10.796737670898, 4.24375)
local mkr=createMarker(-2089.82,1398.96,7.19-0.90, "cylinder", 1.5, 255, 255, 255, 155)
addEventHandler("onClientResourceStart",resourceRoot,
function ()
for i,vehicle in ipairs (getElementsByType("vehicle")) do
loadVehicleLights(vehicle)
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 image = getElementData(vehicle,"vehicle:light")
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 image = getElementData(vehicle,"vehicle:light")
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
local image = guiComboBoxGetItemText(lightsComboBox,guiComboBoxGetSelected(lightsComboBox))
local vehicles=getElementsWithinColShape(cs,"vehicle")
local currentLight=getElementData(vehicles[1],"vehicle:light")
if currentLight==false then currentLight="High Quality" end
if #vehicles < 1 then
outputChatBox("* Na stanowisku monta?u nie ma ?adnego pojazdu.", 255, 0, 0)
return
end
if #vehicles > 1 then
outputChatBox("* Na stanowisku monta?u jest zbyt du?o pojazd?w.", 255, 0, 0)
return
end
if image ~= currentLight then
currentLight = image
local zmiana=triggerServerEvent("changelight", localPlayer, vehicles[1], image)
if zmiana then
outputChatBox("Zamontowa?e? ?wiat?a "..image.." do pojazdu")
else
outputChatBox("Cos posz?o nie tak!")
end
end
guiSetVisible(lightsWindow,false)
showCursor(false)
end
function closeWindow (btn)
if btn ~= "left" then return end
local vehicles=getElementsWithinColShape(cs,"vehicle")
local currentLight=getElementData(vehicles[1],"vehicle:light")
if currentLight==false then currentLight="High Quality" 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 == "vehicle:light" then
loadVehicleLights(source)
end
end
)
--GUI:
function startGui ()
lightsWindow = guiCreateWindow (200, 70, 400, 450, "Montaz swiatel", false)
guiSetAlpha (lightsWindow, 1)
guiWindowSetSizable (lightsWindow, false)
guiCreateLabel (15, 40, 380, 20, "Swiat?a:", false, lightsWindow)
guiCreateLabel (15, 140, 380, 20, "Podgl?d:", false, lightsWindow)
lightsComboBox = guiCreateComboBox (25, 60, 350, 160, "Domyslne", false, lightsWindow)
local vehicles=getElementsWithinColShape(cs,"vehicle")
local currentLight=getElementData(vehicles[1],"vehicle:light")
if currentLight==false then currentLight="High Quality" end
for i,light in ipairs (lights) do
local id = guiComboBoxAddItem (lightsComboBox,light)
if light == currentLight then
guiComboBoxSetSelected(lightsComboBox,id)
end
end
addEventHandler("onClientGUIComboBoxAccepted",lightsComboBox,changeLights)
previewStaticImage = guiCreateStaticImage (25, 160, 350, 220, "images/"..currentLight..".jpg", false, lightsWindow)
local saveChangesButton = guiCreateButton (25, 400, 150, 30, "Zamontuj", false, lightsWindow)
local closeWindowButton = guiCreateButton (225, 400, 150, 30, "Zamknij", false, lightsWindow)
addEventHandler("onClientGUIClick",saveChangesButton,saveChanges,false)
addEventHandler("onClientGUIClick",closeWindowButton,closeWindow,false)
end
addEventHandler("onClientMarkerHit", resourceRoot, function(el,md)
if not md or el~=localPlayer then return end
local vehicles=getElementsWithinColShape(cs,"vehicle")
if #vehicles < 1 then
outputChatBox("* Na stanowisku monta?u nie ma ?adnego pojazdu.", 255, 0, 0)
return
end
if #vehicles > 1 then
outputChatBox("* Na stanowisku monta?u jest zbyt du?o pojazd?w.", 255, 0, 0)
return
end
if getElementHealth(vehicles[1]) < 900 then
outputChatBox("* Pojazd jest zbyt uszkodzony aby zamontowa? ?wiat?a.", 255, 0, 0)
return
end
showCursor(true)
startGui()
end)
addEventHandler("onClientMarkerLeave", resourceRoot, function(el,md)
if el~=localPlayer then return end
if lightsWindow then
guiSetVisible(lightsWindow,false)
showCursor(guiGetVisible(lightsWindow))
end
end)
Prosz? o pomoc bo chc? zrobi? by tylko mechanik kt?ry jest dodany w ALC m?g? montowa? swiat?a lecz nie dzia?a mi prosz? o pomoc
Wysłany: 2016-06-11, 16:04
marcin778
Krytyk serwerów MTA
Wiek: 24 Na forum: 4149 dni Posty: 2268
Nick w MP: Marcineg
Piwa : 4662
Wysłany: 2016-06-11, 22:24
Jurandovsky
Kurdebele
Wiek: 17 Na forum: 4838 dni Posty: 915
Piwa : 2697
Poczytaj na wiki MTA o grupach ACL i ich tworzeniu, stw?rz tam grup? "Mechanik" a po wej?ciu w marker sprawdzasz login osoby i przekazujesz go do tej funkcji kt?r? da? marcin.
Z reszt?, na wikipedii MTA jest przyk?ad jak u?ywa? tej funkcji isObjectInACLGroup
Podpis
Jedyny kontakt ze mną to PW forum
Kod:
local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Tagi: montaż :: świateł :: dla :: mechaników :: acl
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: