Newbie Posted March 19, 2014 Share Posted March 19, 2014 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
cheez3d Posted March 19, 2014 Share Posted March 19, 2014 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
NeO_DUFFMAN Posted March 19, 2014 Share Posted March 19, 2014 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
Newbie Posted March 19, 2014 Author Share Posted March 19, 2014 Thanks. How to make that on all resoliutoins panel be at the canter ? Link to comment
Arnold-1 Posted March 19, 2014 Share Posted March 19, 2014 sx,sy = guiGetScreenSize() drawSomething((x/yourRes)*sx,(y/yourRes)*sy) Link to comment
cheez3d Posted March 20, 2014 Share Posted March 20, 2014 (edited) 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 March 20, 2014 by Guest Link to comment
Dzsozi (h03) Posted March 20, 2014 Share Posted March 20, 2014 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
iPrestege Posted March 20, 2014 Share Posted March 20, 2014 Editing and add the event and change some variables to do it. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now