Chris!i! Posted January 16, 2016 Share Posted January 16, 2016 Why when i press on the top of the panel where it says its name it close or when i press on the panel if there are no things like gridlists button ... it closes why?? its really annoying me first time i experience this problem please help what function should i use? Link to comment
Chris!i! Posted January 16, 2016 Author Share Posted January 16, 2016 (edited) font = guiCreateFont( "font.TTF", 14 ) marker1 = createMarker ( 759.08984375, -59.798828125, 999.7802124023, "cylinder", 1.5, 100, 0, 0, 255 ) marker2 = createMarker ( 773.375, 5.2412109375, 999.7802124023, "cylinder", 1.5, 100, 0, 0, 255 ) marker3 = createMarker ( 756.443359375, -48.0576171875, 999.7802124023, "cylinder", 1.5, 100, 0, 0, 255 ) blip1 = createBlip( 1968.8681640625, 2295.1806640625, 54, 54 ) blip2 = createBlip( -2270.4599609375, -155.95703125, 24, 54 ) blip3 = createBlip( 2229.6298828125, -1721.6298828125, 44, 54 ) setElementInterior(marker1, 7) setElementInterior(marker2, 5) setElementInterior(marker3, 6) GUIEditor = { gridlist = {}, window = {}, button = {}, memo = {}, scrollbar = {} } local screenW, screenH = guiGetScreenSize() GUIEditor.window[1] = guiCreateWindow((screenW - 678) / 2, (screenH - 695) / 2, 678, 695, "Set Your Walking Style", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.gridlist[1] = guiCreateGridList(9, 23, 659, 355, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[1], "Walking Styles", 0.9) for i = 1, 23 do guiGridListAddRow(GUIEditor.gridlist[1]) end guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "Armed", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "Blind Man", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 2, 1, "Busy Woman", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 3, 1, "Default", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 4, 1, "Drunk Man", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 5, 1, "Fat Man", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 6, 1, "Fat Woman", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 7, 1, "Gang 1", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 8, 1, "Gang 2", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 9, 1, "Jetpack", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 10, 1, "Jogger", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 11, 1, "Men", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 12, 1, "Old FatMan", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 13, 1, "Old FatWoman", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 14, 1, "Player", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 15, 1, "Player 2", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 16, 1, "Pro", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 17, 1, "SWAT", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 18, 1, "Sexy Woman", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 19, 1, "Shopping", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 20, 1, "Shuffle", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 21, 1, "Sneak", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 22, 1, "Woman", false, false) GUIEditor.memo[1] = guiCreateMemo(0, 389, 659, 200, "Walking style, choose one from the list and click accept, here you go you got it!\nThere's About 23 Walking Styles, choose one and ROCK!\nEnjoy!\nMade by Chris!i!", false, GUIEditor.window[1]) GUIEditor.button[1] = guiCreateButton(9, 599, 331, 86, "ACCEPT", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[1], font) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") GUIEditor.button[2] = guiCreateButton(342, 599, 326, 86, "CLOSE", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[2], font) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") guiMemoSetReadOnly ( GUIEditor.memo[1], true ) guiSetFont(GUIEditor.gridlist[1], font) function setGUIVisible () guiSetVisible (GUIEditor.window[1], not guiGetVisible ( GUIEditor.window[1] ) ) showCursor ( true ) end addEventHandler ( "onClientMarkerHit", marker1, setGUIVisible ) addEventHandler ( "onClientMarkerHit", marker2, setGUIVisible ) addEventHandler ( "onClientMarkerHit", marker3, setGUIVisible ) function closeGUI () guiSetVisible ( GUIEditor.window[1], false ) showCursor ( false ) end addEventHandler ( "onGUIClick", GUIEditor.button[2], closeGUI ) function dontAppearOnStart () guiSetVisible ( GUIEditor.window[1], false ) showCursor (false) end addEventHandler ( "onClientResourceStart", getRootElement(), dontAppearOnStart ) Wait is that good ? It got fixed at onClientGUIClick i set it to onGUIClick so thats right yea ? it worked for me but it does something wrong or all good ? Edited January 16, 2016 by Guest Link to comment
Mega9 Posted January 16, 2016 Share Posted January 16, 2016 You need to check the source before processing the handler. For GUI elements with parent, the onClientGUIClick will be triggered even if you click on the parent and not the child element. Explained with the code: guiwindow = guiCreateWindow (...) guielement-button = guiCreateButton(..., guiwindow) -- we set it's parent to the window 'guiwindow' function onGUIClick() -- check if button is the clicked element if source == guielement-button then -- do my stuff end end addEventHandler ("onClientGUIClick", guielement-button, onGUIClick) -- even though we have assigned the event handler to the button element, it will still be triggered if we click it's parent (the window) Link to comment
Chris!i! Posted January 16, 2016 Author Share Posted January 16, 2016 But now Close button doesnt work Link to comment
Chris!i! Posted January 16, 2016 Author Share Posted January 16, 2016 Now it works by adding if source == guielement-button then thanks Mega9 so much. Link to comment
Mega9 Posted January 16, 2016 Share Posted January 16, 2016 By checking if hitPlayer is the localPlayer like here: function setGUIVisible (hitPlayer, dimension) if hitPlayer == localPlayer and dimension then guiSetVisible (GUIEditor.window[1], not guiGetVisible ( GUIEditor.window[1] ) ) showCursor ( true ) end end addEventHandler ( "onClientMarkerHit", marker1, setGUIVisible ) 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