NickScripter Posted February 19, 2020 Share Posted February 19, 2020 Hello! I'm trying to make a system where the player needs to answer a few questions before registering. I'm having trouble doing the part where the player selects a CheckBox an answer and clicks the Confirm button. can anybody help me? 'etapas' means the step of the menu (false is the intro menu and true is the questions menu) Client etapas = {}; acertou = {}; function Prova(button) local quantidade = acertou[localPlayer] if button == "left" then if etapas[localPlayer] == false then FecharProva etapas[localPlayer] = true AbrirProva elseif etapas[localPlayer] == true then if Pergunta == false then FecharProva Pergunta = 1 AbrirProva elseif Pergunta == 1 then if source == opcaoC then if guiCheckBoxGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva Pergunta = 2 AbrirProva elseif Pergunta == 2 then if source == opcaoC then if guiCheckBoxGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva Pergunta = 3 AbrirProva end elseif Pergunta == 3 then if source == opcaoC then if guiCheckBoxGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva if quantidade >= 2 then outputChatBox ( "[TLRP] #34eb3dVocê passou na prova com "..quantidade.." acertos. Parabéns!!", 255, 255, 255, true ) acertou[localPlayer] = 0 etapas[localPlayer] = false; triggerServerEvent(localPlayer, "NSCR:TerminouProva", localPlayer) else outputChatBox ( "[TLRP] #ff0000Você falhou na prova com "..quantidade.." acertos e foi kickado. (Maximo de erros: 3)", 255, 255, 255, true ) kickPlayer(localPlayer) end end end end end Error: '=' expected near 'etapas' --Error line: etapas[localPlayer] = true Thanks!!!! Link to comment
ReZurrecti0n Posted February 19, 2020 Share Posted February 19, 2020 If you want to allow multiple answers for each question, then continue using check boxes. However, if you want to allow only one answer, then use radio buttons instead. etapas = {}; acertou = {}; function Prova(button) local quantidade = acertou[localPlayer] if button == "left" then if etapas[localPlayer] == false then FecharProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? etapas[localPlayer] = true AbrirProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? elseif etapas[localPlayer] == true then if Pergunta == false then FecharProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? Pergunta = 1 AbrirProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? elseif Pergunta == 1 then if source == opcaoC then if guiCheckBoxGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? Pergunta = 2 AbrirProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? elseif Pergunta == 2 then if source == opcaoC then if guiCheckBoxGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? Pergunta = 3 AbrirProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? end elseif Pergunta == 3 then if source == opcaoC then if guiCheckBoxGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? if quantidade >= 2 then outputChatBox ( "[TLRP] #34eb3dVocê passou na prova com "..quantidade.." acertos. Parabéns!!", 255, 255, 255, true ) acertou[localPlayer] = 0 etapas[localPlayer] = false; triggerServerEvent(localPlayer, "NSCR:TerminouProva", localPlayer) -- The 1st argument (localPlayer) isn't needed for Server Side Triggers else outputChatBox ( "[TLRP] #ff0000Você falhou na prova com "..quantidade.." acertos e foi kickado. (Maximo de erros: 3)", 255, 255, 255, true ) kickPlayer(localPlayer) end end end end end 1 Link to comment
NickScripter Posted February 19, 2020 Author Share Posted February 19, 2020 (edited) Thanks for you reply! The radio buttons fit better in the system that i want I'ts returning a error when i start the script '=' expected near 'etapas' --Error line in function Prova(button) etapas[localPlayer] = true More explained Script Client: local etapas = {}; -- Step of the questions local acertou = {}; -- right answer table local Pergunta = "" -- Question local textotitulo = "" -- Title Text local texto1 = "" -- Option 1 text local texto2 = "" -- Option 2 text local texto3 = "" -- Option 3 text local texto4 = "" -- Option 4 text function AbrirProva() -- Open DX if isEventHandlerAdded("onClientRender", getRootElement(), ProvaRender) then return end addEventHandler ( "onClientGUIClick", prosseguir, Prova ) addEventHandler("onClientRender", root, ProvaRender) showCursor(true) end --addCommandHandler("testedss", AbrirProva) addEvent("NSCR:AbrirProva", true) addEventHandler("NSCR:AbrirProva", root, AbrirProva) function FecharProva() -- Close DX if isEventHandlerAdded("onClientRender", getRootElement(), ProvaRender) then removeEventHandler("onClientRender", root, ProvaRender) removeEventHandler("onClientGUIClick", root, Prova) showCursor(false) setElementVisibleTo(localPlayer, "prosseguir", false) setElementVisibleTo(localPlayer, "opcaoA", false) setElementVisibleTo(localPlayer, "opcaoB", false) setElementVisibleTo(localPlayer, "opcaoC", false) setElementVisibleTo(localPlayer, "opcaoD", false) end end function Prova(button) local quantidade = acertou[localPlayer] if button == "left" then if etapas[localPlayer] == false then FecharProva etapas[localPlayer] = true AbrirProva elseif etapas[localPlayer] == true then if Pergunta == false then FecharProva Pergunta = 1 AbrirProva elseif Pergunta == 1 then if source == opcaoC then if guiRadioButtonGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva Pergunta = 2 AbrirProva elseif Pergunta == 2 then if source == opcaoC then if guiRadioButtonGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva Pergunta = 3 AbrirProva end elseif Pergunta == 3 then if source == opcaoD then if guiRadioButtonGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva Pergunta = 4 AbrirProva end elseif Pergunta == 4 then if source == opcaoD then if guiRadioButtonGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva Pergunta = 5 AbrirProva end elseif Pergunta == 6 then if source == opcaoC then if guiRadioButtonGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva Pergunta = 7 AbrirProva end elseif Pergunta == 7 then if source == opcaoC then if guiRadioButtonGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva Pergunta = 8 AbrirProva end elseif Pergunta == 8 then if source == opcaoC then if guiRadioButtonGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva Pergunta = 9 AbrirProva end elseif Pergunta == 9 then if source == opcaoC then if guiRadioButtonGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva if quantidade >= 6 then -- If you hit more than 6, you passed outputChatBox ( "[TLRP] #34eb3dVocê passou na prova com "..quantidade.." acertos. Parabéns!!", 255, 255, 255, true ) acertou[localPlayer] = 0 etapas[localPlayer] = false; triggerServerEvent(localPlayer, "NSCR:TerminouProva", localPlayer) else -- fail message outputChatBox ( "[TLRP] #ff0000Você falhou na prova com "..quantidade.." acertos e foi kickado. (Maximo de erros: 6)", 255, 255, 255, true ) kickPlayer(localPlayer) end end end end end function ProvaRender() -- DX if Pergunta == "1" then -- Sets the DX Text textotitulo = "O que é Roleplay?" texto1 = "A- Cidade do MTA Roleplay" texto2 = "B- Simulação de tiro" texto3 = "C- Simulação da vida real" texto4 = "D- Gamemode do GTA ONLINE" elseif Pergunta == "2" then textotitulo = "O que é RDM?" texto1 = "A- Quando prende um meliante" texto2 = "B- Roubar alguem perto da policia" texto3 = "C- Matar um jogador sem motivo" texto4 = "D- Atropelar um jogador sem motivo" end elseif Pergunta == "3" then textotitulo = "O que é VDM?" texto1 = "A- Quando morre afogado" texto2 = "B- Fugir da delegacia de policia" texto3 = "C- Matar um jogador sem motivo" texto4 = "D- Atropelar um jogador sem motivo" end if etapas[localPlayer] == false then -- Intro DX acertou[localPlayer] = 0 dxDrawImage(711, 406, 507, 354, ":[Script]Identidade/Img/prova.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("Testando conhecimento do RP", 805 - 1, 421 - 1, 1085 - 1, 459 - 1, tocolor(0, 0, 0, 255), 1.20, "diploma", "left", "top", false, false, false, false, false) dxDrawText("Testando conhecimento do RP", 805 + 1, 421 - 1, 1085 + 1, 459 - 1, tocolor(0, 0, 0, 255), 1.20, "diploma", "left", "top", false, false, false, false, false) dxDrawText("Testando conhecimento do RP", 805 - 1, 421 + 1, 1085 - 1, 459 + 1, tocolor(0, 0, 0, 255), 1.20, "diploma", "left", "top", false, false, false, false, false) dxDrawText("Testando conhecimento do RP", 805 + 1, 421 + 1, 1085 + 1, 459 + 1, tocolor(0, 0, 0, 255), 1.20, "diploma", "left", "top", false, false, false, false, false) dxDrawText("Testando conhecimento do RP", 805, 421, 1085, 459, tocolor(255, 255, 255, 255), 1.20, "diploma", "left", "top", false, false, false, false, false) dxDrawText(" Seja bem vindo ao ThugLife Roleplay!! \n\nVocê irá responder um questionário \nantes de entrar na cidade.", 749 - 1, 512 - 1, 1178 - 1, 648 - 1, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) dxDrawText(" Seja bem vindo ao ThugLife Roleplay!! \n\nVocê irá responder um questionário \nantes de entrar na cidade.", 749 + 1, 512 - 1, 1178 + 1, 648 - 1, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) dxDrawText(" Seja bem vindo ao ThugLife Roleplay!! \n\nVocê irá responder um questionário \nantes de entrar na cidade.", 749 - 1, 512 + 1, 1178 - 1, 648 + 1, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) dxDrawText(" Seja bem vindo ao ThugLife Roleplay!! \n\nVocê irá responder um questionário \nantes de entrar na cidade.", 749 + 1, 512 + 1, 1178 + 1, 648 + 1, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) dxDrawText(" Seja bem vindo ao ThugLife Roleplay!! \n\nVocê irá responder um questionário \nantes de entrar na cidade.", 749, 512, 1178, 648, tocolor(255, 255, 255, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Responda corretamente o formulário \npara conseguir emitir o seu passaporte.", 745 - 1, 658 - 1, 1178 - 1, 739 - 1, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Responda corretamente o formulário \npara conseguir emitir o seu passaporte.", 745 + 1, 658 - 1, 1178 + 1, 739 - 1, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Responda corretamente o formulário \npara conseguir emitir o seu passaporte.", 745 - 1, 658 + 1, 1178 - 1, 739 + 1, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Responda corretamente o formulário \npara conseguir emitir o seu passaporte.", 745 + 1, 658 + 1, 1178 + 1, 739 + 1, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Responda corretamente o formulário \npara conseguir emitir o seu passaporte.", 745, 658, 1178, 739, tocolor(255, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) dxDrawImage(849, 203, 236, 193, ":[Script]Identidade/Img/logo.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) setElementVisibleTo(localPlayer, "prosseguir", true) elseif etapas[localPlayer] == true then -- Questions DX setElementVisibleTo(localPlayer, "opcaoA", true) setElementVisibleTo(localPlayer, "opcaoB", true) setElementVisibleTo(localPlayer, "opcaoC", true) setElementVisibleTo(localPlayer, "opcaoD", true) dxDrawImage(849, 203, 236, 193, ":[Script]Identidade/Img/logo.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(711, 406, 507, 354, ":[Script]Identidade/Img/perguntas.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText(""..textotitulo.."", 854 - 1, 422 - 1, 1091 - 1, 472 - 1, tocolor(0, 0, 0, 255), 1.00, "diploma", "left", "top", false, false, false, false, false) dxDrawText(""..textotitulo.."", 854 + 1, 422 - 1, 1091 + 1, 472 - 1, tocolor(0, 0, 0, 255), 1.00, "diploma", "left", "top", false, false, false, false, false) dxDrawText(""..textotitulo.."", 854 - 1, 422 + 1, 1091 - 1, 472 + 1, tocolor(0, 0, 0, 255), 1.00, "diploma", "left", "top", false, false, false, false, false) dxDrawText(""..textotitulo.."", 854 + 1, 422 + 1, 1091 + 1, 472 + 1, tocolor(0, 0, 0, 255), 1.00, "diploma", "left", "top", false, false, false, false, false) dxDrawText(""..textotitulo.."", 854, 422, 1091, 472, tocolor(229, 107, 25, 255), 1.00, "diploma", "left", "top", false, false, false, false, false) dxDrawText("A- "..texto.."", 774 - 1, 509 - 1, 1011 - 1, 559 - 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("A- "..texto.."", 774 + 1, 509 - 1, 1011 + 1, 559 - 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("A- "..texto.."", 774 - 1, 509 + 1, 1011 - 1, 559 + 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("A- "..texto.."", 774 + 1, 509 + 1, 1011 + 1, 559 + 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("A- "..texto.."", 774, 509, 1011, 559, tocolor(255, 255, 255, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("B- "..texto2.."", 774 - 1, 565 - 1, 1011 - 1, 615 - 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("B- "..texto2.."", 774 + 1, 565 - 1, 1011 + 1, 615 - 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("B- "..texto2.."", 774 - 1, 565 + 1, 1011 - 1, 615 + 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("B- "..texto2.."", 774 + 1, 565 + 1, 1011 + 1, 615 + 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("B- "..texto2.."", 774, 565, 1011, 615, tocolor(255, 255, 255, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("C- "..texto3.."", 774 - 1, 625 - 1, 1011 - 1, 675 - 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("C- "..texto3.."", 774 + 1, 625 - 1, 1011 + 1, 675 - 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("C- "..texto3.."", 774 - 1, 625 + 1, 1011 - 1, 675 + 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("C- "..texto3.."", 774 + 1, 625 + 1, 1011 + 1, 675 + 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("C- "..texto3.."", 774, 625, 1011, 675, tocolor(255, 255, 255, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("D- "..texto4.."", 774 - 1, 690 - 1, 1011 - 1, 740 - 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("D- "..texto4.."", 774 + 1, 690 - 1, 1011 + 1, 740 - 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("D- "..texto4.."", 774 - 1, 690 + 1, 1011 - 1, 740 + 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("D- "..texto4.."", 774 + 1, 690 + 1, 1011 + 1, 740 + 1, tocolor(0, 0, 0, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("D- "..texto4.."", 774, 690, 1011, 740, tocolor(255, 255, 255, 255), 1.30, "default-bold", "left", "top", false, false, false, false, false) end end addEventHandler("onClientResourceStart", resourceRoot, function() prosseguir = guiCreateButton(878, 760, 157, 41, "Prosseguir", false) guiSetProperty(prosseguir1, "NormalTextColour", "FF31FC02") opcaoA = guiCreateRadioButton(749, 492, 75, 53, "", false, false) opcaoB = guiCreateRadioButton(749, 549, 75, 53, "", false, false) opcaoC = guiCreateRadioButton(749, 608, 75, 53, "", false, false) opcaoD = guiCreateRadioButton(749, 671, 75, 53, "", false, false) end ) Server: function TerminouProva() -- Final Step triggerClientEvent(source, "DNL:AbrirRG", source) -- Continues the registration spawnPlayer(source, 1481.9635009766, -1782.9182128906, 21.828456878662, 2.0302429199219) end addEvent("NSCR:TerminouProva", true) addEventHandler("NSCR:TerminouProva", root, TerminouProva) Waiting your reply! Thanks!! Edited February 19, 2020 by Nickqq Link to comment
ReZurrecti0n Posted February 19, 2020 Share Posted February 19, 2020 FecharProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? etapas[localPlayer] = true -- This line itself is actually just fine AbrirProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? Link to comment
NickScripter Posted February 19, 2020 Author Share Posted February 19, 2020 13 minutes ago, ReZurrecti0n said: FecharProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do?etapas[localPlayer] = true -- This line itself is actually just fineAbrirProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? AbrirProva - Opens the DX FecharProva - Closes the DX Link to comment
NickScripter Posted February 19, 2020 Author Share Posted February 19, 2020 I managed to fix it! Thanks for your RadioBox tip, you saved me !! 1 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