LUA QueZ!

Okey im trying to make a system so when you join this TaconBanna Quiz pops up. (my own ofc)

So can anyone help me with this code:

This part:
( // your code here
#########################################HERE!
CHECKS SO ALL QUES IS “Yes” If it’s yes then CLOSE DERMA PANEL
IF Not THEN KICK.)

So, you´want them to answer a question, by click yes or No. If they click Yes, then it just closes, if No, it kicks them?

What the heck is Ques?

[editline]01:09PM[/editline]

You want only one question, or you want another one to open up after?

If you look in the Lua code you will see two “yes/no” questions, so its 2. and Button1 (Continue) = Check so both questions are answered with “yes” if both are yes then exit derma/window, or if the user didn’t answer the questions and just leave it blank or wrong then kick.

QUES = the Questions codes.

Making one now.

[editline]03:03PM[/editline]



function Quiz1() 
	Quiz1:SetVisible(true)
end

concommand.Add("quiz_1", Quiz1)

	
function Quiz2()
	Quiz2:SetVisible(true)
end 

concommand.Add("quiz_2", Quiz2)

 Quiz1 = vgui.Create( "DFrame" ) 
Quiz1:SetPos( 300, 300 )
Quiz1:SetSize( 285, 150 )
Quiz1:SetTitle( "Welcome to XH RP Server#1 - QUIZ" )
Quiz1:SetVisible( false )
Quiz1:SetDraggable( false )
Quiz1:ShowCloseButton( false )
Quiz1:MakePopup()
 
 DermaList = vgui.Create( "DPanelList", Quiz1 )
DermaList:SetPos( 15, 35 )
DermaList:SetSize( 255, 60 )

 Greet = vgui.Create( "DLabel", Quiz1 )
Greet:SetPos( 20, 40)
Greet:SetText("Is it fun to RP with no toolgun?")
Greet:SizeToContents()

 YesToolgun = vgui.Create ( "DButton", Quiz1 ) 
YesToolgun:SetPos( 25, 110 )
YesToolgun:SetSize( 70, 22 )
YesToolgun:SetText("Yes!")
YesToolgun.DoClick = function()
	Quiz1:SetVisible(false)
	Quiz2:SetVisible(true)
	end

 NoToolgun = vgui.Create ( "DButton", Quiz1 ) 
NoToolgun:SetPos( 120, 110 )
NoToolgun:SetSize( 140, 22 )
NoToolgun:SetText("No!")
NoToolgun.DoClick = function ()
	RunConsoleCommand("disconnect")
end

 Quiz2 = vgui.Create( "DFrame" ) 
Quiz2:SetPos( 300, 250 )
Quiz2:SetSize( 150, 150 )
Quiz2:SetTitle( "Welcome to XH RP Server#1 - QUIZ" ) 
Quiz2:SetVisible( false )
Quiz2:SetDraggable( false )
Quiz2:ShowCloseButton( false )
Quiz2:MakePopup()
 
 QuizTextArea = vgui.Create( "DPanelList", Quiz2 )
QuizTextArea:SetPos( 15, 30 )
QuizTextArea:SetSize( 50, 100 )

 Continue = vgui.Create( "DLabel", Quiz2 ) 
Continue:SetPos( 20, 30) 
Continue:SetText("Is it fun to RP without gun fighting?")
Continue:SizeToContents()

 YesGun = vgui.Create ( "DButton", Quiz2 ) 
YesGun:SetPos( 15, 100 )
YesGun:SetSize( 35, 40 )
YesGun:SetText("Yes!")
YesGun.DoClick = function ()
Quiz2:SetVisible(false)
end

 NoGun = vgui.Create ( "DButton", Quiz2 )
NoGun:SetPos( 25, 100 )
NoGun:SetSize( 35, 40 )
NoGun:SetText("No!")
NoGun.DoClick = function ()
	RunConsoleCommand("disconnect")
end


Should go into lua/autorun/client.

If you dont like it; make your own.

If the buttons arent positioned right; I did it in Notepad, didnt have a visual aspect.

Thanks alot, but the
function Quiz1()
““Quiz1:SetVisible(true)””
end

dons’t work :S

autorun/client/keypad_cracker.lua:2: attempt to index global ‘Quiz1’ (a nil value)

