downight Posted February 26, 2014 Share Posted February 26, 2014 I want to make a close button "X" but I can't search window_Close to see the button ---SCRIPT BY -RoCk-Alex---- ---copyright -RoCk- clan outputChatBox( "#FFFF00===[HELPMANAGER BY -RoCk-ALEX]===",0,255,0,true ) outputChatBox( "#00FF00===[PRESS F9 TO OPEN IT]===",0,255,0,true ) localPlayer = getLocalPlayer() wnd_window = {} local btnClose addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), function ( theResource ) --outputConsole( "wnd_showServerInfo called" ) --outputConsole( " source: ".. tostring( source ) ) --outputConsole( " resourceStarted: ".. tostring( theResource ) ) if source == getResourceRootElement( theResource ) then --outputConsole( " passed if: source == resource" ) local cmd = xmlLoadFile( "cmd.xml" ) local cmd1 = xmlNodeGetValue( cmd ) local member = xmlLoadFile( "member.xml" ) local member1 = xmlNodeGetValue( member ) local other = xmlLoadFile( "other.xml" ) local other1 = xmlNodeGetValue( other ) local server = xmlLoadFile( "server.xml" ) local server1 = xmlNodeGetValue( server ) wnd_create( cmd1, member1, other1, server1 ) end end ) function wnd_create( cmd, member, other, server ) GUIEditor_TabPanel = {} GUIEditor_Tab = {} GUIEditor_Memo = {} GUIEditor_Image = {} window = guiCreateWindow(305,119,1026,740,"Help",false) guiSetProperty(window, "CaptionColour", "FF80FF00") guiSetAlpha(window,1) guiWindowSetSizable(window,false) background = guiCreateStaticImage(0.0165,0.0200,0.9669,0.9191,"images/Black-Texture-Background-1280x800.png",true,window) guiSetAlpha(background,1) guiSetProperty(background,"Disabled","true") GUIEditor_Image[1] = guiCreateStaticImage(0.3100,0.0200,0.4000,0.4000,"images/title.png",true,window) guiSetAlpha(GUIEditor_Image[1],1) guiSetProperty(GUIEditor_Image[1],"Disabled","true") GUIEditor_TabPanel[1] = guiCreateTabPanel(0.0404,0.2457,0.921,0.6936,true,window) guiSetAlpha(GUIEditor_TabPanel[1],1) tabcmd = guiCreateTab("-RoCk-basemode Commands",GUIEditor_TabPanel[1]) guiSetAlpha(tabcmd,1) GUIEditor_Memo[1] = guiCreateMemo(0.008,0.0231,0.984,0.9583,cmd,true,tabcmd) guiSetAlpha(GUIEditor_Memo[1],1) GUIEditor_Tab[1] = guiCreateTab("-RoCk Members",GUIEditor_TabPanel[1]) guiSetAlpha(GUIEditor_Tab[1],1) GUIEditor_Memo[2] = guiCreateMemo(0.01,0.0324,0.98,0.9444,member,true,GUIEditor_Tab[1]) guiSetAlpha(GUIEditor_Memo[2],1) GUIEditor_Tab[2] = guiCreateTab("-RoCk- news",GUIEditor_TabPanel[1]) guiSetAlpha(GUIEditor_Tab[2],1) GUIEditor_Memo[3] = guiCreateMemo(0.008,0.0185,0.982,0.963,other,true,GUIEditor_Tab[2]) guiSetAlpha(GUIEditor_Memo[2],1) GUIEditor_Tab[2] = guiCreateTab("Server Info",GUIEditor_TabPanel[1]) guiSetAlpha(GUIEditor_Tab[2],1) GUIEditor_Memo[4] = guiCreateMemo(0.008,0.0185,0.982,0.963,server,true,GUIEditor_Tab[2]) guiSetAlpha(GUIEditor_Memo[4],1) guiMemoSetReadOnly(GUIEditor_Memo[1],true) guiMemoSetReadOnly(GUIEditor_Memo[2],true) guiMemoSetReadOnly(GUIEditor_Memo[3],true) guiMemoSetReadOnly(GUIEditor_Memo[4],true) window_Close = guiCreateButton(659,700,39,31,"X",false,window) guiSetFont(window_Close,"default-bold-small") guiSetProperty(window_Close, "NormalTextColour", "FF80FF00") end -- BIND THE TOUCH F9 function onresourceStart () bindKey ("F9", "down", showUserPanel) guiSetVisible (window, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onresourceStart) function showUserPanel () getVisible = guiGetVisible (window) playerName = getPlayerName ( getLocalPlayer() ) if (getVisible == true) then guiSetVisible (window, false) showCursor (false) playSound("open.wav") end if (getVisible == false) then guiSetVisible (window, true) showCursor (true) playSound("open.wav") end end Link to comment
cheez3d Posted February 26, 2014 Share Posted February 26, 2014 You must attach a function that will close the window to the event that is triggered when you click that button ("onClientGUIClick"). Link to comment
Jacobob14 Posted February 26, 2014 Share Posted February 26, 2014 function close() guiSetVisible(window, false) end addEventHandler("onClientGUIClick", window_Close, close) Link to comment
downight Posted February 26, 2014 Author Share Posted February 26, 2014 I've already added the same code as you guys said before but it still doesn't work because I think there is some conflict with function showUserPanel () Link to comment
cheez3d Posted February 26, 2014 Share Posted February 26, 2014 Try this. window_Close = guiCreateButton(659,700,39,31,"X",false,window) guiSetFont(window_Close,"default-bold-small") guiSetProperty(window_Close, "NormalTextColour", "FF80FF00") addEventHandler("onClientGUIClick",window_Close,function() guiSetVisible (window, false) showCursor (false) playSound("open.wav") end,false) function onresourceStart () guiSetVisible(window,false) bindKey ("F9", "down", showUserPanel) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onresourceStart) function showUserPanel () getVisible = guiGetVisible (window) if not getVisible then guiSetVisible (window, true) showCursor (true) playSound("open.wav") end end Link to comment
downight Posted February 26, 2014 Author Share Posted February 26, 2014 Now everything doesn't work Link to comment
cheez3d Posted February 26, 2014 Share Posted February 26, 2014 What errors do you receive? Link to comment
Jacobob14 Posted February 26, 2014 Share Posted February 26, 2014 ou must correct your gui tried it and have errors Link to comment
downight Posted February 26, 2014 Author Share Posted February 26, 2014 No errors. When I press F9 the guiwindow doesn't even show up with your code. With my code it shows up the guiwindow and the button. You can click on the button but doesnt do anything. Also tried Jacobob14's code - doesn't work since I tried the same thing before. Link to comment
DNL291 Posted February 26, 2014 Share Posted February 26, 2014 Try this: ---SCRIPT BY -RoCk-Alex---- ---copyright -RoCk- clan outputChatBox( "#FFFF00===[HELPMANAGER BY -RoCk-ALEX]===",0,255,0,true ) outputChatBox( "#00FF00===[PRESS F9 TO OPEN IT]===",0,255,0,true ) localPlayer = getLocalPlayer() wnd_window = {} local btnClose addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), function ( theResource ) --outputConsole( "wnd_showServerInfo called" ) --outputConsole( " source: ".. tostring( source ) ) --outputConsole( " resourceStarted: ".. tostring( theResource ) ) if source == getResourceRootElement( theResource ) then --outputConsole( " passed if: source == resource" ) local cmd = xmlLoadFile( "cmd.xml" ) local cmd1 = xmlNodeGetValue( cmd ) local member = xmlLoadFile( "member.xml" ) local member1 = xmlNodeGetValue( member ) local other = xmlLoadFile( "other.xml" ) local other1 = xmlNodeGetValue( other ) local server = xmlLoadFile( "server.xml" ) local server1 = xmlNodeGetValue( server ) wnd_create( cmd1, member1, other1, server1 ) end end ) function wnd_create( cmd, member, other, server ) GUIEditor_TabPanel = {} GUIEditor_Tab = {} GUIEditor_Memo = {} GUIEditor_Image = {} window = guiCreateWindow(305,119,1026,740,"Help",false) guiSetProperty(window, "CaptionColour", "FF80FF00") guiSetAlpha(window,1) guiWindowSetSizable(window,false) background = guiCreateStaticImage(0.0165,0.0200,0.9669,0.9191,"images/Black-Texture-Background-1280x800.png",true,window) guiSetAlpha(background,1) guiSetProperty(background,"Disabled","true") GUIEditor_Image[1] = guiCreateStaticImage(0.3100,0.0200,0.4000,0.4000,"images/title.png",true,window) guiSetAlpha(GUIEditor_Image[1],1) guiSetProperty(GUIEditor_Image[1],"Disabled","true") GUIEditor_TabPanel[1] = guiCreateTabPanel(0.0404,0.2457,0.921,0.6936,true,window) guiSetAlpha(GUIEditor_TabPanel[1],1) tabcmd = guiCreateTab("-RoCk-basemode Commands",GUIEditor_TabPanel[1]) guiSetAlpha(tabcmd,1) GUIEditor_Memo[1] = guiCreateMemo(0.008,0.0231,0.984,0.9583,cmd,true,tabcmd) guiSetAlpha(GUIEditor_Memo[1],1) GUIEditor_Tab[1] = guiCreateTab("-RoCk Members",GUIEditor_TabPanel[1]) guiSetAlpha(GUIEditor_Tab[1],1) GUIEditor_Memo[2] = guiCreateMemo(0.01,0.0324,0.98,0.9444,member,true,GUIEditor_Tab[1]) guiSetAlpha(GUIEditor_Memo[2],1) GUIEditor_Tab[2] = guiCreateTab("-RoCk- news",GUIEditor_TabPanel[1]) guiSetAlpha(GUIEditor_Tab[2],1) GUIEditor_Memo[3] = guiCreateMemo(0.008,0.0185,0.982,0.963,other,true,GUIEditor_Tab[2]) guiSetAlpha(GUIEditor_Memo[2],1) GUIEditor_Tab[2] = guiCreateTab("Server Info",GUIEditor_TabPanel[1]) guiSetAlpha(GUIEditor_Tab[2],1) GUIEditor_Memo[4] = guiCreateMemo(0.008,0.0185,0.982,0.963,server,true,GUIEditor_Tab[2]) guiSetAlpha(GUIEditor_Memo[4],1) guiMemoSetReadOnly(GUIEditor_Memo[1],true) guiMemoSetReadOnly(GUIEditor_Memo[2],true) guiMemoSetReadOnly(GUIEditor_Memo[3],true) guiMemoSetReadOnly(GUIEditor_Memo[4],true) window_Close = guiCreateButton(659,700,39,31,"X",false,window) guiSetFont(window_Close,"default-bold-small") guiSetProperty(window_Close, "NormalTextColour", "FF80FF00") addEventHandler( "onClientGUIClick", window_Close, function () guiSetVisible (window, false) showCursor (false) playSound("open.wav") end, false ) end -- BIND THE TOUCH F9 function onresourceStart () bindKey ("F9", "down", showUserPanel) guiSetVisible (window, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onresourceStart) function showUserPanel () getVisible = guiGetVisible (window) playerName = getPlayerName ( getLocalPlayer() ) if (getVisible == true) then guiSetVisible (window, false) showCursor (false) playSound("open.wav") end if (getVisible == false) then guiSetVisible (window, true) showCursor (true) playSound("open.wav") end end Link to comment
downight Posted February 26, 2014 Author Share Posted February 26, 2014 WHy I haven't thought of that lol. Works like a charm THANKS! 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