Jump to content

Help GUI Problem!


roleplay+

Recommended Posts

Well I made my code it all works here it is,

function quizMain() 
quizWindow = guiCreateWindow(207, 118, 406, 371, "", false) 
guiWindowSetSizable(quizWindow, false) 
  
quizOne = guiCreateLabel(27, 35, 210, 24, "1. What is Deathmatching in Roleplay?", false, quizWindow) 
quizOneAnswerOne = guiCreateCheckBox(27, 57, 299, 24, "When you kill someone for fun.", false, false, quizWindow) 
quizOneAnswerTwo = guiCreateCheckBox(27, 81, 299, 21, "When you kill someone without a Roleplay reason.", false, false, quizWindow) 
quizOneAnswerThree = guiCreateCheckBox(27, 106, 299, 21, "When you kill someone and run away.", false, false, quizWindow) 
quizTwo = guiCreateLabel(27, 137, 237, 18, "2. What side do you drive your vehicle on?", false, quizWindow) 
quizTwoAnswerOne = guiCreateCheckBox(27, 161, 299, 24, "Right.", false, false, quizWindow) 
quizTwoAnswerTwo = guiCreateCheckBox(27, 185, 299, 24, "Left.", false, false, quizWindow) 
quizTwoAnswerThree = guiCreateCheckBox(27, 209, 299, 24, "Any side you want.", false, false, quizWindow) 
quizFour = guiCreateLabel(27, 239, 343, 17, "3. If you see someone breaking the rules what would you do?", false, quizWindow) 
quizFourAnswerOne = guiCreateCheckBox(27, 260, 299, 24, "Use F2/Report using the right information.", false, false, quizWindow) 
quizFourAnswerTwo = guiCreateCheckBox(27, 290, 299, 24, "Walk past and take no action.", true, false, quizWindow) 
quizFourAnswerThree = guiCreateCheckBox(27, 318, 299, 24, "Spam an Admin's PM.", false, false, quizWindow) 
quizFinish = guiCreateButton(308, 335, 72, 26, "Finish", false, quizWindow)  
showCursor( true ) 
end 
addCommandHandler("rpquiz", quizMain) 
  
function correctQuiz() 
if quizOneAnswerTwo and quizTwoAnswerOne and quizFourAnswerOne and quizFinish then 
guiSetVisible( quizWindow, false ) 
showCursor( false ) 
outputChatBox("You have successfully passed the test, now you may continue!", 0, 255, 0 ) 
  end 
end 
addEventHandler("onClientGUIClick", root, correctQuiz ) 

But what I want is after the person has checked his/her answers I want them to press 'Finish' and then it closes the GUI however it doesn't, the person presses the checkbox and it closes and output's the message. Please help me what I want is once the person has checked their boxes then presses finish and if it's right then the GUI Closes and output's the message.

Link to comment

quizWindow = guiCreateWindow(207, 118, 406, 371, "", false) 
guiWindowSetSizable(quizWindow, false) 
guiSetVisible( quizWindow, false ) 
quizOne = guiCreateLabel(27, 35, 210, 24, "1. What is Deathmatching in Roleplay?", false, quizWindow) 
quizOneAnswerOne = guiCreateCheckBox(27, 57, 299, 24, "When you kill someone for fun.", false, false, quizWindow) 
quizOneAnswerTwo = guiCreateCheckBox(27, 81, 299, 21, "When you kill someone without a Roleplay reason.", false, false, quizWindow) 
guiCheckBoxSetSelected(quizOneAnswerTwo, true); 
quizOneAnswerThree = guiCreateCheckBox(27, 106, 299, 21, "When you kill someone and run away.", false, false, quizWindow) 
quizTwo = guiCreateLabel(27, 137, 237, 18, "2. What side do you drive your vehicle on?", false, quizWindow) 
quizTwoAnswerOne = guiCreateCheckBox(27, 161, 299, 24, "Right.", false, false, quizWindow) 
guiCheckBoxSetSelected(quizTwoAnswerOne, true); 
quizTwoAnswerTwo = guiCreateCheckBox(27, 185, 299, 24, "Left.", false, false, quizWindow) 
quizTwoAnswerThree = guiCreateCheckBox(27, 209, 299, 24, "Any side you want.", false, false, quizWindow) 
quizFour = guiCreateLabel(27, 239, 343, 17, "3. If you see someone breaking the rules what would you do?", false, quizWindow) 
quizFourAnswerOne = guiCreateCheckBox(27, 260, 299, 24, "Use F2/Report using the right information.", false, false, quizWindow) 
guiCheckBoxSetSelected(quizFourAnswerOne, true); 
quizFourAnswerTwo = guiCreateCheckBox(27, 290, 299, 24, "Walk past and take no action.", true, false, quizWindow) 
quizFourAnswerThree = guiCreateCheckBox(27, 318, 299, 24, "Spam an Admin's PM.", false, false, quizWindow) 
quizFinish = guiCreateButton(308, 335, 72, 26, "Finish", false, quizWindow) 
  
