Jump to content

Bind Key ?


Newbie

Recommended Posts

How can i make bind key to show/dontshow (F7) for:

addEventHandler("onClientRender", root, 
    function() 
        dxDrawRectangle(204, 234, 507, 300, tocolor(0, 0, 0, 155), true) 
        dxDrawRectangle(204, 205, 507, 29, tocolor(248, 6, 6, 143), true) 
        dxDrawText("USER PANEL", 203, 204, 711, 234, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, true, false, false) 
    end 
) 

Link to comment
  
local function render_handler() 
    dxDrawRectangle(204, 234, 507, 300, tocolor(0, 0, 0, 155), true) 
    dxDrawRectangle(204, 205, 507, 29, tocolor(248, 6, 6, 143), true) 
    dxDrawText("USER PANEL", 203, 204, 711, 234, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, true, false, false) 
end 
  
addEventHandler("onClientResourceStart",resourceRoot,function() 
    bindKey("F7","down",function() 
        addEventHandler("onClientRender",root,render_handler) 
    end) 
    bindKey("F7","up",function() 
        removeEventHandler("onClientRender",root,render_handler) 
    end) 
end) 
  

Link to comment
  
local data = {visibleState=false,toggleKey="F7"} 
  
local function handleRender() 
    dxDrawRectangle(204, 234, 507, 300, tocolor(0, 0, 0, 155), true) 
    dxDrawRectangle(204, 205, 507, 29, tocolor(248, 6, 6, 143), true) 
    dxDrawText("USER PANEL", 203, 204, 711, 234, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, true, false, false) 
end 
  
bindKey(data.toggleKey,"down", 
function() 
    if data.visibleState == false then 
        addEventHandler("onClientRender",root,handleRender) 
        data.visibleState = true 
    else 
        removeEventHandler("onClientRender",root,handleRender) 
        data.visibleState = false 
    end 
end) 

Damn it, i need to work on my typing skills lol.

Link to comment
  
local screen_width,screen_height = guiGetScreenSize() 
local visibility = false 
  
local function render_handler() 
    dxDrawRectangle((screen_width-507)/2,(screen_height-300)/2, 507, 300, tocolor(0, 0, 0, 155), true) 
    dxDrawRectangle((screen_width-507)/2, (screen_height-29)/2, 507, 29, tocolor(248, 6, 6, 143), true) 
    dxDrawText("USER PANEL",(screen_width-711)/2,(screen_height-234)/2, 711, 234, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, true, false, false) 
end 
  
addEventHandler("onClientResourceStart",resourceRoot,function() 
    bindKey("F7","down",function() 
        local handler = not visibility and addEventHandler or removeEventHandler 
        visibility = not visibility 
        handler("onClientRender",root,render_handler) 
    end) 
end) 
  

Edited by Guest
Link to comment
  
local data = {visibleState=false,toggleKey="F7"} 
  
local function handleRender() 
    dxDrawRectangle(204, 234, 507, 300, tocolor(0, 0, 0, 155), true) 
    dxDrawRectangle(204, 205, 507, 29, tocolor(248, 6, 6, 143), true) 
    dxDrawText("USER PANEL", 203, 204, 711, 234, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, true, false, false) 
end 
  
bindKey(data.toggleKey,"down", 
function() 
    if data.visibleState == false then 
        addEventHandler("onClientRender",root,handleRender) 
        data.visibleState = true 
    else 
        removeEventHandler("onClientRender",root,handleRender) 
        data.visibleState = false 
    end 
end) 

Damn it, i need to work on my typing skills lol.

This is helped me alot too! But I have a question. How to make something visible when the resource starts and then the can toggle it invisible and visible again. So the question is how to make it visible on resource start?

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