Vercetti1010 Posted March 13, 2008 Posted March 13, 2008 hey guys, i need a little help here, im trying to make a good car colors script for anyone to use. i got the functionality down, i just need to make a color chart for noobs to see so they know what car color they want. here is an example of my script. function colorChart ( theResource ) if theResource ~= getThisResource() then return end colorMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, "The Color IDs", true ) colorMenuCloseButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "Close", true, colorMenu ) guiWindowSetMovable ( colorMenu, false ) guiWindowSetSizable ( colorMenu, false ) guiCreateStaticImage ( 0.15, 0.33, 0.6, 0.33, colorchart.png, true, colorMenu ) end end function windowClose ( ) if ( colorMenu ) then destroyElement ( colorMenu ) end end addCommandHandler ( "colorids", colorChart ) addEventhandler ( "onClientGUIClick", colorMenuCloseButton, windowClose ) thats the client side script (not putting serverside, it works) <meta> <info author="masterOfPuppets" version="1.0" /> <script src="color.lua" type="server" /> <script src="colorgrid.lua" type="client" /> <file src="img/colorchart.png" /> </meta> thats the xml. can anyone help me get the ID chart to work?
50p Posted March 13, 2008 Posted March 13, 2008 What exacly do you want? Is your script not working as you want?
Vercetti1010 Posted March 13, 2008 Author Posted March 13, 2008 i want it to display a window which has the color chart in it and a close button
50p Posted March 14, 2008 Posted March 14, 2008 guiCreateStaticImage ( 0.15, 0.33, 0.6, 0.33, colorchart.png, true, colorMenu ) It must be a string. So use "colorchart.png" not colorchart.png
Vercetti1010 Posted March 14, 2008 Author Posted March 14, 2008 yeah, but the window does not show up at all. does that one bad thing sabotage the whole thing or something
Mr.Hankey Posted March 14, 2008 Posted March 14, 2008 I would try to remove the (theResource) argument, the if check if theResource is ~= getThisResource and the end before end of the function.
50p Posted March 14, 2008 Posted March 14, 2008 I would try to remove the (theResource) argument, the if check if theResource is ~= getThisResource and the end before end of the function. Yes, theResource arg will be always "player" it will not be resource because that's how addCommandHandler works. So the function will always stop (return) after the check. Also, why do you destroy the window when you click the button? Hide it instead (guiSetVisible).
Vercetti1010 Posted March 15, 2008 Author Posted March 15, 2008 (edited) ok, with commands i was able to close the window, but i need to make it so the button does it. It wont do it though. could someone help me out here? the button does nothing. function colorChart ( ) showCursor ( true ) colormenu = guiCreateWindow ( 0.15, 0.53, 0.7, 0.34, "The Color IDs", true ) closemenu = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "Close", true, colormenu ) guiWindowSetMovable ( colormenu, true ) guiWindowSetSizable ( colormenu, true ) guiCreateStaticImage ( 0.15, 0.33, 0.6, 0.33, "img/colorchart.png", true, colormenu ) end function windowClose ( ) destroyElement ( colormenu ) showCursor ( false ) end addCommandHandler ( "colorids", colorChart ) addEventHandler ( "onClientGUIClick", closemenu, windowClose ) Edited March 15, 2008 by Guest
50p Posted March 15, 2008 Posted March 15, 2008 Add some outputChatBox messages to closeWindow function and see if it's printed when you press the button.
50p Posted March 15, 2008 Posted March 15, 2008 Try this one: function colorChart ( ) showCursor ( true ) colormenu = guiCreateWindow ( 0.15, 0.53, 0.7, 0.34, "The Color IDs", true ) closemenu = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "Close", true, colormenu ) addEventHandler ( "onClientGUIClick", closemenu, windowClose ) guiWindowSetMovable ( colormenu, true ) guiWindowSetSizable ( colormenu, true ) guiCreateStaticImage ( 0.15, 0.33, 0.6, 0.33, "img/colorchart.png", true, colormenu ) end function windowClose ( ) if source == closemenu then destroyElement ( colormenu ) removeEventHandler( "onClientGUIClick", closemenu, windowClose ) showCursor ( false ) end end
Vercetti1010 Posted March 15, 2008 Author Posted March 15, 2008 wow, this worked. thank you so much 50p. you are very skilled at this.
eAi Posted March 15, 2008 Posted March 15, 2008 Try this one: function colorChart ( ) showCursor ( true ) colormenu = guiCreateWindow ( 0.15, 0.53, 0.7, 0.34, "The Color IDs", true ) closemenu = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "Close", true, colormenu ) addEventHandler ( "onClientGUIClick", closemenu, windowClose ) guiWindowSetMovable ( colormenu, true ) guiWindowSetSizable ( colormenu, true ) guiCreateStaticImage ( 0.15, 0.33, 0.6, 0.33, "img/colorchart.png", true, colormenu ) end function windowClose ( ) if source == closemenu then destroyElement ( colormenu ) removeEventHandler( "onClientGUIClick", closemenu, windowClose ) showCursor ( false ) end end Instead of having to do the 'if source==closemenu' line, you can just set the last boolean of addEventHandler to false (i.e. getPropagated).
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