Try this, I just re arranged busymonkey’s script.
[lua]
Quiz1 = vgui.Create( “DFrame” )
Quiz1:SetPos( 300, 300 )
Quiz1:SetSize( 285, 150 )
Quiz1:SetTitle( “Welcome to XH RP Server#1 - QUIZ” )
Quiz1:SetVisible( false )
Quiz1:SetDraggable( false )
Quiz1:ShowCloseButton( false )
Quiz1:MakePopup()

DermaList = vgui.Create( “DPanelList”, Quiz1 )
DermaList:SetPos( 15, 35 )
DermaList:SetSize( 255, 60 )

Greet = vgui.Create( “DLabel”, Quiz1 )
Greet:SetPos( 20, 40)
Greet:SetText(“Is it fun to RP with no toolgun?”)
Greet:SizeToContents()

YesToolgun = vgui.Create ( “DButton”, Quiz1 )
YesToolgun:SetPos( 25, 110 )
YesToolgun:SetSize( 70, 22 )
YesToolgun:SetText(“Yes!”)
YesToolgun.DoClick = function()
Quiz1:SetVisible(false)
Quiz2:SetVisible(true)
end

NoToolgun = vgui.Create ( “DButton”, Quiz1 )
NoToolgun:SetPos( 120, 110 )
NoToolgun:SetSize( 140, 22 )
NoToolgun:SetText(“No!”)
NoToolgun.DoClick = function ()
RunConsoleCommand(“disconnect”)
end

Quiz2 = vgui.Create( “DFrame” )
Quiz2:SetPos( 300, 250 )
Quiz2:SetSize( 150, 150 )
Quiz2:SetTitle( “Welcome to XH RP Server#1 - QUIZ” )
Quiz2:SetVisible( false )
Quiz2:SetDraggable( false )
Quiz2:ShowCloseButton( false )
Quiz2:MakePopup()

QuizTextArea = vgui.Create( “DPanelList”, Quiz2 )
QuizTextArea:SetPos( 15, 30 )
QuizTextArea:SetSize( 50, 100 )

Continue = vgui.Create( “DLabel”, Quiz2 )
Continue:SetPos( 20, 30)
Continue:SetText(“Is it fun to RP without gun fighting?”)
Continue:SizeToContents()

YesGun = vgui.Create ( “DButton”, Quiz2 )
YesGun:SetPos( 15, 100 )
YesGun:SetSize( 35, 40 )
YesGun:SetText(“Yes!”)
YesGun.DoClick = function ()
Quiz2:SetVisible(false)
end

NoGun = vgui.Create ( “DButton”, Quiz2 )
NoGun:SetPos( 25, 100 )
NoGun:SetSize( 35, 40 )
NoGun:SetText(“No!”)
NoGun.DoClick = function ()
RunConsoleCommand(“disconnect”)
end

function Quiz1()
Quiz1:SetVisible(true)
end

concommand.Add(“quiz_1”, Quiz1)

function Quiz2()
Quiz2:SetVisible(true)
end

concommand.Add(“quiz_2”, Quiz2)
[/lua]

Your panel objects and functions have the same name.

Still Error ^^


QuizTextArea = vgui.Create( "DPanelList", Quiz2 ) 
DermaList = vgui.Create( "DPanelList", Quiz1 )

Not the same ^

Neither is v


function Quiz1() 
Quiz1:SetVisible(true)
end

function Quiz2()
Quiz2:SetVisible(true)
end 


If I remember correctly disconnect should be block unless, I’m thinking about exit.

I don’t think disconnect is, since its not harmful in anyway. But exit is however

You misunderstood me.

[lua] Quiz1 = vgui.Create( “DFrame” ) [/lua]
[lua] Quiz2 = vgui.Create( “DFrame” )[/lua]
[lua]function Quiz1()[/lua]
[lua]function Quiz2()[/lua]

What Nevec means is that Quiz1 ends up pointing to a function and all references to your panel object are lost. Same for Quiz2.

The solution is simply to change the name of the functions.

Which is something he should figure out by himself.

Oh, right :doh:



 Quiz1 = vgui.Create( "DFrame" ) 
Quiz1:SetPos( 300, 300 )
Quiz1:SetSize( 285, 150 )
Quiz1:SetTitle( "Welcome to XH RP Server#1 - QUIZ" )
Quiz1:SetVisible( false )
Quiz1:SetDraggable( false )
Quiz1:ShowCloseButton( false )
Quiz1:MakePopup()
 
 DermaList = vgui.Create( "DPanelList", Quiz1 )
DermaList:SetPos( 15, 35 )
DermaList:SetSize( 255, 60 )

 Greet = vgui.Create( "DLabel", Quiz1 )
Greet:SetPos( 20, 40)
Greet:SetText("Is it fun to RP with no toolgun?")
Greet:SizeToContents()

 YesToolgun = vgui.Create ( "DButton", Quiz1 ) 
YesToolgun:SetPos( 25, 110 )
YesToolgun:SetSize( 70, 22 )
YesToolgun:SetText("Yes!")
YesToolgun.DoClick = function()
	Quiz1:SetVisible(false)
	Quiz2:SetVisible(true)
	end

 NoToolgun = vgui.Create ( "DButton", Quiz1 ) 
NoToolgun:SetPos( 120, 110 )
NoToolgun:SetSize( 140, 22 )
NoToolgun:SetText("No!")
NoToolgun.DoClick = function ()
	RunConsoleCommand("disconnect")
end

 Quiz2 = vgui.Create( "DFrame" ) 
Quiz2:SetPos( 300, 250 )
Quiz2:SetSize( 150, 150 )
Quiz2:SetTitle( "Welcome to XH RP Server#1 - QUIZ" ) 
Quiz2:SetVisible( false )
Quiz2:SetDraggable( false )
Quiz2:ShowCloseButton( false )
Quiz2:MakePopup()
 
 QuizTextArea = vgui.Create( "DPanelList", Quiz2 )
QuizTextArea:SetPos( 15, 30 )
QuizTextArea:SetSize( 50, 100 )

 Continue = vgui.Create( "DLabel", Quiz2 ) 
Continue:SetPos( 20, 30) 
Continue:SetText("Is it fun to RP without gun fighting?")
Continue:SizeToContents()

 YesGun = vgui.Create ( "DButton", Quiz2 ) 
YesGun:SetPos( 15, 100 )
YesGun:SetSize( 35, 40 )
YesGun:SetText("Yes!")
YesGun.DoClick = function ()
Quiz2:SetVisible(false)
end

 NoGun = vgui.Create ( "DButton", Quiz2 )
NoGun:SetPos( 25, 100 )
NoGun:SetSize( 35, 40 )
NoGun:SetText("No!")
NoGun.DoClick = function ()
	RunConsoleCommand("disconnect")
end

function QuizOne() 
	Quiz1:SetVisible(true)
end

concommand.Add("quiz_1", QuizOne)

	
function QuizTwo()
	Quiz2:SetVisible(true)
end 

concommand.Add("quiz_2", QuizTwo)