Wei Posted March 27, 2012 Share Posted March 27, 2012 how can i make my gui open when i type in /admin command. Here is my code (unfinished) window1 = guiCreateWindow(268,214,530,216,"Blazy's Admin Panel! Use /admin to close!",false) button1 = guiCreateButton(10,27,164,82,"Flying cars ON",false,window1) guiSetFont(button1,"sa-header") button2 = guiCreateButton(356,118,159,86,"Admin Base",false,window1) guiSetFont(button2,"sa-header") button3 = guiCreateButton(184,118,164,82,"Hoover cars off",false,window1) guiSetFont(button3,"sa-header") button4 = guiCreateButton(12,117,164,82,"Flying cars off",false,window1) guiSetFont(button4,"sa-header") button5 = guiCreateButton(354,26,164,82,"Admin Godmode",false,window1) guiSetFont(button5,"sa-header") button6 = guiCreateButton(182,26,164,82,"Hoover Cars On",false,window1) guiSetFont(button6,"sa-header") function flyingcars(thePlayer) setWorldSpecialPropertyEnabled("aircars", true) end addEventHandler("onClientGUIClick", button1, flyingcars) function flyingcar(thePlayer) setWorldSpecialPropertyEnabled("aircars", false) end addEventHandler("onClientGUIClick", button2, flyingcar) Link to comment
MIKI785 Posted March 27, 2012 Share Posted March 27, 2012 try: addCommandHandler("/admin", function () guiSetVisible(window1, true) end) Link to comment
Castillo Posted March 27, 2012 Share Posted March 27, 2012 window1 = guiCreateWindow(268,214,530,216,"Blazy's Admin Panel! Use /admin to close!",false) guiSetVisible ( window1, false ) button1 = guiCreateButton(10,27,164,82,"Flying cars ON",false,window1) guiSetFont(button1,"sa-header") button2 = guiCreateButton(356,118,159,86,"Admin Base",false,window1) guiSetFont(button2,"sa-header") button3 = guiCreateButton(184,118,164,82,"Hoover cars off",false,window1) guiSetFont(button3,"sa-header") button4 = guiCreateButton(12,117,164,82,"Flying cars off",false,window1) guiSetFont(button4,"sa-header") button5 = guiCreateButton(354,26,164,82,"Admin Godmode",false,window1) guiSetFont(button5,"sa-header") button6 = guiCreateButton(182,26,164,82,"Hoover Cars On",false,window1) guiSetFont(button6,"sa-header") addCommandHandler ( "admin", function ( ) guiSetVisible ( window1, not guiGetVisible ( window1 ) ) showCursor ( guiGetVisible ( window1 ) ) end ) function flyingcars ( ) setWorldSpecialPropertyEnabled ( "aircars", true ) end addEventHandler ( "onClientGUIClick", button1, flyingcars ) function flyingcar ( ) setWorldSpecialPropertyEnabled ( "aircars", false ) end addEventHandler ( "onClientGUIClick", button2, flyingcar ) Link to comment
yMassai Posted March 27, 2012 Share Posted March 27, 2012 First add the ACL script allowing only the use ADM and after add the addCommandHandler in script Link to comment
Wei Posted March 27, 2012 Author Share Posted March 27, 2012 Thanks all. It's my first time making a GUI. So thanks again! Link to comment
Wei Posted March 27, 2012 Author Share Posted March 27, 2012 Just 1 help more. I didn't open new post. function Staffbaseport ( thePlayer ) setElementPosition((thePlayer), 110.53934, 1104.70752, 13.60938) end addEventHandler ( "onClientGUIClick", button2, Staffbaseport (thePlayer) ) whats the problem here ? Link to comment
Castillo Posted March 27, 2012 Share Posted March 27, 2012 function Staffbaseport ( ) setElementPosition( localPlayer, 110.53934, 1104.70752, 13.60938 ) end addEventHandler ( "onClientGUIClick", button2, Staffbaseport ) Link to comment
Wei Posted March 27, 2012 Author Share Posted March 27, 2012 function Staffbaseport ( ) setElementPosition( localPlayer, 110.53934, 1104.70752, 13.60938 ) end addEventHandler ( "onClientGUIClick", button2, Staffbaseport ) Thanks again ! Link to comment
Wei Posted March 28, 2012 Author Share Posted March 28, 2012 how can I bind that on F1 ? (this is not all of GUI) GUIEditor_Window = {} GUIEditor_Label = {} GUIEditor_Window[1] = guiCreateWindow(195,125,693,475,"SHG Help Manager",false) guiSetVisible ( GUIEditor_Window[1], false ) guiWindowSetSizable(GUIEditor_Window[1],false) GUIEditor_Label[35] = guiCreateLabel(394,318,254,47,"SHG GAMING",false,GUIEditor_Window[1]) guiSetFont(GUIEditor_Label[35],"sa-header") GUIEditor_Label[36] = guiCreateLabel(438,375,167,45,"SERVER",false,GUIEditor_Window[1]) guiSetFont(GUIEditor_Label[36],"sa-header") Link to comment
Vision Posted March 28, 2012 Share Posted March 28, 2012 GUIEditor_Window = {} GUIEditor_Label = {} GUIEditor_Window[1] = guiCreateWindow(195,125,693,475,"SHG Help Manager",false) guiSetVisible ( GUIEditor_Window[1], false ) guiWindowSetSizable(GUIEditor_Window[1],false) GUIEditor_Label[35] = guiCreateLabel(394,318,254,47,"SHG GAMING",false,GUIEditor_Window[1]) guiSetFont(GUIEditor_Label[35],"sa-header") GUIEditor_Label[36] = guiCreateLabel(438,375,167,45,"SERVER",false,GUIEditor_Window[1]) guiSetFont(GUIEditor_Label[36],"sa-header") function Window() if (guiGetVisible(GUIEditor_Window[1]) == true) then guiSetVisible(GUIEditor_Window[1], false) showCursor(false) else guiSetVisible(GUIEditor_Window[1], true) showCursor(true) end end bindKey("F1","down",Window) Link to comment
Wei Posted March 29, 2012 Author Share Posted March 29, 2012 Another Ploblem. If I press close it doesn't close. Code: bike_spawn_window = guiCreateWindow(376,202,232,329,"SHG Bike Spawner",false) guiWindowSetSizable(bike_spawn_window,false) guiSetVisible ( bike_spawn_window, false ) bmx_button = guiCreateButton(9,28,213,66,"BMX",false,bike_spawn_window) guiSetFont(bmx_button,"sa-header") close_button = guiCreateButton(18,248,203,66,"Close",false,bike_spawn_window) guiSetFont(close_button,"sa-header") mountain_bike_button = guiCreateButton(15,174,208,66,"Mountain bike",false,bike_spawn_window) guiSetFont(mountain_bike_button,"sa-header") bike_button = guiCreateButton(13,100,207,66,"Bike",false,bike_spawn_window) guiSetFont(bike_button,"sa-header") policemarker = createMarker ( 1538.97107, -1686.05786, 13.54688, "cylinder", 1, 255, 255, 255, 100 ) function Window() if (guiGetVisible(bike_spawn_window) == true) then guiSetVisible(bike_spawn_window, false) showCursor(false) else guiSetVisible(bike_spawn_window, true) showCursor(true) end end addEventHandler ( "onClientMarkerHit", policemarker, Window ) addEventHandler ( "onClientGuiClick", close_button, Window ) Link to comment
drk Posted March 29, 2012 Share Posted March 29, 2012 Obviously, you haven't handled any function to the button "close_button". Link to comment
Wei Posted March 29, 2012 Author Share Posted March 29, 2012 Obviously, you haven't handled any function to the button "close_button". How can I make it then ? I think it's the same so I added 1 handler more... Link to comment
Absence2 Posted March 29, 2012 Share Posted March 29, 2012 read this https://wiki.multitheftauto.com/wiki/OnClientGUIClick 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