Jump to content

Trying to bind a key to a GUI


Recommended Posts

This is supposed to open an image when you press F10, but it's not showing anything and I get no error messages on the debug script, can someone check and see what's wrong on this?

function mymap () 
    local myWindow = guiCreateWindow ( 20, 200, 100, 100, "Mapa", true ) 
    local mapa = guiCreateStaticImage( 20, 200, 100, 100, "radar.png", false, myWindow ) 
    if ( guiGetVisible ( myWindow ) == true ) then           
        guiSetVisible ( myWindow, false ) 
    else               
        guiSetVisible ( myWindow, true ) 
    end 
end 
addCommandHandler( "abrirmapa", mymap ) 
bindKey( "F10", "down", mymap ) 

Link to comment

That's because you're hiding the GUI when it is created

function mymap () 
    local myWindow = guiCreateWindow ( 20, 200, 100, 100, "Mapa", true ) 
    local mapa = guiCreateStaticImage( 20, 200, 100, 100, "radar.png", false, myWindow ) 
end 
addCommandHandler( "abrirmapa", mymap ) 
bindKey( "F10", "down", mymap ) 

Link to comment
myWindow = guiCreateWindow ( 20, 200, 100, 100, "Mapa", true ) 
guiSetVisible(myWindow,false) 
guiCreateStaticImage( 20, 200, 100, 100, "radar.png", false, myWindow ) 
  
function mymap () 
guiSetVisible(myWindow,not guiGetVisible ( myWindow )) 
showCursor(not isCursorShowing()) 
end 
addCommandHandler( "abrirmapa", mymap ) 
bindKey( "F10", "down", mymap ) 

Link to comment

Sadly, none worked for me, I managed to build it this way:

myWindow = guiCreateWindow( 128, 0, 534, 600, "noneedtoknow", false ) 
guiWindowSetSizable( myWindow, false ) 
guiWindowSetMovable( myWindow, false ) 
guiSetVisible ( myWindow, false ) 
myImage = guiCreateStaticImage(9, 19, 515, 571, "radar.png", false, myWindow )   
  
function abriromapa () 
    if ( guiGetVisible ( myWindow ) == false ) then 
        guiSetVisible ( myWindow, true ) 
    else               
        guiSetVisible ( myWindow, false ) 
    end 
end 
addCommandHandler( "noneedtoknoweither", abriromapa ) 
bindKey( "F10", "down", abriromapa ) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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