Jump to content

Ayuda sobre la Interfaz


aka Blue

Recommended Posts

No jaja, es lo más extraño. Supongo que es por las funciones que tengo en el onReparar (ya sabes, si está en x facción, si está subido en el vehículo, si tiene dinero para pagar la reparación...)

Y es super extraño porque hace el onReparar des donde le des, esa es la explicación que quería dar, supongo jaja.

Link to comment

mm ya encontre el problema le estas poniendo mucho ancho y largo

tu error

dxDrawRectangle(441, 297, 146, 32, tocolor(255, 255, 255, 40), false) 
dxDrawText("Reparar", 440, 297, 587, 330, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
----- 
isCursorOnElement ( 440, 297, 587, 330) -- le estas poniendo el ancho y largo del dxText y deberia ser el ancho y largo del dxRectangle 
  

copia esta parte y reemplazarlo y ya debe de funcionarte bien

PD: ya lo probe para que no haya mas errores

function repararlo ( ) 
   if isCursorOnElement ( 440, 297, 146, 32) then 
     triggerServerEvent ( "onReparar", getLocalPlayer() ) 
     removeEventHandler ( "onClientRender", root, panelsito ) 
    elseif isCursorOnElement ( 440, 348, 146, 32 ) then 
     triggerServerEvent ( "onPintar", getLocalPlayer() ) 
     removeEventHandler ( "onClientRender", root, panelsito ) 
  end 
end 
addEventHandler ( "onClientClick", getRootElement(), repararlo) 

Link to comment

Nono, verás. Al hacer click digamos en el color mismo, yo tengo un evento que abre un panel para elegir diferentes colores (la GUI es un cliente). Diría hacer que al clickear dicho botón en el panel (en el DX) abra el panel de colores (en la GUI normal).

Ambas funciones son clientes por lo tanto no sé si eso es posible.

Link to comment

Aquí tienes. Es un script que colocaré en la comunidad de MTA así que bueno, el código es free to use :)

  
function abririnflar () 
  
        InflarPanel = guiCreateWindow(715, 280, 201, 219, "Inflar ruedas", false) 
        guiWindowSetSizable(InflarPanel, false) 
        guiSetAlpha(InflarPanel, 0.68) 
  
        DIzquierda = guiCreateButton(9, 34, 71, 39, "Delantera Izquierda", false, InflarPanel) 
        guiSetFont(DIzquierda, "default-bold-small") 
        DDerecha = guiCreateButton(120, 34, 71, 39, "Delantera Derecha", false, InflarPanel) 
        guiSetFont(DDerecha, "default-bold-small") 
        TIzquierda = guiCreateButton(9, 116, 71, 39, "Trasera Izquierda", false, InflarPanel) 
        guiSetFont(TIzquierda, "default-bold-small") 
        TDerecha = guiCreateButton(120, 116, 71, 39, "Trasera Derecha", false, InflarPanel) 
        guiSetFont(TDerecha, "default-bold-small") 
        CerrarPanel = guiCreateButton(48, 178, 99, 31, "Cerrar ", false, InflarPanel) 
        guiSetFont(CerrarPanel, "default-bold-small")     
         
       showCursor (true) 
    addEventHandler ("onClientGUIClick", CerrarPanel, cerrar, false) 
    addEventHandler ("onClientGUIClick", DIzquierda, inflardizquierda, false) 
    addEventHandler ("onClientGUIClick", DDerecha, inflardderecha, false) 
    addEventHandler ("onClientGUIClick", TIzquierda, inflartizquierda, false) 
    addEventHandler ("onClientGUIClick", TDerecha, inflartderecha, false) 
         
end 
addEvent( "openInflar", true ) 
addEventHandler( "opneInflar", localPlayer, abririnflar ) 
  
function cerrar () 
guiSetVisible (InflarPanel, not guiGetVisible ( InflarPanel ) ) 
showCursor (false) 
end 
  
