DRW Posted May 16, 2015 Share Posted May 16, 2015 So I'm using a shader to appear only when the GUI is open. It's called blurshader, here it is: https://community.multitheftauto.com/ind ... ls&id=7349 The thing is that I made something to my script to see if it works, and it actually does, for half a second. For some unknown reason the blurshader appears and dissapears at the same moment, I can see the blurshader for less than a second and then dissapears. Nothing in the debugscript. Client-sided only: local root = getRootElement() local resourceRoot = getResourceRootElement(getThisResource()) local screenWidth, screenHeight = guiGetScreenSize() local blurStrength = 6 local myScreenSource = dxCreateScreenSource(screenWidth, screenHeight) addEventHandler("onClientResourceStart", resourceRoot, function() if getVersion ().sortable < "1.3.1" then outputChatBox("Resource is not compatible with this client.") return else blurShader, blurTec = dxCreateShader("shaders/BlurShader.fx") if (not blurShader) then outputChatBox("Could not create blur shader. Please use debugscript 3.") else outputChatBox(blurTec .. " was started.") end end end) local screenW, screenH = guiGetScreenSize() ventanaclases = guiCreateWindow(10, (screenH - 369) / 2, 352, 369, "[ZNEXT] Elección de clases", false) guiWindowSetSizable(ventanaclases, false) labelclases = guiCreateLabel(10, 22, 89, 19, "Elige una clase:", false, ventanaclases) memoclases = guiCreateMemo(124, 43, 218, 316, "¡Bienvenid@ a ZNEXT: Zombies!\nAquí te vamos a enseñar los tipos de clases que puedes elegir a tu comodidad:\n\n\n\nRecibe una flor que sirve como forma de curar a la gente al golpe, además tiene regeneración de vida. Capacidad nula de atacar bases.\n\n\nArregla coches al entrar en ellos y escribir el comando /repararvehiculo. Tardas 10 segundos en repararlo.\n\n\nVende armas al escribir /vender, sus armas son más baratas y recibes menos dinero del que vendes con las armas.\n\n\nPiloto de rescate de Base 17, ayuda a la gente perdida a volver a la base o a transportar gente de un lugar a otro, gana dinero por cada 10 segundos cuando alguien está de copiloto.\n\n\nAsesina gente y gana 1500$, pero a los asesinos también se les captura, por ello, los que asesinen al bandido, ganarán 3000$.\n\n\nSólo está disponible si eres donante del server, pagando con PayPal al menos 2EUR.\n\n\nEl equipo de Staff: Moderadores, Super Moderadores, Community Managers y Admins.\n\n\nNo trabajas en nada, simplemente quieres jugar sin importarte un rol en general.\n\n\nEstos botones están en prueba, los dejamos ahí para evitar crear botones para futuras clases.", false, ventanaclases) guiMemoSetReadOnly(memoclases, true) botclass1 = guiCreateButton(10, 43, 115, 28, "MÉDICO", false, ventanaclases) guiSetFont(botclass1, "default-bold-small") guiSetProperty(botclass1, "NormalTextColour", "FF76EA84") botclass2 = guiCreateButton(10, 71, 115, 28, "MECÁNICO", false, ventanaclases) guiSetFont(botclass2, "default-bold-small") guiSetProperty(botclass2, "NormalTextColour", "FFF5F16C") botclass3 = guiCreateButton(10, 99, 115, 28, "TRAFICANTE", false, ventanaclases) guiSetFont(botclass3, "default-bold-small") guiSetProperty(botclass3, "NormalTextColour", "FFAE2BEB") botclass4 = guiCreateButton(10, 127, 115, 28, "RESCATE AÉREO", false, ventanaclases) guiSetFont(botclass4, "default-bold-small") guiSetProperty(botclass4, "NormalTextColour", "FF17FCEE") botclass5 = guiCreateButton(10, 155, 115, 28, "BANDIDO", false, ventanaclases) guiSetFont(botclass5, "default-bold-small") guiSetProperty(botclass5, "NormalTextColour", "FFCF0505") botclass6 = guiCreateButton(10, 183, 115, 28, "PROTECCIÓN MILITAR", false, ventanaclases) guiSetFont(botclass6, "default-bold-small") guiSetProperty(botclass6, "NormalTextColour", "FF1E641C") botclass7 = guiCreateButton(10, 211, 115, 28, "STAFF", false, ventanaclases) guiSetFont(botclass7, "default-bold-small") guiSetProperty(botclass7, "NormalTextColour", "FFAAAAAA") botclass8 = guiCreateButton(10, 239, 115, 28, "SIN OFICIO", false, ventanaclases) guiSetFont(botclass8, "default-bold-small") guiSetProperty(botclass8, "NormalTextColour", "FFFFFFFF") botclass9 = guiCreateButton(10, 267, 115, 28, "(Botón inútil)", false, ventanaclases) guiSetProperty(botclass9, "NormalTextColour", "FF0E7164") botclass10 = guiCreateButton(10, 295, 115, 28, "(Botón inútil)", false, ventanaclases) guiSetProperty(botclass10, "NormalTextColour", "FF0E7164") botclass11 = guiCreateButton(10, 321, 115, 28, "(Botón inútil)", false, ventanaclases) guiSetProperty(botclass11, "NormalTextColour", "FF0E7164") addEventHandler ("onClientResourceStart", getResourceRootElement(getThisResource()), function () guiSetVisible (ventanaclases, false) end) addEvent ("abrirventana",true) addEventHandler ("abrirventana", getRootElement(), function () setCameraMatrix (-425,2627,86, -514,2589,54) guiSetVisible (ventanaclases, true) if (blurShader) then dxUpdateScreenSource(myScreenSource) dxSetShaderValue(blurShader, "ScreenSource", myScreenSource); dxSetShaderValue(blurShader, "BlurStrength", blurStrength); dxSetShaderValue(blurShader, "UVSize", screenWidth, screenHeight); dxDrawImage(0, 0, screenWidth, screenHeight, blurShader) showCursor (true) end end ) addEventHandler ("onClientGUIClick", botclass1, function () triggerServerEvent ("team1", localPlayer) end ) addEventHandler ("onClientGUIClick", botclass2, function () triggerServerEvent ("team2", localPlayer) end ) addEventHandler ("onClientGUIClick", botclass3, function () triggerServerEvent ("team3", localPlayer) end ) addEventHandler ("onClientGUIClick", botclass4, function () triggerServerEvent ("team4", localPlayer) end ) addEventHandler ("onClientGUIClick", botclass5, function () triggerServerEvent ("team5", localPlayer) end ) addEventHandler ("onClientGUIClick", botclass6, function () triggerServerEvent ("team6", localPlayer) end ) addEventHandler ("onClientGUIClick", botclass7, function () triggerServerEvent ("team7", localPlayer) end ) addEventHandler ("onClientGUIClick", botclass8, function () triggerServerEvent ("team8", localPlayer) end ) addEvent ("amosnose",true) addEventHandler ("amosnose", getRootElement(), function() guiSetVisible (ventanaclases, false) if (blurShader) then destroyElement(blurShader) blurShader = nil setCameraTarget (localPlayer) showCursor (false) end end) Link to comment
WhoAmI Posted May 16, 2015 Share Posted May 16, 2015 Use this script instead, much simplier. https://community.multitheftauto.com/ind ... s&id=10163 Documentation: https://wiki.multitheftauto.com/wiki/Resource:Blur_box Link to comment
Walid Posted May 16, 2015 Share Posted May 16, 2015 you need to use "onClientPreRender" event to make the shader appear for a long time. try this it should work local root = getRootElement() local resourceRoot = getResourceRootElement(getThisResource()) local screenWidth, screenHeight = guiGetScreenSize() local blurStrength = 6 local myScreenSource = dxCreateScreenSource(screenWidth, screenHeight) addEventHandler ("onClientResourceStart", resourceRoot, function () local screenW, screenH = guiGetScreenSize() ventanaclases = guiCreateWindow(10, (screenH - 369) / 2, 352, 369, "[ZNEXT] Elección de clases", false) guiWindowSetSizable(ventanaclases, false) labelclases = guiCreateLabel(10, 22, 89, 19, "Elige una clase:", false, ventanaclases) memoclases = guiCreateMemo(124, 43, 218, 316, "¡Bienvenid@ a ZNEXT: Zombies!\nAquí te vamos a enseñar los tipos de clases que puedes elegir a tu comodidad:\n\n\n\nRecibe una flor que sirve como forma de curar a la gente al golpe, además tiene regeneración de vida. Capacidad nula de atacar bases.\n\n\nArregla coches al entrar en ellos y escribir el comando /repararvehiculo. Tardas 10 segundos en repararlo.\n\n\nVende armas al escribir /vender, sus armas son más baratas y recibes menos dinero del que vendes con las armas.\n\n\nPiloto de rescate de Base 17, ayuda a la gente perdida a volver a la base o a transportar gente de un lugar a otro, gana dinero por cada 10 segundos cuando alguien está de copiloto.\n\n\nAsesina gente y gana 1500$, pero a los asesinos también se les captura, por ello, los que asesinen al bandido, ganarán 3000$.\n\n\nSólo está disponible si eres donante del server, pagando con PayPal al menos 2EUR.\n\n\nEl equipo de Staff: Moderadores, Super Moderadores, Community Managers y Admins.\n\n\nNo trabajas en nada, simplemente quieres jugar sin importarte un rol en general.\n\n\nEstos botones están en prueba, los dejamos ahí para evitar crear botones para futuras clases.", false, ventanaclases) guiMemoSetReadOnly(memoclases, true) botclass1 = guiCreateButton(10, 43, 115, 28, "MÉDICO", false, ventanaclases) guiSetFont(botclass1, "default-bold-small") guiSetProperty(botclass1, "NormalTextColour", "FF76EA84") botclass2 = guiCreateButton(10, 71, 115, 28, "MECÁNICO", false, ventanaclases) guiSetFont(botclass2, "default-bold-small") guiSetProperty(botclass2, "NormalTextColour", "FFF5F16C") botclass3 = guiCreateButton(10, 99, 115, 28, "TRAFICANTE", false, ventanaclases) guiSetFont(botclass3, "default-bold-small") guiSetProperty(botclass3, "NormalTextColour", "FFAE2BEB") botclass4 = guiCreateButton(10, 127, 115, 28, "RESCATE AÉREO", false, ventanaclases) guiSetFont(botclass4, "default-bold-small") guiSetProperty(botclass4, "NormalTextColour", "FF17FCEE") botclass5 = guiCreateButton(10, 155, 115, 28, "BANDIDO", false, ventanaclases) guiSetFont(botclass5, "default-bold-small") guiSetProperty(botclass5, "NormalTextColour", "FFCF0505") botclass6 = guiCreateButton(10, 183, 115, 28, "PROTECCIÓN MILITAR", false, ventanaclases) guiSetFont(botclass6, "default-bold-small") guiSetProperty(botclass6, "NormalTextColour", "FF1E641C") botclass7 = guiCreateButton(10, 211, 115, 28, "STAFF", false, ventanaclases) guiSetFont(botclass7, "default-bold-small") guiSetProperty(botclass7, "NormalTextColour", "FFAAAAAA") botclass8 = guiCreateButton(10, 239, 115, 28, "SIN OFICIO", false, ventanaclases) guiSetFont(botclass8, "default-bold-small") guiSetProperty(botclass8, "NormalTextColour", "FFFFFFFF") botclass9 = guiCreateButton(10, 267, 115, 28, "(Botón inútil)", false, ventanaclases) guiSetProperty(botclass9, "NormalTextColour", "FF0E7164") botclass10 = guiCreateButton(10, 295, 115, 28, "(Botón inútil)", false, ventanaclases) guiSetProperty(botclass10, "NormalTextColour", "FF0E7164") botclass11 = guiCreateButton(10, 321, 115, 28, "(Botón inútil)", false, ventanaclases) guiSetProperty(botclass11, "NormalTextColour", "FF0E7164") guiSetVisible (ventanaclases, false) if getVersion ().sortable < "1.3.1" then outputChatBox("Resource is not compatible with this client.") return else blurShader, blurTec = dxCreateShader("shaders/BlurShader.fx") if (not blurShader) then outputChatBox("Could not create blur shader. Please use debugscript 3.") else outputChatBox(blurTec .. " was started.") end end end ) addEvent ("abrirventana",true) addEventHandler ("abrirventana", getRootElement(), function () setCameraMatrix (-425,2627,86, -514,2589,54) guiSetVisible (ventanaclases, true) showCursor (true) addEventHandler("onClientPreRender", root,drawShader) end ) addEvent ("amosnose",true) addEventHandler ("amosnose", getRootElement(), function() guiSetVisible (ventanaclases, false) if (blurShader) then removeEventHandler("onClientPreRender", root,drawShader) destroyElement(blurShader) blurShader = nil setCameraTarget (localPlayer) showCursor (false) end end ) addEventHandler ("onClientGUIClick", guiRoot, function () if source == botclass1 then triggerServerEvent ("team1", localPlayer) elseif source == botclass2 then triggerServerEvent ("team2", localPlayer) elseif source == botclass3 then triggerServerEvent ("team3", localPlayer) elseif source == botclass4 then triggerServerEvent ("team4", localPlayer) elseif source == botclass5 then triggerServerEvent ("team5", localPlayer) elseif source == botclass6 then triggerServerEvent ("team6", localPlayer) elseif source == botclass7 then triggerServerEvent ("team7", localPlayer) elseif source == botclass8 then triggerServerEvent ("team8", localPlayer) end end ) function drawShader() if (blurShader) then dxUpdateScreenSource(myScreenSource) dxSetShaderValue(blurShader, "ScreenSource", myScreenSource); dxSetShaderValue(blurShader, "BlurStrength", blurStrength); dxSetShaderValue(blurShader, "UVSize", screenWidth, screenHeight); dxDrawImage(0, 0, screenWidth, screenHeight, blurShader) end end 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