Jump to content

[Ayuda] Activar Gui por medio de marker


DanielZ3RO

Recommended Posts

Hola, estaba haciendo un panel de armas para que cuando un usuario entre a un marker se abra el panel y pueda seleccionar las armas pero aparecen los objetos pero cuando el usuario pasa por el marker no se activa ninguna ventana gui

-------Objetos------ 
  
createObject ( 1570, 220.8, 1922, 18, 0, 0, 0 ) 
createPed ( 179, 220.5, 1922.7, 17.8, 180.0 ) 
tienda = createMarker ( 220.3, 1920.3, 16.6, "cylinder", 1.5, 255, 0, 0, 255 ) 
  
  
-------Panel De Armas-------- 
  
    function panel() 
        ventana = guiCreateWindow(95, 108, 654, 397, "Panel De Armas", false) 
        guiWindowSetSizable(ventana, false) 
        guiSetAlpha(ventana, 0.70) 
        boton1 = guiCreateButton(45, 49, 115, 93, "", false, ventana) 
        img1 = guiCreateStaticImage(-82, 10, 194, 148, ":guieditor/images/examples/1.png", false, boton1) 
        boton2 = guiCreateButton(207, 49, 115, 93, "", false, ventana) 
        img2 = guiCreateStaticImage(-41, 10, 147, 121, ":guieditor/images/examples/2.png", false, boton2) 
        boton3 = guiCreateButton(365, 49, 115, 93, "", false, ventana) 
        img3 = guiCreateStaticImage(-90, 10, 196, 158, ":guieditor/images/examples/3.png", false, boton3) 
        boton4 = guiCreateButton(45, 156, 115, 93, "", false, ventana) 
        img4 = guiCreateStaticImage(-23, 36, 147, 84, ":guieditor/images/examples/4.png", false, boton4) 
        boton5 = guiCreateButton(207, 156, 115, 93, "", false, ventana) 
        img5 = guiCreateStaticImage(-19, 29, 135, 106, ":guieditor/images/examples/5.png", false, boton5) 
        boton6 = guiCreateButton(365, 156, 115, 93, "", false, ventana) 
        img6 = guiCreateStaticImage(-20, 27, 136, 83, ":guieditor/images/examples/6.png", false, boton6) 
        boton7 = guiCreateButton(45, 263, 115, 93, "", false, ventana) 
        img7 = guiCreateStaticImage(-101, 4, 211, 111, ":guieditor/images/examples/7.png", false, boton7) 
        boton8 = guiCreateButton(207, 263, 115, 93, "", false, ventana) 
        img8 = guiCreateStaticImage(-7, 29, 122, 64, ":guieditor/images/examples/10.png", false, boton8) 
        boton9 = guiCreateButton(365, 263, 115, 93, "", false, ventana) 
        img9 = guiCreateStaticImage(-14, 28, 130, 72, ":guieditor/images/examples/13.png", false, boton9) 
        cerrar = guiCreateButton(516, 156, 128, 93, "Cerrar", false, ventana) 
         
         addEventHandler ( "onClientGUIClick", cerrar, Exit, false ) 
         addEventHandler ( "onClientGUIClick", boton1, arma1, false ) 
         addEventHandler ( "onClientGUIClick", boton2, arma2, false ) 
         addEventHandler ( "onClientGUIClick", boton3, arma3, false ) 
         addEventHandler ( "onClientGUIClick", boton4, arma4, false ) 
         addEventHandler ( "onClientGUIClick", boton5, arma5, false ) 
         addEventHandler ( "onClientGUIClick", boton6, arma6, false ) 
         addEventHandler ( "onClientGUIClick", boton7, arma7, false ) 
         addEventHandler ( "onClientGUIClick", boton8, arma8, false ) 
         addEventHandler ( "onClientGUIClick", boton9, arma9, false ) 
          
         addEventHandler("onClientRender", root, 
    function() 
        dxDrawLine(600, 154, 600, 476, tocolor(255, 255, 255, 255), 1, true, ventana) 
    end 
)                
            
         showCursor ( true ) 
          
    end 
addEventHandler ( "onMarkerHit", tienda, MarkerHit) 
  
------Funciones------ 
  
function MarkerHit(hitElement) 
guiSetVisible (ventana, guiGetVisible, ( ventana ) ) 
end 
  
