Saltar al contenido
  • Global

    Global

    Chatroom Rules

    • NO SE DA SOPORTE EN CHATBOX
    • NO SPAM
    • NO FLOOD

Publicaciones recomendadas

  • Usuario
Publicado
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

  • Ex-Staff
Publicado

Bueno, primero que todo "onMarkerHit" es un evento de tipo servidor y tu estás trabajando con cliente, el evento que necesitas es "onClientMarkerHit", y debes tener cuidado con este evento ya que si no utilizas getLocalPlayer() el gui aparecerá para todos los jugadores.

 

Aquí el código:

 

 

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
 
 

 

 

Tiene algunos ajustes para facilitar el código.

 

Ahora mira, el tema de las imagenes. Las que tienes importadas en el panel están desde el recurso "guieditor" para que esas imagenes te corran debes tener corriendo el guieditor y te correrá sin problemas, pero te aconsejo que las importes al recurso.

 

para agregarlo al meta xml debe ser así:

<file src="nombre.png"/>

y en el código no olvides olvidar cambiar la dirección de la imagen, por ejemplo:

img5 = guiCreateStaticImage(-19, 29, 135, 106, "5.png", false, boton5)

Espero que haberte ayudado, si no vuelve a preguntar y trataré de explicarme mejor, saludos :D

  • Usuario
Publicado

O____________________O Gracias Saxi me sirvio el script en serio muchas gracias por haberme ayudado, cuando lo termine lo pondre como aporte

  • Usuario
Publicado

Tengo otra preguntica, es para cuando el jugador presione el boton le de el arma, yo lo tengo de esta forma pero no se cual otra usar

function arma1()
Jugador = getLocalPlayer()
giveWeapon ( "Jugador", 346, 5000, setAsCurrent=false )
end
  • Ex-Staff
Publicado

No no, ahora lo que tienes que usar es triggerServerEvent

 

Buscalo en la wiki de MTA, te daré un ejemplo cuando me conecte al pc

  • Usuario
Publicado (editado)

No no, ahora lo que tienes que usar es triggerServerEvent

 

Buscalo en la wiki de MTA, te daré un ejemplo cuando me conecte al pc

seria algo asi

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

perdon por preguntar tanto, soy muy nuevo y entiendo muy poco :P

 

ahh y tambien queria saber en que momento se empiezan a usar las funciones de servidor

Editado por DanielZ3RO
  • Usuario
Publicado (editado)

mira saxi el script de server side lo hice asi con todos los botones

function a1()
Jugador = getLocalPlayer()
giveWeapon ( "Jugador", 346, 5000, setAsCurrent=false )
end
addEvent( "onArmas1", true )
addEventHandler( "onArmas1", getRootElement(), a1 )
Editado por DanielZ3RO
  • Usuario
Publicado (editado)

mira saxi esto es lo que llevo

 

75p2.png

pso3.png


asi lo tengo conectado el client con el server

 

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 )

Editado por DanielZ3RO
  • Ex-Staff
Publicado

Bien, pero en server-side no corre getLocalPlayer() ya que es una función del cliente, no servidor, ahora debes de usar el argumento source

giveWeapon(source, ID, Munición, setAsCurrent=false)

En tu código el ID del arma no existe, acá te dejo la lista de IDs de las armas: CLICK AQUI

  • Usuario
Publicado (editado)

Bien, pero en server-side no corre getLocalPlayer() ya que es una función del cliente, no servidor, ahora debes de usar el argumento source

giveWeapon(source, ID, Munición, setAsCurrent=false)

En tu código el ID del arma no existe, acá te dejo la lista de IDs de las armas: CLICK AQUI

es el id o el model id ? yo puse la de model id por que pense que era por ese tipo de id

Editado por DanielZ3RO
  • Usuario
Publicado (editado)

ahh y me salta un error en la consola dice client (yo) triggered server event onArmas1, but the event is not added server side

Editado por DanielZ3RO
  • Usuario
Publicado

Muéstrame el código

---------Client-------------

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

--------Server--------------

function a1()
    giveWeapon( source, 22, 5000, setAsCurrent=false )
end
addEvent( "onArmas1", true )
addEventHandler( "onArmas1", getRootElement(), a1 )
  • Usuario
Publicado

mira

cliente

 

 

---------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, ":Dz-tiendas/images/1.png", false, boton1)
        boton2 = guiCreateButton(207, 49, 115, 93, "", false, ventana)
        img2 = guiCreateStaticImage(-41, 10, 147, 121, ":Dz-tiendas/images/2.png", false, boton2)
        boton3 = guiCreateButton(365, 49, 115, 93, "", false, ventana)
        img3 = guiCreateStaticImage(-90, 10, 196, 158, ":Dz-tiendas/images/3.png", false, boton3)
        boton4 = guiCreateButton(45, 156, 115, 93, "", false, ventana)
        img4 = guiCreateStaticImage(-23, 36, 147, 84, ":Dz-tiendas/images/4.png", false, boton4)
        boton5 = guiCreateButton(207, 156, 115, 93, "", false, ventana)
        img5 = guiCreateStaticImage(-19, 29, 135, 106, ":Dz-tiendas/images/5.png", false, boton5)
        boton6 = guiCreateButton(365, 156, 115, 93, "", false, ventana)
        img6 = guiCreateStaticImage(-20, 27, 136, 83, ":Dz-tiendas/images/6.png", false, boton6)
        boton7 = guiCreateButton(45, 263, 115, 93, "", false, ventana)
        img7 = guiCreateStaticImage(-101, 4, 211, 111, ":Dz-tiendas/images/7.png", false, boton7)
        boton8 = guiCreateButton(207, 263, 115, 93, "", false, ventana)
        img8 = guiCreateStaticImage(-7, 29, 122, 64, ":Dz-tiendas/images/8.png", false, boton8)
        boton9 = guiCreateButton(365, 263, 115, 93, "", false, ventana)
        img9 = guiCreateStaticImage(-14, 28, 130, 72, ":Dz-tiendas/images/9.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
 
function arma1()
    triggerServerEvent ( "onArmas1", localPlayer )
end

server

 

 

function a1()
    giveWeapon( source, 22, 5000, setAsCurrent=false )
end
addEvent( "onArmas1", true )
addEventHandler( "onArmas1", getRootElement(), a1 )

  • Usuario
Publicado
giveWeapon(source,22,5000,false)

Gracias ya me sirvio, en serio muchas gracias, perdon por molestar mucho :c te pondre en el xml hahaha en serio gracias

voy a intentar terminar las otras 2 tiendas que me faltan espero no tener inconvenientes para no venir a molestar

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Invitado
Responder a este tema...

×   Pegar como texto enriquecido.   Pegar como texto sin formato

  Only 75 emoji are allowed.

×   Tu enlace se ha incrustado automáticamente..   Mostrar como un enlace en su lugar

×   Se ha restaurado el contenido anterior.   Limpiar editor

×   No se pueden pegar imágenes directamente. Carga o inserta imágenes desde la URL.

  • Explorando recientemente   0 miembros

    • No hay usuarios registrados viendo esta página.
×
×
  • Crear nuevo...