addCommandHandler("rpquiz", 
function ( ) 
guiSetVisible( quizWindow, true ) 
showCursor( true ) 
  end 
) 
  
addEventHandler("onClientGUIClick",resourceRoot, 
function ( ) 
     if(guiCheckBoxGetSelected(quizOneAnswerTwo) == true and guiCheckBoxGetSelected(quizTwoAnswerOne) == true) and guiCheckBoxGetSelected(quizFourAnswerOne) == true then 
      if ( source == quizFinish ) then 
     guiSetVisible( quizWindow, false ) 
     showCursor( false ) 
     outputChatBox("You have successfully passed the test, now you may continue!", 0, 255, 0 ) 
   end 
 end 
end 
) 

Edited @

Edited by Guest
Link to comment

I tried it but the problem is the check boxes are already checked I don't want that, any ideas ?

quizWindow = guiCreateWindow(207, 118, 406, 371, "", false) 
guiWindowSetSizable(quizWindow, false) 
guiSetVisible( quizWindow, false ) 
quizOne = guiCreateLabel(27, 35, 210, 24, "1. What is Deathmatching in Roleplay?", false, quizWindow) 
quizOneAnswerOne = guiCreateCheckBox(27, 57, 299, 24, "When you kill someone for fun.", false, false, quizWindow) 
quizOneAnswerTwo = guiCreateCheckBox(27, 81, 299, 21, "When you kill someone without a Roleplay reason.", false, false, quizWindow) 
guiCheckBoxSetSelected(quizOneAnswerTwo, true); 
quizOneAnswerThree = guiCreateCheckBox(27, 106, 299, 21, "When you kill someone and run away.", false, false, quizWindow) 
quizTwo = guiCreateLabel(27, 137, 237, 18, "2. What side do you drive your vehicle on?", false, quizWindow) 
quizTwoAnswerOne = guiCreateCheckBox(27, 161, 299, 24, "Right.", false, false, quizWindow) 
guiCheckBoxSetSelected(quizTwoAnswerOne, true); 
quizTwoAnswerTwo = guiCreateCheckBox(27, 185, 299, 24, "Left.", false, false, quizWindow) 
quizTwoAnswerThree = guiCreateCheckBox(27, 209, 299, 24, "Any side you want.", false, false, quizWindow) 
quizFour = guiCreateLabel(27, 239, 343, 17, "3. If you see someone breaking the rules what would you do?", false, quizWindow) 
quizFourAnswerOne = guiCreateCheckBox(27, 260, 299, 24, "Use F2/Report using the right information.", false, false, quizWindow) 
guiCheckBoxSetSelected(quizFourAnswerOne, true); 
quizFourAnswerTwo = guiCreateCheckBox(27, 290, 299, 24, "Walk past and take no action.", true, false, quizWindow) 
quizFourAnswerThree = guiCreateCheckBox(27, 318, 299, 24, "Spam an Admin's PM.", false, false, quizWindow) 
quizFinish = guiCreateButton(308, 335, 72, 26, "Finish", false, quizWindow) 
  
addCommandHandler("rpquiz", 
function ( ) 
guiSetVisible( quizWindow, true ) 
showCursor( true ) 
  end 
) 
  
addEventHandler("onClientGUIClick",resourceRoot, 
function ( ) 
     if(guiCheckBoxGetSelected(quizOneAnswerTwo) == true and guiCheckBoxGetSelected(quizTwoAnswerOne) == true) and guiCheckBoxGetSelected(quizFourAnswerOne) == true then 
      if ( source == quizFinish ) then 
     guiSetVisible( quizWindow, false ) 
     showCursor( false ) 
     outputChatBox("You have successfully passed the test, now you may continue!", 0, 255, 0 ) 
   end 
 end 
end 
) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...