function Exit() 
guiSetVisible (ventana, not guiGetVisible, ( ventana ) ) 
showCursor ( false ) 
end 

y otra duda es de como hacer para que se vean imagenes en lo que es el gui, cuando activo el resource no se ven las imagenes, creo que es poniendo las imagenes en una carpeta y en el xml poniendolas como client. de antemano gracias por aclararme la duda

Link to comment
  • MTA Team

Usa esto:

-------Objetos------ 
  
createObject ( 1570, 220.8, 1922, 18, 0, 0, 0 ) 
createPed ( 179, 220.5, 1922.7, 17.8, 180.0 ) 
tienda = createMarker ( 220.3, 1920.3, 16.6, "cylinder", 1.5, 255, 0, 0, 255 ) 
abierto = false 
  
  
-------Panel De Armas-------- 
  
    function panel() 
        ventana = guiCreateWindow(95, 108, 654, 397, "Panel De Armas", false) 
        guiWindowSetSizable(ventana, false) 
        guiSetAlpha(ventana, 0.70) 
        boton1 = guiCreateButton(45, 49, 115, 93, "", false, ventana) 
        img1 = guiCreateStaticImage(-82, 10, 194, 148, ":guieditor/images/examples/1.png", false, boton1) 
        boton2 = guiCreateButton(207, 49, 115, 93, "", false, ventana) 
        img2 = guiCreateStaticImage(-41, 10, 147, 121, ":guieditor/images/examples/2.png", false, boton2) 
        boton3 = guiCreateButton(365, 49, 115, 93, "", false, ventana) 
        img3 = guiCreateStaticImage(-90, 10, 196, 158, ":guieditor/images/examples/3.png", false, boton3) 
        boton4 = guiCreateButton(45, 156, 115, 93, "", false, ventana) 
        img4 = guiCreateStaticImage(-23, 36, 147, 84, ":guieditor/images/examples/4.png", false, boton4) 
        boton5 = guiCreateButton(207, 156, 115, 93, "", false, ventana) 
        img5 = guiCreateStaticImage(-19, 29, 135, 106, ":guieditor/images/examples/5.png", false, boton5) 
        boton6 = guiCreateButton(365, 156, 115, 93, "", false, ventana) 
        img6 = guiCreateStaticImage(-20, 27, 136, 83, ":guieditor/images/examples/6.png", false, boton6) 
        boton7 = guiCreateButton(45, 263, 115, 93, "", false, ventana) 
        img7 = guiCreateStaticImage(-101, 4, 211, 111, ":guieditor/images/examples/7.png", false, boton7) 
        boton8 = guiCreateButton(207, 263, 115, 93, "", false, ventana) 
        img8 = guiCreateStaticImage(-7, 29, 122, 64, ":guieditor/images/examples/10.png", false, boton8) 
        boton9 = guiCreateButton(365, 263, 115, 93, "", false, ventana) 
        img9 = guiCreateStaticImage(-14, 28, 130, 72, ":guieditor/images/examples/13.png", false, boton9) 
        cerrar = guiCreateButton(516, 156, 128, 93, "Cerrar", false, ventana) 
        
         addEventHandler ( "onClientGUIClick", cerrar, Exit ) 
         addEventHandler ( "onClientGUIClick", boton1, arma1 ) 
         addEventHandler ( "onClientGUIClick", boton2, arma2 ) 
         addEventHandler ( "onClientGUIClick", boton3, arma3) 
         addEventHandler ( "onClientGUIClick", boton4, arma4) 
         addEventHandler ( "onClientGUIClick", boton5, arma5) 
         addEventHandler ( "onClientGUIClick", boton6, arma6 ) 
         addEventHandler ( "onClientGUIClick", boton7, arma7 ) 
         addEventHandler ( "onClientGUIClick", boton8, arma8 ) 
         addEventHandler ( "onClientGUIClick", boton9, arma9 ) 
          
         addEventHandler("onClientRender", root, 
    function() 
        dxDrawLine(600, 154, 600, 476, tocolor(255, 255, 255, 255), 1, true, ventana) 
    end 
)               
  
  
  
------Funciones------ 
  
function MarkerHit() 
guiSetVisible (ventana, true) 
showCursor ( true ) 
abierto = true 
end 
  
function Exit() 
guiSetVisible (ventana, false ) 
showCursor ( false ) 
abierto = false 
end 
addEventHandler ( "onClientMarkerHit", tienda, MarkerHit) 
addEventHandler ( "onClientMarkerLeave", tienda, Exit) 

