Jump to content

[Solucionado] Modo relative en un DX


aka Blue

Recommended Posts

Buenas. Bueno, me dijeron que ponga relative en cada gui que haga para que así, a otro jugador con menor resolución no se le ¿distorsione? el panel por lo cual, le puse a todos los objetos de mi gui dx relative. El problema viene a la hora de usar la función isCursorOnElement.

¿Qué debo poner?

Pondré un ejemplo. Al ponerlo relativo, las coordenadas salen así:

creenW * 0.324, screenH * 0.202, screenW * 0.351, screenH * 0.615 

Entonces yo en la función de detectar el cursor pongo, cuando no es relativo:

if isCursorOnElement ( 440, 297, 146, 32) then 

Resumiendo, mi duda es, ¿qué debo poner en las coordenadas en caso de que sea relativo?

Edited by Guest
Link to comment

Prueba con esto, utiliza las posiciones relativas (sin aritmética, sólo el númerito)

  
function isCursorOnElement(x,y,w,h) 
    local mx,my = getCursorPosition () 
    local fullx,fully = guiGetScreenSize() 
    cursorx,cursory = mx*fullx,my*fully 
    if ( x < 1 and y < 1 and w < 1 and h < 1 ) then 
        x, y, w, h = x*fullx, y*fully, w*fullx, h*fully 
    end 
    if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then 
        return true 
    else 
        return false 
    end 
end 
  

Link to comment

Nada, sigue igual. Dejo el código por si he fallado en algo pero no lo entiendo.