function inflardizquierda () 
triggerServerEvent ( "onInflar1", getLocalPlayer() ) 
end 
  
function inflardderecha () 
triggerServerEvent ( "onInflar2", getLocalPlayer() ) 
end 
  
function inflartizquierda () 
triggerServerEvent ( "onInflar3", getLocalPlayer() ) 
end 
  
function inflartderecha () 
triggerServerEvent ( "onInflar4", getLocalPlayer() ) 
end 
  
  
  

Link to comment

Hum, no funciona por lo que veo.

  
function abririnflar () 
  
        InflarPanel = guiCreateWindow(715, 280, 201, 219, "Inflar ruedas", false) 
        guiWindowSetSizable(InflarPanel, false) 
        guiSetAlpha(InflarPanel, 0.68) 
  
        DIzquierda = guiCreateButton(9, 34, 71, 39, "Delantera Izquierda", false, InflarPanel) 
        guiSetFont(DIzquierda, "default-bold-small") 
        DDerecha = guiCreateButton(120, 34, 71, 39, "Delantera Derecha", false, InflarPanel) 
        guiSetFont(DDerecha, "default-bold-small") 
        TIzquierda = guiCreateButton(9, 116, 71, 39, "Trasera Izquierda", false, InflarPanel) 
        guiSetFont(TIzquierda, "default-bold-small") 
        TDerecha = guiCreateButton(120, 116, 71, 39, "Trasera Derecha", false, InflarPanel) 
        guiSetFont(TDerecha, "default-bold-small") 
        CerrarPanel = guiCreateButton(48, 178, 99, 31, "Cerrar ", false, InflarPanel) 
        guiSetFont(CerrarPanel, "default-bold-small")     
        
       showCursor (true) 
    addEventHandler ("onClientGUIClick", CerrarPanel, cerrar, false) 
    addEventHandler ("onClientGUIClick", DIzquierda, inflardizquierda, false) 
    addEventHandler ("onClientGUIClick", DDerecha, inflardderecha, false) 
    addEventHandler ("onClientGUIClick", TIzquierda, inflartizquierda, false) 
    addEventHandler ("onClientGUIClick", TDerecha, inflartderecha, false) 
        
end 
addEvent( "openInflar", true ) 
addEventHandler( "opneInflar", localPlayer, abririnflar ) 
  