Sobre las imagenes, en tu caso, asegurate de tener el resource guieditor en funcionamiento ya que estas llamando a imagenes en otro resource. Puedes evitar activar guieditor, copiando esas imagenes al directorio de tu resource, agregandolas al meta con el formato y cambiando todas las rutas de las imagenes, a las nuevas copias de imagenes.

Y esto no se que has querido hacer:(Imagino que tienes funciones como arma1,arma2 etc..)

         addEventHandler ( "onClientGUIClick", cerrar, Exit, false ) 
         addEventHandler ( "onClientGUIClick", boton1, arma1, false ) 
         addEventHandler ( "onClientGUIClick", boton2, arma2, false ) 
         addEventHandler ( "onClientGUIClick", boton3, arma3, false ) 
         addEventHandler ( "onClientGUIClick", boton4, arma4, false ) 
         addEventHandler ( "onClientGUIClick", boton5, arma5, false ) 
         addEventHandler ( "onClientGUIClick", boton6, arma6, false ) 
         addEventHandler ( "onClientGUIClick", boton7, arma7, false ) 
         addEventHandler ( "onClientGUIClick", boton8, arma8, false ) 
         addEventHandler ( "onClientGUIClick", boton9, arma9, false ) 
          

PD:Cuando trabajas con gran cantidad de cosas, mi recomendación es la utilización de tablas.

Edited by Guest
Link to comment
Y esto no se que has querido hacer:(Imagino que tienes funciones como arma1,arma2 etc..)
         addEventHandler ( "onClientGUIClick", cerrar, Exit, false ) 
         addEventHandler ( "onClientGUIClick", boton1, arma1, false ) 
         addEventHandler ( "onClientGUIClick", boton2, arma2, false ) 
         addEventHandler ( "onClientGUIClick", boton3, arma3, false ) 
         addEventHandler ( "onClientGUIClick", boton4, arma4, false ) 
         addEventHandler ( "onClientGUIClick", boton5, arma5, false ) 
         addEventHandler ( "onClientGUIClick", boton6, arma6, false ) 
         addEventHandler ( "onClientGUIClick", boton7, arma7, false ) 
         addEventHandler ( "onClientGUIClick", boton8, arma8, false ) 
         addEventHandler ( "onClientGUIClick", boton9, arma9, false ) 
          

PD:Cuando trabajas con gran cantidad de cosas, mi recomendación es la utilización de tablas.

Si ahy van las armas pero me toca mirar como con que tipo de comando hago para que le de las armas al usuario

Link to comment

ya lo hice servir gracias

---------Objetos------------- 
  
createObject ( 1570, 220.8, 1922, 18, 0, 0, 0 ) 
createPed ( 179, 220.5, 1922.7, 17.8, 180.0 ) 
tienda = createMarker ( 220.3, 1920.3, 16.6, "cylinder", 1.5, 255, 0, 0, 255 ) 
-------Panel De Armas-------- 
  