local screenW, screenH = guiGetScreenSize() 
abrido = false 
function tuneos () 
        dxDrawRectangle(screenW * 0.7344, screenH * 0.3802, screenW * 0.2559, screenH * 0.0404, tocolor(0, 255, 120, 150), false) 
        dxDrawText("Tuneos", screenW * 0.7344, screenH * 0.3802, screenW * 0.9902, screenH * 0.4206, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(screenW * 0.7344, screenH * 0.4206, screenW * 0.2559, screenH * 0.3815, tocolor(0, 0, 0, 100), false) 
        dxDrawRectangle(screenW * 0.7344, screenH * 0.7982, screenW * 0.2559, screenH * 0.0247, tocolor(0, 255, 120, 150), false) 
        dxDrawText("Cerrar panel", screenW * 0.7344, screenH * 0.7982, screenW * 0.9902, screenH * 0.8229, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(screenW * 0.7842, screenH * 0.4336, screenW * 0.1611, screenH * 0.0326, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Parachoques\nDelantero", screenW * 0.7842, screenH * 0.4336, screenW * 0.9453, screenH * 0.4661, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(screenW * 0.7842, screenH * 0.4727, screenW * 0.1611, screenH * 0.0326, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Parachoques\nTrasero", screenW * 0.7842, screenH * 0.4727, screenW * 0.9453, screenH * 0.5052, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(screenW * 0.7842, screenH * 0.5117, screenW * 0.1611, screenH * 0.0326, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Alerones", screenW * 0.7842, screenH * 0.5117, screenW * 0.9453, screenH * 0.5443, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 423, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Faldones\nDisponibles", screenW * 0.7842, screenH * 0.5508, screenW * 0.9453, screenH * 0.5833, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 454, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Techos", screenW * 0.7842, screenH * 0.5911, screenW * 0.9453, screenH * 0.6237, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 484, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Hidraulica", screenW * 0.7842, screenH * 0.6302, screenW * 0.9453, screenH * 0.6628, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 514, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Barras delanteras", screenW * 0.7842, screenH * 0.6693, screenW * 0.9453, screenH * 0.7018, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 547, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Barras Traseras", screenW * 0.7842, screenH * 0.7122, screenW * 0.9453, screenH * 0.7448, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 578, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Tubos de escape", screenW * 0.7842, screenH * 0.7526, screenW * 0.9453, screenH * 0.7852, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
  
    showCursor(true) 
    abrido = true 
end 
function dibujo() 
addEventHandler("onClientRender", getRootElement(), tuneos) 
addEventHandler("onClientClick", getRootElement(), clickeo) 
end 
addEvent("onTuneo", true) 
addEventHandler("onTuneo", getRootElement(), dibujo) 
  
function isCursorOnElement(x,y,w,h) 
    local mx,my = getCursorPosition () 
    local fullx,fully = guiGetScreenSize() 
    cursorx,cursory = mx*fullx,my*fully 
    if ( x < 1 and y < 1 and w < 1 and h < 1 ) then 
        x, y, w, h = x*fullx, y*fully, w*fullx, h*fully 
    end 
    if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then 
        return true 
    else 
        return false 
    end 
end 
  
function clickeo ( _,state) 
if abrido then 
  if state == "down" then 
   if isCursorOnElement ( 0.7344, 0.7982, 0.9902, 0.8229) then--Boton cerrar 
     abrido = false 
     showCursor (false) 
     removeEventHandler ( "onClientRender", root, tuneos ) 
     removeEventHandler ( "onClientClick", getRootElement(), clickeo) 
    elseif isCursorOnElement (0.7842, 0.4336, 0.9453, 0.4661 ) then--Parachoques delantero 
      abrido = false 
    exports.gui:show('meca1') 
     showCursor (false) 
     removeEventHandler ( "onClientRender", root, tuneos ) 
     removeEventHandler ( "onClientClick", getRootElement(), clickeo) 
  end 
  end 
 end 
end 
addEventHandler ( "onClientClick", getRootElement(), clickeo) 

Ni caso al "abrido", xD.

Link to comment

Prueba con esto:

  
function isCursorOnElement(x,y,w,h) 
    local mx,my = getCursorPosition () 
    local fullx,fully = guiGetScreenSize() 
    if ( not x < 1 and not y < 1 and not w < 1 and not h < 1 ) then 
            cursorx,cursory = mx*fullx,my*fully 
    end 
    if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then 
        return true 
    else 
        return false 
    end 
end 
  

Link to comment
  
  
function isCursorOnElement(x,y,w,h) 
    local mx,my = getCursorPosition () 
    local fullx,fully = guiGetScreenSize() 
    if ( not x < 1 and not y < 1 and not w < 1 and not h < 1 ) then 
            cursorx,cursory = mx*fullx,my*fully 
    else 
            cursorx,cursory = mx, my 
    end 
    if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then 
        return true 
    else 
        return false 
    end 
end 
  
  

Link to comment

Éste es mi código. Ahora le doy click y no hace nada, de donde le de.

local screenW, screenH = guiGetScreenSize() 
abrido = false 
function tuneos () 
        dxDrawRectangle(screenW * 0.7344, screenH * 0.3802, screenW * 0.2559, screenH * 0.0404, tocolor(0, 255, 120, 150), false) 
        dxDrawText("Tuneos", screenW * 0.7344, screenH * 0.3802, screenW * 0.9902, screenH * 0.4206, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(screenW * 0.7344, screenH * 0.4206, screenW * 0.2559, screenH * 0.3815, tocolor(0, 0, 0, 100), false) 
        dxDrawRectangle(screenW * 0.7344, screenH * 0.7982, screenW * 0.2559, screenH * 0.0247, tocolor(0, 255, 120, 150), false) 
        dxDrawText("Cerrar panel", screenW * 0.7344, screenH * 0.7982, screenW * 0.9902, screenH * 0.8229, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(screenW * 0.7842, screenH * 0.4336, screenW * 0.1611, screenH * 0.0326, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Parachoques\nDelantero", screenW * 0.7842, screenH * 0.4336, screenW * 0.9453, screenH * 0.4661, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(screenW * 0.7842, screenH * 0.4727, screenW * 0.1611, screenH * 0.0326, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Parachoques\nTrasero", screenW * 0.7842, screenH * 0.4727, screenW * 0.9453, screenH * 0.5052, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(screenW * 0.7842, screenH * 0.5117, screenW * 0.1611, screenH * 0.0326, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Alerones", screenW * 0.7842, screenH * 0.5117, screenW * 0.9453, screenH * 0.5443, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 423, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Faldones\nDisponibles", screenW * 0.7842, screenH * 0.5508, screenW * 0.9453, screenH * 0.5833, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 454, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Techos", screenW * 0.7842, screenH * 0.5911, screenW * 0.9453, screenH * 0.6237, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 484, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Hidraulica", screenW * 0.7842, screenH * 0.6302, screenW * 0.9453, screenH * 0.6628, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 514, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Barras delanteras", screenW * 0.7842, screenH * 0.6693, screenW * 0.9453, screenH * 0.7018, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 547, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Barras Traseras", screenW * 0.7842, screenH * 0.7122, screenW * 0.9453, screenH * 0.7448, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 578, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Tubos de escape", screenW * 0.7842, screenH * 0.7526, screenW * 0.9453, screenH * 0.7852, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
  
    showCursor(true) 
    abrido = true 
end 
function dibujo() 
addEventHandler("onClientRender", getRootElement(), tuneos) 
addEventHandler("onClientClick", getRootElement(), clickeo) 
end 
addEvent("onTuneo", true) 
addEventHandler("onTuneo", getRootElement(), dibujo) 
  
function isCursorOnElement(x,y,w,h) 
    local mx,my = getCursorPosition () 
    local fullx,fully = guiGetScreenSize() 
    if ( not x < 1 and not y < 1 and not w < 1 and not h < 1 ) then 
            cursorx,cursory = mx*fullx,my*fully 
    else 
            cursorx,cursory = mx, my 
    end 
    if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then 
        return true 
    else 
        return false 
    end 
end 
  
function clickeo ( _,state) 
if abrido then 
  if state == "down" then 
   if isCursorOnElement ( 0.7344, 0.7982, 0.9902, 0.8229) then--Boton cerrar 
     abrido = false 
     showCursor (false) 
     removeEventHandler ( "onClientRender", root, tuneos ) 
     removeEventHandler ( "onClientClick", getRootElement(), clickeo) 
    elseif isCursorOnElement (0.7842, 0.4336, 0.9453, 0.4661 ) then--Parachoques delantero 
      abrido = false 
    exports.gui:show('meca1') 
     showCursor (false) 
     removeEventHandler ( "onClientRender", root, tuneos ) 
     removeEventHandler ( "onClientClick", getRootElement(), clickeo) 
  end 
  end 
 end 
end 
addEventHandler ( "onClientClick", getRootElement(), clickeo) 
  
-------------------------------------------------------------------------------------- 

Link to comment

getCursorPosition ya devuelve los valores de manera relativa.

  
function isCursorOnElement(x,y,w,h) 
    local cursorx, cursory = getCursorPosition () 
  
    if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then 
        return true 
    else 
        return false 
    end 
end 

Link to comment

El problema ahí es el siguiente (disculpa doble post), como ves, tengo asignadas dos posiciones. La de cerrar y la de los parachoques delanteros. Muy bien, lo que pasa es que ponga donde ponga el cursor, en cualquier botón, sale la gui del parachoques delantero

local screenW, screenH = guiGetScreenSize() 
abrido = false 
function tuneos () 
        dxDrawRectangle(screenW * 0.7344, screenH * 0.3802, screenW * 0.2559, screenH * 0.0404, tocolor(0, 255, 120, 150), false) 
        dxDrawText("Tuneos", screenW * 0.7344, screenH * 0.3802, screenW * 0.9902, screenH * 0.4206, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(screenW * 0.7344, screenH * 0.4206, screenW * 0.2559, screenH * 0.3815, tocolor(0, 0, 0, 100), false) 
        dxDrawRectangle(screenW * 0.7344, screenH * 0.7982, screenW * 0.2559, screenH * 0.0247, tocolor(0, 255, 120, 150), false) 
        dxDrawText("Cerrar panel", screenW * 0.7344, screenH * 0.7982, screenW * 0.9902, screenH * 0.8229, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(screenW * 0.7842, screenH * 0.4336, screenW * 0.1611, screenH * 0.0326, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Parachoques\nDelantero", screenW * 0.7842, screenH * 0.4336, screenW * 0.9453, screenH * 0.4661, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(screenW * 0.7842, screenH * 0.4727, screenW * 0.1611, screenH * 0.0326, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Parachoques\nTrasero", screenW * 0.7842, screenH * 0.4727, screenW * 0.9453, screenH * 0.5052, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(screenW * 0.7842, screenH * 0.5117, screenW * 0.1611, screenH * 0.0326, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Alerones", screenW * 0.7842, screenH * 0.5117, screenW * 0.9453, screenH * 0.5443, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 423, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Faldones\nDisponibles", screenW * 0.7842, screenH * 0.5508, screenW * 0.9453, screenH * 0.5833, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 454, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Techos", screenW * 0.7842, screenH * 0.5911, screenW * 0.9453, screenH * 0.6237, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 484, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Hidraulica", screenW * 0.7842, screenH * 0.6302, screenW * 0.9453, screenH * 0.6628, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 514, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Barras delanteras", screenW * 0.7842, screenH * 0.6693, screenW * 0.9453, screenH * 0.7018, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 547, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Barras Traseras", screenW * 0.7842, screenH * 0.7122, screenW * 0.9453, screenH * 0.7448, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(803, 578, 165, 25, tocolor(0, 0, 0, 150), false) 
        dxDrawText("Tubos de escape", screenW * 0.7842, screenH * 0.7526, screenW * 0.9453, screenH * 0.7852, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) 
  
    showCursor(true) 
    abrido = true 
end 
function dibujo() 
addEventHandler("onClientRender", getRootElement(), tuneos) 
addEventHandler("onClientClick", getRootElement(), clickeo) 
end 
addEvent("onTuneo", true) 
addEventHandler("onTuneo", getRootElement(), dibujo) 
  
function isCursorOnElement(x,y,w,h) 
    local cursorx, cursory = getCursorPosition () 
  
    if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then 
        return true 
    else 
        return false 
    end 
end 
  
function clickeo ( _,state) 
if abrido then 
  if state == "down" then 
   if isCursorOnElement ( 0.7344, 0.7982, 0.9902, 0.8229) then--Boton cerrar 
     abrido = false 
     showCursor (false) 
     removeEventHandler ( "onClientRender", root, tuneos ) 
     removeEventHandler ( "onClientClick", getRootElement(), clickeo) 
    elseif isCursorOnElement (0.7842, 0.4336, 0.9453, 0.4661 ) then--Parachoques delantero 
      abrido = false 
    exports.gui:show('meca1') 
     showCursor (false) 
     removeEventHandler ( "onClientRender", root, tuneos ) 
     removeEventHandler ( "onClientClick", getRootElement(), clickeo) 
  end 
  end 
 end 
end 
addEventHandler ( "onClientClick", getRootElement(), clickeo) 
  
-------------------------------------------------------------------------------------- 

Link to comment

Mejor usa esta función

function isMouseInPosition ( x, y, width, height ) 
    if ( not isCursorShowing ( ) ) then return false end  
    local sx, sy = guiGetScreenSize ( )  
    local cx, cy = getCursorPosition ( ) 
    local cx, cy = ( cx * sx ), ( cy * sy )  
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then  
        return true 
    else  
        return false  
    end  
end 

Por ejemplo

dxDrawRectangle(screenW * 0.7344, screenH * 0.4206, screenW * 0.2559, screenH * 0.3815, tocolor(0, 0, 0, 100), false) 
  
if isMouseInPosition (screenW * 0.7344, screenH * 0.4206, screenW * 0.2559, screenH * 0.3815) then 
    -- Blablabla  
end[ 

Link to comment
Mejor usa esta función
function isMouseInPosition ( x, y, width, height ) 
    if ( not isCursorShowing ( ) ) then return false end  
    local sx, sy = guiGetScreenSize ( )  
    local cx, cy = getCursorPosition ( ) 
    local cx, cy = ( cx * sx ), ( cy * sy )  
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then  
        return true 
    else  
        return false  
    end  
end 

Por ejemplo

dxDrawRectangle(screenW * 0.7344, screenH * 0.4206, screenW * 0.2559, screenH * 0.3815, tocolor(0, 0, 0, 100), false) 
  
if isMouseInPosition (screenW * 0.7344, screenH * 0.4206, screenW * 0.2559, screenH * 0.3815) then 
    -- Blablabla  
end[ 

Él está usando valores relativos, eso sólo funconaría con absolutos.

@Sasu Y ahora me dices :x

Link to comment
Él está usando valores relativos, eso sólo funconaría con absolutos.

Pero si pone los mismos valores relativos en los argumentos de la función igual debería funcionar, a mi me funcionaba ._.

¿Los valores relativos no son los de "0.9, 0.5"?

Según lo que he entendido de la wiki él está utilizando valores absolutos, simplemente hace esa ecuación para que se vea en todas la resoluciones ¿o no? Quien me saca de esta duda xD

Link to comment

Para hacer ese panel usé guieditor, marqué cada panel y texto como relative.

PD: Me salió ahora un problemilla. No funciona bien, es decir, cuando clickeo donde tendría que funcionar, no va.

local screenW, screenH = guiGetScreenSize() 
  
renderizado = false 
 function panelsito () 
        dxDrawRectangle(screenW * 0.3896, screenH * 0.3529, screenW * 0.2285, screenH * 0.4023, tocolor(0, 0, 0, 100), false) 
        dxDrawRectangle(screenW * 0.3896, screenH * 0.3034, screenW * 0.2285, screenH * 0.0495, tocolor(0, 255, 120, 150), false) 
        dxDrawText("Panel Mecánico", screenW * 0.3896, screenH * 0.3008, screenW * 0.6182, screenH * 0.3529, tocolor(255, 255, 255, 255), 1.80, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(441, 297, 146, 32, tocolor(0, 255, 120, 44), false) 
        dxDrawText("Reparar", screenW * 0.4307, screenH * 0.3854, screenW * 0.5742, screenH * 0.4284, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(440, 349, 146, 32, tocolor(0, 255, 120, 44), false) 
        dxDrawRectangle(441, 406, 146, 32, tocolor(0, 255, 120, 44), false) 
        dxDrawText("Ruedas", screenW * 0.4297, screenH * 0.5273, screenW * 0.5732, screenH * 0.5703, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(screenW * 0.4297, screenH * 0.6055, screenW * 0.1426, screenH * 0.0417, tocolor(0, 255, 120, 44), false) 
        dxDrawRectangle(screenW * 0.4307, screenH * 0.6849, screenW * 0.1426, screenH * 0.0417, tocolor(0, 255, 120, 44), false) 
        dxDrawText("Luces", screenW * 0.4307, screenH * 0.6849, screenW * 0.5742, screenH * 0.7279, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawRectangle(screenW * 0.3896, screenH * 0.7552, screenW * 0.2285, screenH * 0.0313, tocolor(0, 255, 120, 150), false) 
        dxDrawText("Cerrar", screenW * 0.3896, screenH * 0.7552, screenW * 0.6182, screenH * 0.7865, tocolor(255, 255, 255, 255), 1.40, "default-bold", "center", "top", false, false, false, false, false) 
        dxDrawLine(screenW * 0.3896, screenH * 0.3034, screenW * 0.3896, screenH * 0.7852, tocolor(0, 0, 0, 200), 1, false) 
        dxDrawLine(screenW * 0.6182, screenH * 0.3047, screenW * 0.6182, screenH * 0.7865, tocolor(0, 0, 0, 200), 1, false) 
        dxDrawText("Pintar", screenW * 0.4307, screenH * 0.4544, screenW * 0.5742, screenH * 0.4974, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false) 
        dxDrawText("Inflar", screenW * 0.4307, screenH * 0.6042, screenW * 0.5742, screenH * 0.6471, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false) 
       
     renderizado = true 
     showCursor (true) 
end 
function openPanel() 
addEventHandler ( "onClientRender", getRootElement(), panelsito ) 
addEventHandler ( "onClientClick", getRootElement(), repararlo) 
end 
addEvent("openMeca", true) 
addEventHandler("openMeca", getRootElement(), openPanel) 
  
function isCursorOnElement(x,y,w,h) 
    local cursorx, cursory = getCursorPosition () 
  
    if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then 
        return true 
    else 
        return false 
    end 
end 
  
function repararlo ( _,state) 
if renderizado then 
  if state == "down" then 
   if isCursorOnElement (0.4307, 0.3854, 0.5742, 0.4284) then 
     triggerServerEvent ( "onReparar", getLocalPlayer() ) 
     showCursor (false) 
    renderizado = false 
     removeEventHandler ( "onClientRender", root, panelsito ) 
     removeEventHandler ( "onClientClick", getRootElement(), repararlo) 
    elseif isCursorOnElement (0.4307, 0.6042, 0.5742, 0.6471) then 
     abririnflar () 
     renderizado = false 
     showCursor (true) 
     removeEventHandler ( "onClientRender", root, panelsito ) 
     removeEventHandler ( "onClientClick", getRootElement(), repararlo) 
    elseif isCursorOnElement (  0.4307,  0.4544,  0.5742,  0.4974 ) then 
     abrirelpanel () 
     showCursor (true) 
     renderizado = false 
     removeEventHandler ( "onClientRender", root, panelsito ) 
     removeEventHandler ( "onClientClick", getRootElement(), repararlo) 
    elseif isCursorOnElement (  0.4297,  0.5273,  0.5732,  0.5703 ) then 
     ruedas () 
     showCursor (true) 
    renderizado = false 
     removeEventHandler ( "onClientRender", root, panelsito ) 
     removeEventHandler ( "onClientClick", getRootElement(), repararlo) 
    elseif isCursorOnElement (  0.4307,  0.6849,  0.5742,  0.7279 ) then 
     lucesitas () 
     showCursor (true) 
     renderizado = false 
     removeEventHandler ( "onClientRender", root, panelsito ) 
     removeEventHandler ( "onClientClick", getRootElement(), repararlo) 
 elseif isCursorOnElement (  0.3896,  0.7552,  0.6182,  0.7865 ) then 
     showCursor (false) 
     renderizado = false 
     removeEventHandler ( "onClientRender", root, panelsito ) 
     removeEventHandler ( "onClientClick", getRootElement(), repararlo) 
end 
  end 
 end 
end 
addEventHandler ( "onClientClick", getRootElement(), repararlo) 

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...