proracer Posted January 15, 2011 Share Posted January 15, 2011 Hello, I was creating a code so when player ticks the checkbox and presses the button he will agree with rules and if he does not ticks checkbox and immediately presses button it won't close window. The problem is that when I press checkbox and press the button it won't close the window.Don't bother reading the start. You can easily start reading from 25 to 40. Code: function drawRulesGUI() --- Using GUI Script Editor GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Checkbox = {} GUIEditor_Label = {} showCursor(true,true) GUIEditor_Window[1] = guiCreateWindow(493,126,850,620,"TripleX Clan Server Rules [MUST READ!]",false) guiWindowSetSizable(GUIEditor_Window[1],false) guiWindowSetMovable(GUIEditor_Window[1],false) GUIEditor_Memo[1] = guiCreateMemo(13,81,828,465,"1. Do not cheat or use any 3rd party mod.\n\n2. Do not swear and insult our players or admins.\n\n3. We do not allow spamming and flooding the chat.\n\n4. Please respect all players and admins.\n\n5. If you want to join our clan please post it on our site.\n\n6. If you have any suggestions about server/site or scripts\n\n post it on our site.\n\n\n [ Coming GUI based Suggestions tab.]\n\n\n Have fun!",false,GUIEditor_Window[1]) guiMemoSetReadOnly(GUIEditor_Memo[1], true) GUIEditor_Checkbox[1] = guiCreateCheckBox(224,548,39,20,"",false,false,GUIEditor_Window[1]) GUIEditor_Label[1] = guiCreateLabel(23,551,361,26,"I have read and I accept the rules.",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[1],255,255,255) guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) guiSetFont(GUIEditor_Label[1],"default-bold-small") GUIEditor_Button[1] = guiCreateButton(14,576,231,35,"I accept the rules.",false,GUIEditor_Window[1]) guiSetFont(GUIEditor_Button[1],"default-bold-small") addEventHandler ("onClientGUIClick", GUIEditor_Button[1], drawRulesGUI) -- This segment of code is if player does not select checkbox and presses the button function rulesCheckBoxAndButton(button, state) if guiCheckBoxGetSelected(GUIEditor_Checkbox[1]) == false and button == "left" and state == "up" then return end -- This segment of code is if playe selects checkbox and presses the button if guiCheckBoxGetSelected(GUIEditor_Checkbox[1]) == true and button == "left" and state == "up" then guiSetVisible(GUIEditor_Window[1], false) showCursor(false, false) outputChatBox("Thank you for accepting our rules.") end end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), drawRulesGUI) -- Direct X Drawing addEventHandler("onClientRender",root, function() dxDrawText("Player Rules",536.0,172.0,817.0,217.0,tocolor(255,0,0,255),0.8,"bankgothic","top","left",false,false,false) dxDrawLine(497.0,201.0,1341.0,201.0,tocolor(255,0,0,255),1.0,false) end ) Link to comment
Buffalo Posted January 15, 2011 Share Posted January 15, 2011 So, you made that if he clicked button, it would draw all windows again, when it should do a checkbox check function, like: addEventHandler ("onClientGUIClick", GUIEditor_Button[1], function (button, state) if button == "left" and state == "up" then if guiCheckBoxGetSelected(GUIEditor_Checkbox[1]) == false then --checkbox not selected return else -- checkbox selected guiSetVisible(GUIEditor_Window[1], false) showCursor(false, false) outputChatBox("Thank you for accepting our rules.") end end end,false) Link to comment
proracer Posted January 15, 2011 Author Share Posted January 15, 2011 It works thanks.Only you forgot 1 'end'.Btw because dx elements are not parent with gui window how can I remove the dx drawings when he presses accept rules? Link to comment
Buffalo Posted January 15, 2011 Share Posted January 15, 2011 (edited) Give a name to function which draws text and other stuff: -- Direct X Drawing function drawText() dxDrawText("Player Rules",536.0,172.0,817.0,217.0,tocolor(255,0,0,255),0.8,"bankgothic","top","left",false,false,false) dxDrawLine(497.0,201.0,1341.0,201.0,tocolor(255,0,0,255),1.0,false) end addEventHandler("onClientRender",root,drawText) Then remove text with removeEventHandler("onClientRender",root,drawText) Keep in mind that players using different resolution may not see text and lines drawn properly, you need a fix for that. Edited January 15, 2011 by Guest Link to comment
proracer Posted January 15, 2011 Author Share Posted January 15, 2011 Yes thanks.Figured it out myself ^^ Link to comment
proracer Posted January 15, 2011 Author Share Posted January 15, 2011 I edited the script a little but now it doesn't show. function drawRulesGUI() --- Using GUI Script Editor GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Checkbox = {} GUIEditor_Label = {} local sWidth,sHeight = 1920, 1080 showCursor(true,true) GUIEditor_Window[1] = guiCreateWindow( (sWidth-493)/sWidth, (sHeight-126)/sHeight, (sWidth-850)/sWidth, (sHeight-620)/sHeight, "TripleX Clan Server Rules [MUST READ!]",false) guiWindowSetSizable(GUIEditor_Window[1],false) guiWindowSetMovable(GUIEditor_Window[1],false) GUIEditor_Memo[1] = guiCreateMemo( (sWidth-13)/sWidth, (sHeight-81)/sHeight, (sWidth-828)/sWidth, (sHeight-465)/sHeight, "1. Do not cheat or use any 3rd party mod.\n\n2. Do not swear and insult our players or admins.\n\n3. We do not allow spamming and flooding the chat.\n\n4. Please respect all players and admins.\n\n5. If you want to join our clan please post it on our site.\n\n6. If you have any suggestions about server/site or scripts\n\n post it on our site.\n\n\n [ Coming GUI based Suggestions tab.]\n\n\n Have fun!",false,GUIEditor_Window[1]) guiMemoSetReadOnly(GUIEditor_Memo[1], true) GUIEditor_Checkbox[1] = guiCreateCheckBox( (sWidth-224)/sWidth, (sHeight-548)/sHeight, (sWidth-17)/sWidth, (sHeight-17)/sHeight, "",false,false,GUIEditor_Window[1]) GUIEditor_Label[1] = guiCreateLabel( (sWidth-23)/sWidth, (sHeight-551)/sHeight, (sWidth-361)/sWidth, (sHeight-26)/sHeight, "I have read and I accept the rules.",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[1],255,255,255) guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) guiSetFont(GUIEditor_Label[1],"default-bold-small") GUIEditor_Button[1] = guiCreateButton( (sWidth-14)/sWidth, (sHeight-576)/sHeight, (sWidth-231)/sWidth, (sHeight-35)/sHeight, "I accept the rules.",false,GUIEditor_Window[1]) guiSetFont(GUIEditor_Button[1],"default-bold-small") addEventHandler ("onClientGUIClick", GUIEditor_Button[1], function (button, state) if button == "left" and state == "up" then if guiCheckBoxGetSelected(GUIEditor_Checkbox[1]) == false then --checkbox not selected return else -- checkbox selected guiSetVisible(GUIEditor_Window[1], false) showCursor(false, false) outputChatBox("Thank you for accepting our rules.") end end end,false) end GUI doesn't show... no errors. Link to comment
SDK Posted January 15, 2011 Share Posted January 15, 2011 Where did you edit and where is the event handler for onClientResourceStart ? Please post the complete code again, I don't see anything wrong for what I can see now. Link to comment
proracer Posted January 15, 2011 Author Share Posted January 15, 2011 Yeah forgot the event handler lol. Now it shows but its in my top left corner and barelly see's.So something co-ords is wrong.I changed all positions of GUI elements to fit all monitor resolutions.(like you posted in my thread) But you see it doesn't work . Link to comment
SDK Posted January 15, 2011 Share Posted January 15, 2011 That method probably only worked for that part I saw, it's probably best to make it again and keep it relative from the start Link to comment
proracer Posted January 15, 2011 Author Share Posted January 15, 2011 Someone else helped me.Thanks guys anway. 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