Mann56 Posted May 19, 2015 Share Posted May 19, 2015 Hey there i was making a PM System (it's still incomplete so the code may be broken somewhere) I had a problem that when i press f3 which is bindkey it spawns but when i again press bindkey instead of not showing another gui appears Please help: GUIEditor = { gridlist = {}, button = {}, edit = {} } function pmGUI() pmWindow = guiCreateWindow(498, 143, 353, 549, "", false) guiWindowSetSizable(pmWindow, false) gridThing = guiCreateGridList(12, 29, 331, 468, false, pmWindow) column = guiGridListAddColumn(gridThing, "Name", 0.9) editBox = guiCreateEdit(15, 510, 291, 29, "", false, pmWindow) closeButton = guiCreateButton(315, 509, 28, 30, "X", false, pmWindow) guiSetProperty(closeButton, "NormalTextColour", "FFAAAAAA") guiSetVisible(pmWindow,true) showCursor(true) end function showDxText() addEventHandler("onClientRender", root, function() dxDrawText("PM Box", 454, 69, 903, 134, tocolor(213, 216, 14, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) end ) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), function () for i,v in pairs(getElementsByType("player")) do row = guiGridListAddRow(gridThing) guiGridListSetItemText ( gridThing, row, column, getPlayerName ( v ), false, false ) end end ) bindKey("F3","up",pmGUI) bindKey("F3","up",showDxText) PS: Please do not complete the other code i want to do it myself Link to comment
novo Posted May 19, 2015 Share Posted May 19, 2015 Another gui is being created because you've done that everytime that F3's being pressed, pmGUI's executed and hence another window created. I recommend you setting a variable called state through which you will iterate in order to show and hide your desired guis. Either way, I would just do the following: (as you've requested us to not do any further improvements in your code, here's an example) -- Create the window as soon as the client-code is loaded local pmWindow = guiCreateWindow(498, 143, 353, 549, "", false) guiSetVisible(pmWindow, false) -- making it invisible showCursor(false) -- disabling cursor, though it should be already disabled so.. whatever local pmEnabled = false function dxText () if not pmEnabled then return end -- do not execute any further code within this function as long as 'pmEnabled' is false dxDrawText("PM Box", 454, 69, 903, 134, tocolor(213, 216, 14, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) end addEventHandler("onClientRender", root, dxText) function togglePM () pmEnabled = not pmEnabled -- example: pmEnabled is false, doing 'not false' will return true - so we then iterate this way between states guiSetVisible(pmWindow, pmEnabled) -- set our window visible or not, depending on the previously set state showCursor(pmEnabled) -- same as making the window visible, though with the cursor end bindKey("F3","up", togglePM) --bindKey("F3","up", showDxText) -- REMOVED Link to comment
Mann56 Posted May 19, 2015 Author Share Posted May 19, 2015 Thank you very much . They should have it as an optional argument in bindKey so that it can be turned off without any trouble 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