addEventHandler ( "onClientMarkerHit", tienda,function(jugador) 
    if jugador == getLocalPlayer() then 
  
        ventana = guiCreateWindow(95, 108, 654, 397, "Panel De Armas", false) 
        guiWindowSetSizable(ventana, false) 
        guiSetAlpha(ventana, 0.70) 
        boton1 = guiCreateButton(45, 49, 115, 93, "", false, ventana) 
        img1 = guiCreateStaticImage(-82, 10, 194, 148, ":guieditor/images/examples/1.png", false, boton1) 
        boton2 = guiCreateButton(207, 49, 115, 93, "", false, ventana) 
        img2 = guiCreateStaticImage(-41, 10, 147, 121, ":guieditor/images/examples/2.png", false, boton2) 
        boton3 = guiCreateButton(365, 49, 115, 93, "", false, ventana) 
        img3 = guiCreateStaticImage(-90, 10, 196, 158, ":guieditor/images/examples/3.png", false, boton3) 
        boton4 = guiCreateButton(45, 156, 115, 93, "", false, ventana) 
        img4 = guiCreateStaticImage(-23, 36, 147, 84, ":guieditor/images/examples/4.png", false, boton4) 
        boton5 = guiCreateButton(207, 156, 115, 93, "", false, ventana) 
        img5 = guiCreateStaticImage(-19, 29, 135, 106, ":guieditor/images/examples/5.png", false, boton5) 
        boton6 = guiCreateButton(365, 156, 115, 93, "", false, ventana) 
        img6 = guiCreateStaticImage(-20, 27, 136, 83, ":guieditor/images/examples/6.png", false, boton6) 
        boton7 = guiCreateButton(45, 263, 115, 93, "", false, ventana) 
        img7 = guiCreateStaticImage(-101, 4, 211, 111, ":guieditor/images/examples/7.png", false, boton7) 
        boton8 = guiCreateButton(207, 263, 115, 93, "", false, ventana) 
        img8 = guiCreateStaticImage(-7, 29, 122, 64, ":guieditor/images/examples/10.png", false, boton8) 
        boton9 = guiCreateButton(365, 263, 115, 93, "", false, ventana) 
        img9 = guiCreateStaticImage(-14, 28, 130, 72, ":guieditor/images/examples/13.png", false, boton9) 
        cerrar = guiCreateButton(516, 156, 128, 93, "Cerrar", false, ventana) 
         
        addEventHandler ( "onClientGUIClick", cerrar, Exit, false ) 
        addEventHandler ( "onClientGUIClick", boton1, arma1, false ) 
        addEventHandler ( "onClientGUIClick", boton2, arma2, false ) 
        addEventHandler ( "onClientGUIClick", boton3, arma3, false ) 
        addEventHandler ( "onClientGUIClick", boton4, arma4, false ) 
        addEventHandler ( "onClientGUIClick", boton5, arma5, false ) 
        addEventHandler ( "onClientGUIClick", boton6, arma6, false ) 
        addEventHandler ( "onClientGUIClick", boton7, arma7, false ) 
        addEventHandler ( "onClientGUIClick", boton8, arma8, false ) 
        addEventHandler ( "onClientGUIClick", boton9, arma9, false ) 
  
        addEventHandler("onClientRender", root,linea) 
             
                 
        showCursor (true)  
    end 
end)  
function linea() 
dxDrawLine(600, 154, 600, 476, tocolor(255, 255, 255, 255), 1, true, ventana) 
end 
------Funciones------ 
function Exit() 
destroyElement(ventana) 
showCursor(false) 
removeEventHandler("onClientRender",root,linea) 
end 

Link to comment

ya pude abrir el gui con los botones y las imagenes pero ahora no se como dar el arma al usuario tengo esto

llevo esto

75p2.png

pso3.png

clientside

function arma1() 
    triggerServerEvent ( "onArmas1", localPlayer )  
end 

serverside

function a1() 
Jugador = getLocalPlayer() 
giveWeapon ( "Jugador", 346, 5000, setAsCurrent=false ) 
end 
addEvent( "onArmas1", true ) 
addEventHandler( "onArmas1", getRootElement(), a1 ) 

Link to comment
  • MTA Team
function arma1() 
    triggerServerEvent ( "onArmas1", localPlayer,localPlayer ) 
end 

function a1(jugador) 
giveWeapon ( jugador, 346, 5000,false ) 
end 
addEvent( "onArmas1", true ) 
addEventHandler( "onArmas1", getRootElement(), a1 ) 

Tambien podes ahorrarte el pasaje de variables usando "client" de esta manera:

function arma1() 
    triggerServerEvent ( "onArmas1", localPlayer ) 
end 

function a1() 
giveWeapon ( client, 346, 5000,false ) 
end 
addEvent( "onArmas1", true ) 
addEventHandler( "onArmas1", getRootElement(), a1 ) 

Link to comment
function arma1() 
    triggerServerEvent ( "onArmas1", localPlayer,localPlayer ) 
end 

function a1(jugador) 
giveWeapon ( jugador, 346, 5000,false ) 
end 
addEvent( "onArmas1", true ) 
addEventHandler( "onArmas1", getRootElement(), a1 ) 

Tambien podes ahorrarte el pasaje de variables usando "client" de esta manera:

function arma1() 
    triggerServerEvent ( "onArmas1", localPlayer ) 
end 

function a1() 
giveWeapon ( client, 346, 5000,false ) 
end 
addEvent( "onArmas1", true ) 
addEventHandler( "onArmas1", getRootElement(), a1 ) 

También en vez de client más 'ortodoxo' sería source.

Link to comment
  • Recently Browsing   0 members

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