saluta Posted May 7, 2021 Share Posted May 7, 2021 (edited) Full code client.lua Toner Spoiler local tmpDimension = nil local tmpPosition = {} function vehicleDimensionUpdate(veh,dimension) local nveh = getPedOccupiedVehicle ( veh ) setElementDimension(nveh,dimension) for i = 0, getVehicleMaxPassengers ( nveh ) do if getVehicleOccupant ( nveh, i ) then setElementDimension(getVehicleOccupant ( nveh, i ),dimension) end end end local entradaB = createMarker (-906.0869,1960.8920,45, "cylinder", 1, 100, 160, 255, 0) addEventHandler( "onClientRender", root, function ( ) local x, y, z = getElementPosition( entradaB ) local Mx, My, Mz = getCameraMatrix( ) if ( getDistanceBetweenPoints3D( x, y, z, Mx, My, Mz ) <= 10 ) then local WorldPositionX, WorldPositionY = getScreenFromWorldPosition( x, y, z +1, 0.07 ) if ( WorldPositionX and WorldPositionY ) then dxDrawText("EN: Toning center", WorldPositionX - 1, WorldPositionY + 1, WorldPositionX - 1, WorldPositionY + 1, tocolor(255, 255, 255, 255), 3.02, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("RU: Тонировочный центр", WorldPositionX - 1, WorldPositionY + 1, WorldPositionX - 1, WorldPositionY + 99, tocolor(255, 255, 255, 255), 3.00, "default-bold", "center", "center", false, false, false, false, false) end end end ) function isLegalVehicle(veh) for i = 0, #vehiclesArray do if getElementModel(veh) == vehiclesArray then outputChatBox ( "You cannot use the tuning of a working vehicle!", 255,50,0, true ) return false end if i == #vehiclesArray and not(getElementModel(veh) == vehiclesArray) then return true end end end shader1 = {} -- Лобовое стекло. shader2 = {} -- Передние боковые. shader3 = {} -- Задняя полусфера. wndToner = guiCreateWindow(500, 190, 330, 460, "EN: Tinting RU: Тонировка MD/RO: Tintare", false) guiSetVisible(wndToner, false) labelTonerInfo1 = guiCreateLabel(5, 23, 320, 50, "Select the color of the tinting:", false, wndToner) guiSetFont(labelTonerInfo1, "default-bold-small") guiLabelSetHorizontalAlign(labelTonerInfo1, "center", false) imgToner0 = guiCreateStaticImage(38, 43, 44, 44, "files/texture0.png", false,wndToner) --индикатор imgToner1 = guiCreateStaticImage(40, 45, 40, 40, "files/texture1.png", false,wndToner) imgToner2 = guiCreateStaticImage(110, 45, 40, 40, "files/texture2.png", false,wndToner) imgToner3 = guiCreateStaticImage(180, 45, 40, 40, "files/texture3.png", false,wndToner) imgToner4 = guiCreateStaticImage(250, 45, 40, 40, "files/texture4.png", false,wndToner) labelTonerPoloska = guiCreateLabel(5, 85, 320, 50, "_______________________________________", false, wndToner) guiLabelSetHorizontalAlign(labelTonerPoloska, "center", false) labelTonerInfo2 = guiCreateLabel(5, 105, 320, 50, "Choose the transparency of the tinting:", false, wndToner) guiSetFont(labelTonerInfo2, "default-bold-small") guiLabelSetHorizontalAlign(labelTonerInfo2, "center", false) labelTonerInfo3 = guiCreateLabel(5, 125, 320, 50, "Opacity: 40 %", false,wndToner) guiSetFont(labelTonerInfo3, "default-bold-small") guiLabelSetHorizontalAlign(labelTonerInfo3, "center", false) ScrollToner = guiCreateScrollBar(15,155,300,17,true,false,wndToner) guiScrollBarSetScrollPosition(ScrollToner, 40) labelTonerPoloska = guiCreateLabel(5, 170, 320, 50, "_______________________________________", false, wndToner) guiLabelSetHorizontalAlign(labelTonerPoloska, "center", false) labelTonerInfo4 = guiCreateLabel(5, 190, 320, 50, "Apply the selected color for:", false,wndToner) guiSetFont(labelTonerInfo4, "default-bold-small") guiLabelSetHorizontalAlign(labelTonerInfo4, "center", false) labelToner1 = guiCreateLabel(15, 220, 320, 25, "✘", false,wndToner) -- Лобового стекла labelTonerName1 = guiCreateLabel(45, 220, 320, 50, "Windshield", false,wndToner) guiSetFont(labelTonerName1, "default-bold-small") labelToner2 = guiCreateLabel(15, 245, 320, 25, "✘", false,wndToner) -- Боковых передних labelTonerName2 = guiCreateLabel(45, 245, 320, 50, "Side front windows", false,wndToner) guiSetFont(labelTonerName2, "default-bold-small") labelToner3 = guiCreateLabel(15, 270, 320, 25, "✘", false,wndToner) -- Задней полусферы labelTonerName3 = guiCreateLabel(45, 270, 320, 50, "Rear hemisphere", false,wndToner) guiSetFont(labelTonerName3, "default-bold-small") labelToner4 = guiCreateLabel(15, 295, 320, 25, "✘", false,wndToner) -- Всех стекол labelTonerName4 = guiCreateLabel(45, 295, 320, 50, "All glasses", false,wndToner) guiSetFont(labelTonerName4, "default-bold-small") labelTonerPoloska = guiCreateLabel(5, 315, 320, 50, "_______________________________________", false, wndToner) guiLabelSetHorizontalAlign(labelTonerPoloska, "center", false) buttonToner1 = guiCreateButton(15, 340, 300, 30, "Buy tinting ("..buyMoneyToner.." $.)", false,wndToner) buttonToner2 = guiCreateButton(15, 380, 300, 30, "Remove all tint ("..delMoneyToner.." $.)", false,wndToner) buttonToner3 = guiCreateButton(15, 420, 300, 30, "Close", false,wndToner) function updateToner() guiSetText(labelTonerInfo3,"Opacity: "..guiScrollBarGetScrollPosition(ScrollToner).." %") local prozr = guiScrollBarGetScrollPosition(ScrollToner) / 100 local veh = getPedOccupiedVehicle(localPlayer) if veh and guiGetVisible(wndToner) == true then if guiGetText(labelToner1) == "✘" then guiLabelSetColor(labelToner1,255,50,50) else guiLabelSetColor(labelToner1,50,255,100) end if guiGetText(labelToner2) == "✘" then guiLabelSetColor(labelToner2,255,50,50) else guiLabelSetColor(labelToner2,50,255,100) end if guiGetText(labelToner3) == "✘" then guiLabelSetColor(labelToner3,255,50,50) else guiLabelSetColor(labelToner3,50,255,100) end if guiGetText(labelToner4) == "✘" then guiLabelSetColor(labelToner4,255,50,50) else guiLabelSetColor(labelToner4,50,255,100) end if not shader1[veh] then shader1[veh] = dxCreateShader("files/toner.fx") end if guiGetText(labelToner1) == "✔" then engineRemoveShaderFromWorldTexture(shader1[veh], texture1, veh) engineApplyShaderToWorldTexture(shader1[veh], texture1, veh) dxSetShaderValue(shader1[veh], "gTexture", dxCreateTexture("files/texture"..tonumber(getElementData(localPlayer,"numToner"))..".png") ) dxSetShaderValue(shader1[veh], "gAlpha", prozr) setElementData(veh,"type1",tonumber(getElementData(localPlayer,"numToner"))) setElementData(veh,"proz1",prozr) end if not shader2[veh] then shader2[veh] = dxCreateShader("files/toner.fx") end if guiGetText(labelToner2) == "✔" then engineRemoveShaderFromWorldTexture(shader2[veh], texture2, veh) engineApplyShaderToWorldTexture(shader2[veh], texture2, veh) dxSetShaderValue(shader2[veh], "gTexture", dxCreateTexture("files/texture"..tonumber(getElementData(localPlayer,"numToner"))..".png") ) dxSetShaderValue(shader2[veh], "gAlpha", prozr) setElementData(veh,"type2",tonumber(getElementData(localPlayer,"numToner"))) setElementData(veh,"proz2",prozr) end if not shader3[veh] then shader3[veh] = dxCreateShader("files/toner.fx") end if guiGetText(labelToner3) == "✔" then engineRemoveShaderFromWorldTexture(shader3[veh], texture3, veh) engineApplyShaderToWorldTexture(shader3[veh], texture3, veh) dxSetShaderValue(shader3[veh], "gTexture", dxCreateTexture("files/texture"..tonumber(getElementData(localPlayer,"numToner"))..".png") ) dxSetShaderValue(shader3[veh], "gAlpha", prozr) setElementData(veh,"type3",tonumber(getElementData(localPlayer,"numToner"))) setElementData(veh,"proz3",prozr) end end end addEventHandler("onClientRender", root, updateToner) function onGuiClickPanel() local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle and getVehicleController(vehicle) == localPlayer then if source == imgToner1 then guiSetPosition(imgToner0,38,43,false) setElementData(localPlayer, "numToner", 1) elseif source == imgToner2 then guiSetPosition(imgToner0,108,43,false) setElementData(localPlayer, "numToner", 2) elseif source == imgToner3 then guiSetPosition(imgToner0,178,43,false) setElementData(localPlayer, "numToner", 3) elseif source == imgToner4 then guiSetPosition(imgToner0,248,43,false) setElementData(localPlayer, "numToner", 4) elseif source == labelToner1 then if guiGetText(labelToner1) == "✘" then guiSetText(labelToner1,"✔") else guiSetText(labelToner1,"✘") end elseif source == labelToner2 then if guiGetText(labelToner2) == "✘" then guiSetText(labelToner2,"✔") else guiSetText(labelToner2,"✘") end elseif source == labelToner3 then if guiGetText(labelToner3) == "✘" then guiSetText(labelToner3,"✔") else guiSetText(labelToner3,"✘") end elseif source == labelToner4 then if guiGetText(labelToner4) == "✘" then guiSetText(labelToner1,"✔") guiSetText(labelToner2,"✔") guiSetText(labelToner3,"✔") guiSetText(labelToner4,"✔") else guiSetText(labelToner1,"✘") guiSetText(labelToner2,"✘") guiSetText(labelToner3,"✘") guiSetText(labelToner4,"✘") end elseif source == buttonToner1 then guiSetText(labelToner1,"✘") guiSetText(labelToner2,"✘") guiSetText(labelToner3,"✘") guiSetText(labelToner4,"✘") guiSetVisible(wndToner,false) vehicleDimensionUpdate(localPlayer,tmpDimension) tmpDimension = nil showCursor(false) mouseToner = false triggerServerEvent("SES", getPedOccupiedVehicle(localPlayer), true) setElementPosition (getPedOccupiedVehicle(localPlayer),tmpPosition[1]-5,tmpPosition[2]-5,tmpPosition[3]) setElementRotation (getPedOccupiedVehicle(localPlayer),tmpPosition[4],tmpPosition[5],tmpPosition[6]) local vehicle = getPedOccupiedVehicle(localPlayer) if not getElementData(vehicle,"type1") or getElementData(vehicle,"type1") == "" then setElementData(vehicle,"type1",getElementData(vehicle,"nastType1")) end if not getElementData(vehicle,"type2") or getElementData(vehicle,"type2") == "" then setElementData(vehicle,"type2",getElementData(vehicle,"nastType2")) end if not getElementData(vehicle,"type3") or getElementData(vehicle,"type3") == "" then setElementData(vehicle,"type3",getElementData(vehicle,"nastType3")) end if not getElementData(vehicle,"proz1") or getElementData(vehicle,"proz1") == "" then setElementData(vehicle,"proz1",getElementData(vehicle,"nastProz1")) end if not getElementData(vehicle,"proz2") or getElementData(vehicle,"proz2") == "" then setElementData(vehicle,"proz2",getElementData(vehicle,"nastProz2")) end if not getElementData(vehicle,"proz3") or getElementData(vehicle,"proz3") == "" then setElementData(vehicle,"proz3",getElementData(vehicle,"nastProz3")) end setElementData(vehicle,"nastType1",getElementData(vehicle,"type1")) setElementData(vehicle,"nastType2",getElementData(vehicle,"type2")) setElementData(vehicle,"nastType3",getElementData(vehicle,"type3")) setElementData(vehicle,"nastProz1",getElementData(vehicle,"proz1")) setElementData(vehicle,"nastProz2",getElementData(vehicle,"proz2")) setElementData(vehicle,"nastProz3",getElementData(vehicle,"proz3")) local t1 = tostring(getElementData(vehicle,"type1")) or "4" local p1 = tonumber(getElementData(vehicle,"proz1")) or 0.4 local t2 = tostring(getElementData(vehicle,"type2")) or "4" local p2 = tonumber(getElementData(vehicle,"proz2")) or 0.4 local t3 = tostring(getElementData(vehicle,"type3")) or "4" local p3 = tonumber(getElementData(vehicle,"proz3")) or 0.4 triggerServerEvent("setServerToner", getRootElement(), localPlayer, vehicle, t1, t2, t3, p1, p2, p3, buyMoneyToner) elseif source == buttonToner2 then guiSetText(labelToner1,"✘") guiSetText(labelToner2,"✘") guiSetText(labelToner3,"✘") guiSetText(labelToner4,"✘") local vehicle = getPedOccupiedVehicle(localPlayer) setElementData(vehicle,"nastType1","4") setElementData(vehicle,"nastType2","4") setElementData(vehicle,"nastType3","4") setElementData(vehicle,"nastProz1",0.4) setElementData(vehicle,"nastProz2",0.4) setElementData(vehicle,"nastProz3",0.4) triggerServerEvent("setServerToner", getRootElement(), localPlayer, vehicle, "udalit", "udalit", "udalit", "udalit", "udalit", "udalit", delMoneyToner) elseif source == buttonToner3 then guiSetText(labelToner1,"✘") guiSetText(labelToner2,"✘") guiSetText(labelToner3,"✘") guiSetText(labelToner4,"✘") guiSetVisible(wndToner,false) vehicleDimensionUpdate(localPlayer,tmpDimension) tmpDimension = nil showCursor(false) mouseToner = false triggerServerEvent("SES", getPedOccupiedVehicle(localPlayer), true) setElementPosition (getPedOccupiedVehicle(localPlayer),tmpPosition[1]-5,tmpPosition[2]-5,tmpPosition[3]) setElementRotation (getPedOccupiedVehicle(localPlayer),tmpPosition[4],tmpPosition[5],tmpPosition[6]) local vehicle = getPedOccupiedVehicle(localPlayer) local t1 = tostring(getElementData(vehicle,"nastType1")) local p1 = tonumber(getElementData(vehicle,"nastProz1")) local t2 = tostring(getElementData(vehicle,"nastType2")) local p2 = tonumber(getElementData(vehicle,"nastProz2")) local t3 = tostring(getElementData(vehicle,"nastType3")) local p3 = tonumber(getElementData(vehicle,"nastProz3")) triggerServerEvent("setServerToner", getRootElement(), localPlayer, vehicle, t1, t2, t3, p1, p2, p3, 0) setElementData(vehicle,"type1","") setElementData(vehicle,"type2","") setElementData(vehicle,"type3","") setElementData(vehicle,"proz1","") setElementData(vehicle,"proz2","") setElementData(vehicle,"proz3","") end end end addEventHandler ("onClientGUIClick", getRootElement(), onGuiClickPanel) function setToner(veh, t1, t2, t3, p1, p2, p3) shader1[veh] = dxCreateShader("files/toner.fx") engineApplyShaderToWorldTexture(shader1[veh], texture1, veh) dxSetShaderValue(shader1[veh], "gTexture", dxCreateTexture("files/texture"..t1..".png") ) dxSetShaderValue(shader1[veh], "gAlpha", p1) shader2[veh] = dxCreateShader("files/toner.fx") engineApplyShaderToWorldTexture(shader2[veh], texture2, veh) dxSetShaderValue(shader2[veh], "gTexture", dxCreateTexture("files/texture"..t2..".png") ) dxSetShaderValue(shader2[veh], "gAlpha", p2) shader3[veh] = dxCreateShader("files/toner.fx") engineApplyShaderToWorldTexture(shader3[veh], texture3, veh) dxSetShaderValue(shader3[veh], "gTexture", dxCreateTexture("files/texture"..t3..".png") ) dxSetShaderValue(shader3[veh], "gAlpha", p3) end addEvent("setToner", true) addEventHandler("setToner", getRootElement(), setToner) function delToner(veh) if not getElementData(veh, "toner1") then setElementData(veh, "toner1", "4") end if not getElementData(veh, "toner2") then setElementData(veh, "toner2", "4") end if not getElementData(veh, "toner3") then setElementData(veh, "toner3", "4") end if not getElementData(veh, "p1") then setElementData(veh, "p1", 0.4) end if not getElementData(veh, "p2") then setElementData(veh, "p2", 0.4) end if not getElementData(veh, "p3") then setElementData(veh, "p3", 0.4) end shader1[veh] = dxCreateShader("files/toner.fx") engineApplyShaderToWorldTexture(shader1[veh], texture1, veh) dxSetShaderValue(shader1[veh], "gTexture", dxCreateTexture("files/texture4.png") ) dxSetShaderValue(shader1[veh], "gAlpha", 0.4) shader2[veh] = dxCreateShader("files/toner.fx") engineApplyShaderToWorldTexture(shader2[veh], texture2, veh) dxSetShaderValue(shader2[veh], "gTexture", dxCreateTexture("files/texture4.png") ) dxSetShaderValue(shader2[veh], "gAlpha", 0.4) shader3[veh] = dxCreateShader("files/toner.fx") engineApplyShaderToWorldTexture(shader3[veh], texture3, veh) dxSetShaderValue(shader3[veh], "gTexture", dxCreateTexture("files/texture4.png") ) dxSetShaderValue(shader3[veh], "gAlpha", 0.4) end addEvent("delToner", true) addEventHandler("delToner", getRootElement(), delToner) function toggleMouse() if mouseToner == true then showCursor(not isCursorShowing ()) end end bindKey("mouse2", "up",toggleMouse) bindKey("mouse2", "down",toggleMouse) function MarkerHit(hitPlayer, matchingDimension) if getElementData (source, "isToner") == true and hitPlayer == getLocalPlayer() and isPedInVehicle(hitPlayer) then if getVehicleController ( getPedOccupiedVehicle(hitPlayer) ) == getLocalPlayer() and isLegalVehicle(getPedOccupiedVehicle(hitPlayer)) then local veh = getPedOccupiedVehicle(hitPlayer) if not veh then return end if getPedOccupiedVehicleSeat(hitPlayer) ~= 0 then return end triggerServerEvent("removePeds",hitPlayer, veh) guiSetVisible(wndToner, true) showCursor(true) tmpDimension = getElementDimension (hitPlayer) tmpPosition[1],tmpPosition[2],tmpPosition[3] = getElementPosition(getPedOccupiedVehicle(hitPlayer)) tmpPosition[4],tmpPosition[5],tmpPosition[6] = getElementRotation(getPedOccupiedVehicle(hitPlayer)) vehicleDimensionUpdate(hitPlayer,0) setElementPosition (getPedOccupiedVehicle(hitPlayer),Point[1],Point[2],Point[3]) setElementRotation (getPedOccupiedVehicle(hitPlayer),Point[4],Point[5],Point[6]) triggerServerEvent("SES", getPedOccupiedVehicle(hitPlayer), false) outputChatBox("", 0, 191, 255, true) outputChatBox("", 0, 191, 255, true) outputChatBox("", 0, 191, 255, true) outputChatBox("", 0, 191, 255, true) outputChatBox("", 0, 191, 255, true) outputChatBox("", 0, 191, 255, true) outputChatBox("", 0, 191, 255, true) outputChatBox("", 0, 191, 255, true) outputChatBox("#FFFFFFRU: Добро пожаловать в тонировочный центр.", 0, 191, 255, true) outputChatBox("#FFFFFFEN: Welcome to the tinting center.", 0, 191, 255, true) outputChatBox("#FFFFFFRU: Нажмите ПКМ, чтобы скрыть/показать курсор.", 0, 191, 255, true) outputChatBox("#FFFFFFEN: Press RMB to hide/show cursor.", 0, 191, 255, true) mouseToner = true local gc = getElementData(localPlayer,"numToner") if not gc then setElementData(localPlayer,"numToner",1) end end end end addEventHandler("onClientMarkerHit", getRootElement(), MarkerHit) Donwload client.lua Toner client.lua Edited May 7, 2021 by Createprojectmd Link to comment
SpecT Posted May 7, 2021 Share Posted May 7, 2021 (edited) Hello, What exactly doesn't work ? You didn't tell us if there are any errors (/debugscript 3) and gave no information about what the problem with this script is. Also if this script is not written by you then it would be best to ask its creator for assistance! We are here to help you with a script you wrote and we expect you to have at least some kind of an idea what might be wrong. Simply dropping the full script with 300+ lines here and asking someone to get it fixed for you isn't the best idea. Edited May 7, 2021 by SpecT Link to comment
saluta Posted May 10, 2021 Author Share Posted May 10, 2021 On 07/05/2021 at 20:05, SpecT said: Hello, What exactly doesn't work ? You didn't tell us if there are any errors (/debugscript 3) and gave no information about what the problem with this script is. Also if this script is not written by you then it would be best to ask its creator for assistance! We are here to help you with a script you wrote and we expect you to have at least some kind of an idea what might be wrong. Simply dropping the full script with 300+ lines here and asking someone to get it fixed for you isn't the best idea. Photo debugscript Link to comment
Other Languages Moderators androksi Posted May 10, 2021 Other Languages Moderators Share Posted May 10, 2021 Those images are missing in the folder. Link to comment
saluta Posted May 11, 2021 Author Share Posted May 11, 2021 (edited) On 10/05/2021 at 18:24, andr0xy said: Those images are missing in the folder. Fixed bugs missing but now there are still bugs next photo Please help Edited May 11, 2021 by Createprojectmd Link to comment
SpecT Posted May 11, 2021 Share Posted May 11, 2021 function setToner(veh, t1, t2, t3, p1, p2, p3) -- p1, p2 and p3 are missing from the call ... end addEvent("setToner", true) addEventHandler("setToner", getRootElement(), setToner) It throws you errors cuz the part where you call the "setToner" function misses the last 3 arguments. Find where you trigger the "setToner" event and add the missing p1, p2 and p3 arguments. Link to comment
saluta Posted May 12, 2021 Author Share Posted May 12, 2021 20 hours ago, SpecT said: function setToner(veh, t1, t2, t3, p1, p2, p3) -- p1, p2 and p3 are missing from the call ... end addEvent("setToner", true) addEventHandler("setToner", getRootElement(), setToner) It throws you errors cuz the part where you call the "setToner" function misses the last 3 arguments. Find where you trigger the "setToner" event and add the missing p1, p2 and p3 arguments. It didn’t help, but I’m a bit the same programmer, no matter how I do the project from scratch, in general, I solved this problem the topic is that referring to the settuner function I made a reference to the deltoner to remove tinting, and errors do not come out anymore, I am a genius. Textures t1 in deltoner, and in settoner t1 and it worked) function setToner(veh, t1, t2, t3, p1, p2, p3) shader1[veh] = dxCreateShader("files/toner.fx") engineApplyShaderToWorldTexture(shader1[veh], texture1, veh) dxSetShaderValue(shader1[veh], "gTexture", dxCreateTexture("files/texture"..t1..".png") ) dxSetShaderValue(shader1[veh], "gAlpha", p1, t1) ... end addEvent("setToner", true) addEventHandler("setToner", getRootElement(), setToner) function delToner(veh) if not getElementData(veh, "toner1") then setElementData(veh, "toner1", "4") end ... if not getElementData(veh, "t1") then setElementData(veh, "t1", 0.4) end end Locked topic 20 hours ago, SpecT said: function setToner(veh, t1, t2, t3, p1, p2, p3) -- p1, p2 and p3 are missing from the call ... end addEvent("setToner", true) addEventHandler("setToner", getRootElement(), setToner) It throws you errors cuz the part where you call the "setToner" function misses the last 3 arguments. Find where you trigger the "setToner" event and add the missing p1, p2 and p3 arguments. On 10/05/2021 at 18:24, andr0xy said: Those images are missing in the folder. thank you for your help 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