Jump to content

Help me with window


Zinjaaa

Recommended Posts

Help I have a button and I want the function to close the window

--------------------------------------> http://tinypic.com/view.php?pic=t0kw9s&s=5 <--------------------------------------

I want this function

Example:

Press f1 (open panel), Press button ( X ) close panel

This is my client.lua

local isPlayerViewingPanel = false 
local sw,sh = guiGetScreenSize() 
  
function dxDrawTheImage ( ) 
    if isPlayerViewingPanel then 
        dxDrawImage ( 400, 120, 560, 480, "Ventana.png" ) 
        dxDrawImage ( 746.50, 144, 43.50, 43.50, "close.png" )       
    end 
end 
  
addEventHandler ( "onClientRender", root, dxDrawTheImage ) 
  
bindKey("f9", "down",function() 
    if ( isPlayerViewingPanel == true ) then           
        isPlayerViewingPanel = false 
        showCursor (false) 
    else               
        isPlayerViewingPanel = true 
        showCursor (true) 
end 

Link to comment

Sorry, I meant OnClientClick

Example:

addEventHandler("onClientClick",root,function(_,_,x,y) 
    if not isPlayerViewingPanel then return end --Checks if the panel's opening and if it is then stop the function 
    --Checks if the cursor is over the mouse from x to the width and y to the height 
    if ( x >= 746.50 and x <= 746.50 + 43.50) and ( y >= 144 and y <= 144 + 43.50 ) then 
        isPlayerViewingPanel = false 
    end 
end) 

Link to comment

hahha, You can make this in my client.lua, I do not understand much please help i'am very stupid .(

local isPlayerViewingPanel = false 
local sw,sh = guiGetScreenSize() 
  
function dxDrawTheImage ( ) 
    if isPlayerViewingPanel then 
        dxDrawImage ( 400, 120, 560, 480, "Ventana.png" ) 
        dxDrawImage ( 746.50, 144, 43.50, 43.50, "close.png" )      
    end 
end 
  
addEventHandler ( "onClientRender", root, dxDrawTheImage ) 
  
bindKey("f9", "down",function() 
    if ( isPlayerViewingPanel == true ) then           
        isPlayerViewingPanel = false 
        showCursor (false) 
    else               
        isPlayerViewingPanel = true 
        showCursor (true) 
end 

Link to comment

Try this:

local isPlayerViewingPanel = false 
local sw,sh = guiGetScreenSize() 
  
addEventHandler ( "onClientRender", root, function( ) 
    if isPlayerViewingPanel then 
        dxDrawImage ( 400, 120, 560, 480, "Ventana.png" ) 
        dxDrawImage ( 746.50, 144, 43.50, 43.50, "close.png" ) 
    end 
end ) 
  
bindKey("f9", "down",function() 
    if isPlayerViewingPanel then 
        isPlayerViewingPanel = false 
        showCursor (false) 
    else 
        isPlayerViewingPanel = true 
        showCursor (true) 
    end 
end) 
  
addEventHandler("onClientClick",root,function(_,_,x,y) 
    if not isPlayerViewingPanel then return end --Checks if the panel's opening and if it is then stop the function 
    --Checks if the cursor is over the mouse from x to the width and y to the height 
    if ( x >= 746.50 and x <= 746.50 + 43.50) and ( y >= 144 and y <= 144 + 43.50 ) then 
        isPlayerViewingPanel = false 
    end 
end) 

Link to comment

Thanks friend, but a detail, By pressing the button, the cursor does not disappear And I found the fault

local isPlayerViewingPanel = false 
local sw,sh = guiGetScreenSize() 
  
addEventHandler ( "onClientRender", root, function( ) 
    if isPlayerViewingPanel then 
        dxDrawImage ( 240, 145, 550, 480, "window.png" ) 
        dxDrawImage ( 746.50, 144, 43.50, 43.50, "close.png" ) 
    end 
end ) 
  
bindKey("f9", "down",function() 
    if isPlayerViewingPanel then 
        isPlayerViewingPanel = false 
        showCursor (false) 
    else 
        isPlayerViewingPanel = true 
        showCursor (true) 
    end 
end) 
  
addEventHandler("onClientClick",root,function(_,_,x,y) 
    if not isPlayerViewingPanel then return end --Checks if the panel's opening and if it is then stop the function 
    --Checks if the cursor is over the mouse from x to the width and y to the height 
    if ( x >= 746.50 and x <= 746.50 + 43.50) and ( y >= 144 and y <= 144 + 43.50 ) then 
        isPlayerViewingPanel = false 
        showCursor( false ) 
    end 
end) 

Edited by Guest
Link to comment
local isPlayerViewingPanel = false 
local sw, sh = guiGetScreenSize ( ) 
  
addEventHandler ( "onClientRender", root, 
    function( ) 
        if isPlayerViewingPanel then 
            dxDrawImage ( 400, 120, 560, 480, "Ventana.png" ) 
            dxDrawImage ( 746.50, 144, 43.50, 43.50, "close.png" ) 
        end 
    end 
) 
  
bindKey ( "f9", "down", 
    function ( ) 
        isPlayerViewingPanel = ( not isPlayerViewingPanel ) 
        showCursor ( isPlayerViewingPanel ) 
    end  
) 
  
addEventHandler ( "onClientClick", root, 
    function ( _, _, x, y ) 
        if ( not isPlayerViewingPanel ) then --Checks if the panel's opening and if it is then stop the function 
            return 
        end 
  
        --Checks if the cursor is over the mouse from x to the width and y to the height 
        if ( x >= 746.50 and x <= 746.50 + 43.50 ) and ( y >= 144 and y <= 144 + 43.50 ) then 
            isPlayerViewingPanel = false 
            showCursor ( false ) 
        end 
    end 
) 

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...