Darkwarrior Diesel Posted February 28, 2014 Share Posted February 28, 2014 hi again guys this time, i made a gui, and want it to appear when player press the f2 key and if window is already visible, the window disappears. but man, i think im doing it all wrong heres the code : -- makin a rules window, second type, with a f2 bind key --a simple rules window, with an accept button and a list of all the server rules and information -- however, instead of relative, we gonna use absolute position values !!! -- as noted in previous tutorials, all the gui must be made client side --makin the window --create the window that will hold our gui creation code local sWidth, sHeight = guiGetScreenSize() local Width,Height = 445,445 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) rulesWindow = guiCreateWindow(X,Y,Width,Height,"Rules",false) guiWindowSetMovable(rulesWindow,false) guiWindowSetSizable(rulesWindow,false) -- next we will add the label to the centre of our window that our rules will be displayed on -- we set the text of the label to our rules rulesLabel = guiCreateLabel(10,25,425,359,[[ Welcome to my mta server! Please carefully read the rules before accepting. By accepting the rules, you are agreeing to play by them. Anyone caught breakin these rules will be kicked and/or banned from this server. 1: No cheating. 2: No bug abuse. 3: No mods to your game. 4: No flaming. 5: Respect other players. 6: Be nice!]],false,rulesWindow) --set the horizontal alignment of your label to centre, : in the middle of the window -- also the final argument is true, which means, it will turn on wordwrap guiLabelSetHorizontalAlign(rulesLabel,"center",true) guiSetVisible(rulesWindow, false) function resourceStart () bindKey ("F2", "down", showHelp) end addEventHandler ("onClientResourceStart",getResourceRootElement(getThisResource()),resourceStart) function showHelp () visableOrNot = guiSetVisible (rulesWindow) if (visableOrNot == true) then guiSetVisible (rulesWindow, false) elseif (visableOrNot == false) then guiSetVisible (rulesWindow,true) end end Thnks for u help guys Link to comment
Castillo Posted February 28, 2014 Share Posted February 28, 2014 Any error in the debugscript? Link to comment
Wei Posted February 28, 2014 Share Posted February 28, 2014 local sWidth, sHeight = guiGetScreenSize() local Width,Height = 445,445 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) rulesWindow = guiCreateWindow(X,Y,Width,Height,"Rules",false) guiWindowSetMovable(rulesWindow,false) guiWindowSetSizable(rulesWindow,false) rulesLabel = guiCreateLabel(10,25,425,359,[[ Welcome to my mta server! Please carefully read the rules before accepting. By accepting the rules, you are agreeing to play by them. Anyone caught breakin these rules will be kicked and/or banned from this server. 1: No cheating. 2: No bug abuse. 3: No mods to your game. 4: No flaming. 5: Respect other players. 6: Be nice!]],false,rulesWindow) guiLabelSetHorizontalAlign(rulesLabel,"center",true) guiSetVisible(rulesWindow, false) function showHelp () if (guiGetVisible(rulesWindow)) then guiSetVisible(rulesWindow, false) else guiSetVisible(rulesWindow,true) end end bindKey ("F2", "down", showHelp) --// binding that on resource start is not needeed anyways this was the problem visableOrNot = guiSetVisible (rulesWindow) Link to comment
Castillo Posted February 28, 2014 Share Posted February 28, 2014 To make it shorter you can use: guiSetVisible ( rulesWindow, not guiGetVisible ( rulesWindow ) ) Link to comment
Darkwarrior Diesel Posted February 28, 2014 Author Share Posted February 28, 2014 Thnks Wei, it works and thnk u for tryin to help me solid thnks a lot guys 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