function cerrar () 
guiSetVisible (InflarPanel, not guiGetVisible ( InflarPanel ) ) 
showCursor (false) 
end 
--------------------------------------------- 
function panelsito () 
        dxDrawRectangle(344, 266, 334, 316, tocolor(127, 127, 127, 50), false) 
        dxDrawRectangle(344, 179, 334, 87, tocolor(255, 255, 255, 40), false) 
        dxDrawText("Panel Mecánico", 415, 206, 607, 256, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, false, false, false) 
        dxDrawRectangle(344, 582, 334, 23, tocolor(255, 255, 255, 40), false) 
     dxDrawRectangle(441, 297, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawText("Reparar", 440, 297, 587, 330, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
        dxDrawText("Pintar", 440, 348, 587, 381, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
        dxDrawRectangle(441, 349, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawRectangle(441, 406, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawText("Ruedas", 441, 406, 588, 439, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
        dxDrawText("Inflar", 441, 466, 588, 499, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
        dxDrawRectangle(441, 467, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawRectangle(441, 526, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawText("Luces", 441, 525, 588, 558, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
  
     showCursor (true) 
end 
function openPanel() 
addEventHandler ( "onClientRender", root, panelsito ) 
end 
addCommandHandler ("panel", openPanel) 
  
function isCursorOnElement(x,y,w,h) 
    local mx,my = getCursorPosition () 
         if isCursorShowing() then else  mx,my = x,y end 
          local fullx,fully = guiGetScreenSize() 
          cursorx,cursory = mx*fullx,my*fully 
         if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then 
          return true 
         else 
         return false 
        end 
    end 
  
function repararlo ( ) 
   if isCursorOnElement ( 440, 297, 146, 32) then 
     triggerServerEvent ( "onReparar", getLocalPlayer() ) 
     removeEventHandler ( "onClientRender", root, panelsito ) 
     showCursor (false) 
    elseif isCursorOnElement ( 440, 348, 146, 32 ) then 
     local state = ( not guiGetVisible ( InflarPanel ) ) 
     guiSetVisible ( InflarPanel, state ) 
      showCursor (false) 
     removeEventHandler ( "onClientRender", root, panelsito ) 
  end 
end 
addEventHandler ( "onClientClick", getRootElement(), repararlo) 
  

Link to comment

Modifique unas cuantas cosas que estaban mal pero ya lo probé y funciona

avísame si tienes alguna duda

function abririnflar () 
  
        InflarPanel = guiCreateWindow(715, 280, 201, 219, "Inflar ruedas", false) 
        guiWindowSetSizable(InflarPanel, false) 
        guiSetAlpha(InflarPanel, 0.68) 
  
        DIzquierda = guiCreateButton(9, 34, 71, 39, "Delantera Izquierda", false, InflarPanel) 
        guiSetFont(DIzquierda, "default-bold-small") 
        DDerecha = guiCreateButton(120, 34, 71, 39, "Delantera Derecha", false, InflarPanel) 
        guiSetFont(DDerecha, "default-bold-small") 
        TIzquierda = guiCreateButton(9, 116, 71, 39, "Trasera Izquierda", false, InflarPanel) 
        guiSetFont(TIzquierda, "default-bold-small") 
        TDerecha = guiCreateButton(120, 116, 71, 39, "Trasera Derecha", false, InflarPanel) 
        guiSetFont(TDerecha, "default-bold-small") 
        CerrarPanel = guiCreateButton(48, 178, 99, 31, "Cerrar ", false, InflarPanel) 
        guiSetFont(CerrarPanel, "default-bold-small")     
        
        showCursor (true) 
        addEventHandler ("onClientGUIClick", getRootElement(), onguiClick) 
  
        
end 
addEvent( "openInflar", true ) 
addEventHandler( "opneInflar", localPlayer, abririnflar ) 
  
function onguiClick () 
  if source == CerrarPanel then  
     guiSetVisible (InflarPanel, false) 
     showCursor (false) 
  elseif source == DIzquierda then  
     triggerServerEvent ( "onInflar1", getLocalPlayer() ) 
  elseif source == DDerecha then  
     triggerServerEvent ( "onInflar2", getLocalPlayer() ) 
  elseif source == TIzquierda then  
     triggerServerEvent ( "onInflar3", getLocalPlayer() ) 
  elseif source == inflartderecha then  
     triggerServerEvent ( "onInflar4", getLocalPlayer() ) 
  end 
end 
  
  
  
function panelsito () 
        dxDrawRectangle(344, 266, 334, 316, tocolor(127, 127, 127, 50), false) 
        dxDrawRectangle(344, 179, 334, 87, tocolor(255, 255, 255, 40), false) 
        dxDrawText("Panel Mecánico", 415, 206, 607, 256, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, false, false, false) 
        dxDrawRectangle(344, 582, 334, 23, tocolor(255, 255, 255, 40), false) 
     dxDrawRectangle(441, 297, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawText("Reparar", 440, 297, 587, 330, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
        dxDrawText("Pintar", 440, 348, 587, 381, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
        dxDrawRectangle(441, 349, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawRectangle(441, 406, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawText("Ruedas", 441, 406, 588, 439, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
        dxDrawText("Inflar", 441, 466, 588, 499, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
        dxDrawRectangle(441, 467, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawRectangle(441, 526, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawText("Luces", 441, 525, 588, 558, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
  
     showCursor (true) 
end 
function openPanel() 
addEventHandler ( "onClientRender", root, panelsito ) 
end 
addCommandHandler ("panel", openPanel) 
  
function isCursorOnElement(x,y,w,h) 
    local mx,my = getCursorPosition () 
         if isCursorShowing() then else  mx,my = x,y end 
          local fullx,fully = guiGetScreenSize() 
          cursorx,cursory = mx*fullx,my*fully 
         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 state == "down" then 
   if isCursorOnElement ( 440, 297, 146, 32) then 
     triggerServerEvent ( "onReparar", getLocalPlayer() ) 
     removeEventHandler ( "onClientRender", root, panelsito ) 
    elseif isCursorOnElement ( 440, 348, 146, 32 ) then 
     abririnflar () 
     removeEventHandler ( "onClientRender", root, panelsito ) 
  end 
 end 
end 
addEventHandler ( "onClientClick", getRootElement(), repararlo) 
  
  

Link to comment

Justo ahora estoy desde el móvil porque acabo de salir, pero lo vi así por eso encima y lo veo todo bien, y si a ti te va, a mi también me tendría que ir jaja. En cualquier caso, algun problema con el triggerServer, pero no creo. Muchas gracias nuevamente jaja :)

Link to comment

Prueba con esto

 InflarPanel = guiCreateWindow(715, 280, 201, 219, "Inflar ruedas", false) 
        guiWindowSetSizable(InflarPanel, false) 
        guiSetAlpha(InflarPanel, 0.68) 
  
        DIzquierda = guiCreateButton(9, 34, 71, 39, "Delantera Izquierda", false, InflarPanel) 
        guiSetFont(DIzquierda, "default-bold-small") 
        DDerecha = guiCreateButton(120, 34, 71, 39, "Delantera Derecha", false, InflarPanel) 
        guiSetFont(DDerecha, "default-bold-small") 
        TIzquierda = guiCreateButton(9, 116, 71, 39, "Trasera Izquierda", false, InflarPanel) 
        guiSetFont(TIzquierda, "default-bold-small") 
        TDerecha = guiCreateButton(120, 116, 71, 39, "Trasera Derecha", false, InflarPanel) 
        guiSetFont(TDerecha, "default-bold-small") 
        CerrarPanel = guiCreateButton(48, 178, 99, 31, "Cerrar ", false, InflarPanel) 
        guiSetFont(CerrarPanel, "default-bold-small")     
        guiSetVisible (InflarPanel, false) 
  
        
  
function onguiClick () 
  if source == CerrarPanel then 
     guiSetVisible (InflarPanel, false) 
     showCursor (false) 
     removeEventHandler ("onClientGUIClick", getRootElement(), onguiClick) 
  elseif source == DIzquierda then 
     triggerServerEvent ( "onInflar1", getLocalPlayer() ) 
  elseif source == DDerecha then 
     triggerServerEvent ( "onInflar2", getLocalPlayer() ) 
  elseif source == TIzquierda then 
     triggerServerEvent ( "onInflar3", getLocalPlayer() ) 
  elseif source == inflartderecha then 
     triggerServerEvent ( "onInflar4", getLocalPlayer() ) 
  end 
end 
  
  
  
function panelsito () 
        dxDrawRectangle(344, 266, 334, 316, tocolor(127, 127, 127, 50), false) 
        dxDrawRectangle(344, 179, 334, 87, tocolor(255, 255, 255, 40), false) 
        dxDrawText("Panel Mecánico", 415, 206, 607, 256, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, false, false, false) 
        dxDrawRectangle(344, 582, 334, 23, tocolor(255, 255, 255, 40), false) 
     dxDrawRectangle(441, 297, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawText("Reparar", 440, 297, 587, 330, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
        dxDrawText("Pintar", 440, 348, 587, 381, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
        dxDrawRectangle(441, 349, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawRectangle(441, 406, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawText("Ruedas", 441, 406, 588, 439, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
        dxDrawText("Inflar", 441, 466, 588, 499, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
        dxDrawRectangle(441, 467, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawRectangle(441, 526, 146, 32, tocolor(255, 255, 255, 40), false) 
        dxDrawText("Luces", 441, 525, 588, 558, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "top", false, false, false, false, false) 
  
     showCursor (true) 
end 
function openPanel() 
addEventHandler ( "onClientRender", root, panelsito ) 
end 
addCommandHandler ("panel", openPanel) 
  
function isCursorOnElement(x,y,w,h) 
    local mx,my = getCursorPosition () 
         if isCursorShowing() then else  mx,my = x,y end 
          local fullx,fully = guiGetScreenSize() 
          cursorx,cursory = mx*fullx,my*fully 
         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 state == "down" then 
   if isCursorOnElement ( 440, 297, 146, 32) then 
     triggerServerEvent ( "onReparar", getLocalPlayer() ) 
     removeEventHandler ( "onClientRender", root, panelsito ) 
    elseif isCursorOnElement ( 440, 348, 146, 32 ) then 
        showCursor (true) 
        guiSetVisible (InflarPanel, true) 
        addEventHandler ("onClientGUIClick", getRootElement(), onguiClick) 
        removeEventHandler ( "onClientRender", root, panelsito ) 
  end 
 end 
end 
addEventHandler ( "onClientClick", getRootElement(), repararlo) 

Link to comment

Nada, sigue igual. No sé si me expliqué muy bien (es que estoy medio dormido jaja). Cuando abro el panel y hago click en... pues, yo que sé, en las luces por ejemplo, me abre una pequeña gui normal (hecha con la función window y todo eso, no con el dx). Todo bien pero, cuando le doy click en el medio con el ratón (sin estar el panel) empieza a hacerme las funciones del panel. Osea, es como si aun estuviese jaja.

Link to comment

Osea, al hacer ésto, por ejemplo.

  
    elseif isCursorOnElement ( 440, 348, 146, 32 ) then 
        showCursor (true) 
        guiSetVisible (InflarPanel, true) 
        addEventHandler ("onClientGUIClick", getRootElement(), onguiClick) 
        removeEventHandler ( "onClientRender", root, panelsito ) 
  

Me abre el panel y todo bien, pero no me elimina lo que viene siendo la función del isCursorOnElement, es decir, si sigo clickeando, me sigue abriendo gui's que tienen asignada x posición. Es como si el dx estuviera invisible, pero sigue haciendo las funciones.

Link to comment

ah xD

tienes que añadirle esto

removeEventHandler ( "onClientClick", getRootElement(), repararlo) 

te tiene que quedar algo así

function openPanel() 
addEventHandler ( "onClientRender", root, panelsito ) 
addEventHandler ( "onClientClick", getRootElement(), repararlo) 
end 
addCommandHandler ("panel", openPanel) 
  
function isCursorOnElement(x,y,w,h) 
    local mx,my = getCursorPosition () 
         if isCursorShowing() then else  mx,my = x,y end 
          local fullx,fully = guiGetScreenSize() 
          cursorx,cursory = mx*fullx,my*fully 
         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 state == "down" then 
   if isCursorOnElement ( 440, 297, 146, 32) then 
     triggerServerEvent ( "onReparar", getLocalPlayer() ) 
     removeEventHandler ( "onClientRender", root, panelsito ) 
    elseif isCursorOnElement ( 440, 348, 146, 32 ) then 
        showCursor (true) 
        guiSetVisible (InflarPanel, true) 
        addEventHandler ("onClientGUIClick", getRootElement(), onguiClick) 
        removeEventHandler ( "onClientRender", root, panelsito ) 
        removeEventHandler ( "onClientClick", getRootElement(), repararlo) 
  end 
 end 
end 

Link to comment
  • Recently Browsing   0 members

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