ViRuZGamiing Posted July 9, 2013 Posted July 9, 2013 Hello Community, I tried to make a GUI which is visible on the command /heal and dissapears on the command /heal too. CLIENT: function createHealWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 heal = guiCreateWindow(X, Y, Width, Height, "Heal yourself", true) guiSetVisible ( heal, 0 ) end function changeVisibility ( ) guiSetVisible (heal, not guiGetVisible ( heal ) ) end addCommandHandler("heal", changeVisibility) "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
Baseplate Posted July 9, 2013 Posted July 9, 2013 local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 heal = guiCreateWindow(X, Y, Width, Height, "Heal yourself", true) guiSetVisible ( heal, false ) function changeVisibility ( ) guiSetVisible (heal, not guiGetVisible ( heal ) ) showCursor (guiGetVisible(heal)) end addCommandHandler("heal", changeVisibility)
ViRuZGamiing Posted July 9, 2013 Author Posted July 9, 2013 (edited) Okay can you tell what I did wrong so I can learn something about my mistake +Why the f*ck you say Signature Thief too me! Everyone can take it There is no Copyright on it so it's no theft. ++ I've reported that Document too Google as Insulting and took a screenshot Edited July 9, 2013 by Guest "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
aim-killer Posted July 9, 2013 Posted July 9, 2013 in this guiSetVisible ( element guiElement, bool state ) it has guiElement and the state, you wrote 0 for state.. it must be true/false .. and you have created the gui in a function and that function is not being called, in this case it is not necessary to put in a function cuz its not visible
ViRuZGamiing Posted July 9, 2013 Author Posted July 9, 2013 in this guiSetVisible ( element guiElement, bool state ) it has guiElement and the state, you wrote 0 for state.. it must be true/false .. and you have created the gui in a function and that function is not being called, in this case it is not necessary to put in a function cuz its not visible Thank you very much for explaining that "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
ViRuZGamiing Posted July 15, 2013 Author Posted July 15, 2013 Okay another Question: I've added the last part (yes as text not code) but how can I attach the button to the right upper corner of the GUI? Like on a Windows Program the left upper red "X" to close the Program (GUI) The button (button) needs to be in the middle. 50% up-down 50% left-right local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 heal = guiCreateWindow(X, Y, Width, Height, "Heal yourself", true) button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Heal!", true ) guiSetVisible ( heal, false ) function changeVisibility ( ) guiSetVisible (heal, not guiGetVisible ( heal ) ) showCursor (guiGetVisible(heal)) end addCommandHandler("heal", changeVisibility) triggerServerEvent ( "onClientGUIClick", button, heal) --[[ Close Button Test x = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true ) function closeGui ( ) guiSetVisible (heal, not guiGetVisible ( heal ) ) showCursor (guiGetVisible(heal)) end addEventHandler ("onClientGUIClick",x,closeGui,false) --]] "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
iMr.3a[Z]eF Posted July 15, 2013 Posted July 15, 2013 there is an argument for the window parent, attach it with window or use GUIEditor easily x = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true, myWindpw ) To Visit Us Press Here: mtasa://5.9.206.180:22002
ViRuZGamiing Posted July 15, 2013 Author Posted July 15, 2013 Is this correct? local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 heal = guiCreateWindow(X, Y, Width, Height, "Heal yourself", true) button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Heal!", true, heal ) x = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "x", true, heal ) guiSetVisible ( heal, false ) function changeVisibility ( ) guiSetVisible (heal, not guiGetVisible ( heal ) ) showCursor (guiGetVisible(heal)) end addCommandHandler("heal", changeVisibility) triggerServerEvent ( "onClientGUIClick", button, heal) function closeGui ( ) guiSetVisible (heal, not guiGetVisible ( heal ) ) showCursor (guiGetVisible(heal)) end addEventHandler ("onClientGUIClick",x,closeGui,false) "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
Castillo Posted July 15, 2013 Posted July 15, 2013 Everything seems fine but this line: triggerServerEvent ( "onClientGUIClick", button, heal) which makes absolutely no sense. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
ViRuZGamiing Posted July 15, 2013 Author Posted July 15, 2013 Everything seems fine but this line: triggerServerEvent ( "onClientGUIClick", button, heal) which makes absolutely no sense. it does i have a server side "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
Castillo Posted July 15, 2013 Posted July 15, 2013 No, it doesn't, you are triggering that event just when script starts, using the button element as "theElement" and sending the window element, explain me how does it make sense. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Moderators IIYAMA Posted July 15, 2013 Moderators Posted July 15, 2013 for your question from skype. local sWidth,sHeight = guiGetScreenSize() local halveSWidth = sWidth / 2 local halveSHeight = sHeight / 2 -- your gui size and position. local guiSizeX,guiSizeY = sWidth *.25,sHeight *.25 local guiPosStartX = halveSWidth - (guiSizeX/2) local guiPosStartY = halveSHeight - (guiSizeY/2) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
ViRuZGamiing Posted July 15, 2013 Author Posted July 15, 2013 Okay sorry i'm a noob "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
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