MKZ Posted August 17, 2022 Share Posted August 17, 2022 Eu queria fazer uma auto escola mais na hora do teste com mais de uma pessoa fazendo ela buga por completo como posso resolver isso? Client_Side local rx,ry = guiGetScreenSize() local x,y = (rx/1440),(ry/900) local off_on = false local selected = "" markers = { [1] = {2809.625, -1576.302, 10.928}, [2] = {2840.45, -1571.208, 10.922}, } function painel() dxDrawRectangle(x*529, y*246, x*377, y*208, tocolor(75, 0, 0, 183), false) dxDrawRectangle(x*529, y*246, x*377, y*37, tocolor(11, 0, 0, 255), false) dxDrawText("Auto Escola", x*529, y*246, x*908, y*283, tocolor(255, 255, 255, 255), 2.00*x, "default", "center", "center", false, false, false, false, false) dxDrawRectangle(x*715, y*279, x*17, y*175, tocolor(11, 0, 0, 255), false) dxDrawRectangle(x*569, y*420, x*106, y*31, tocolor(38, 102, 18, 255), false) dxDrawRectangle(x*529, y*401, x*377, y*17, tocolor(11, 0, 0, 255), false) dxDrawRectangle(x*766, y*420, x*106, y*31, tocolor(254, 0, 0, 255), false) dxDrawRectangle(x*532, y*319, x*180, y*24, color1, false) if selected == "Moto" then else color1 = tocolor(0, 0, 0, 0) end if isCursorOnElement(x*532, y*319, x*180, y*24) then color1 = tocolor(255, 81, 81, 255) end dxDrawRectangle(x*532, y*349, x*180, y*24, color2, false) if selected == "Carro" then else color2 = tocolor(0, 0, 0, 0) end if isCursorOnElement(x*532, y*349, x*180, y*24) then color2 = tocolor(255, 81, 81, 255) end dxDrawRectangle(x*532, y*377, x*180, y*24, color3, false) if selected == "Caminhão" then else color3 = tocolor(0, 0, 0, 0) end if isCursorOnElement(x*532, y*377, x*180, y*24) then color3 = tocolor(255, 81, 81, 255) end dxDrawText("Categoria", x*529, y*283, x*716, y*306, tocolor(255, 255, 255, 255), 1.20*x, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Preço", x*732, y*283, x*906, y*306, tocolor(255, 255, 255, 255), 1.20*x, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Moto (A)", x*529, y*321, x*715, y*341, tocolor(255, 255, 255, 255), 1.00*x, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Carro (B)", x*529, y*351, x*715, y*371, tocolor(255, 255, 255, 255), 1.00*x, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Caminhão (C)", x*529, y*381, x*715, y*401, tocolor(255, 255, 255, 255), 1.00*x, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("R$: 2000", x*732, y*321, x*906, y*341, tocolor(255, 255, 255, 255), 1.00*x, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("R$: 5000", x*732, y*351, x*906, y*371, tocolor(255, 255, 255, 255), 1.00*x, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("R$: 7000", x*732, y*381, x*906, y*401, tocolor(255, 255, 255, 255), 1.00*x, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Fazer Carteira", x*569, y*420, x*675, y*451, tocolor(255, 255, 255, 255), 1.00*x, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Cancelar", x*766, y*420, x*872, y*451, tocolor(255, 255, 255, 255), 1.00*x, "default-bold", "center", "center", false, false, false, false, false) end function abrirAutoEscola() if not isEventHandlerAdded("onClientRender", root, painel) then addEventHandler("onClientRender", root, painel) showCursor(true) end end addEvent("AbrirPainelAutoEscola", true) addEventHandler("AbrirPainelAutoEscola", getRootElement(), abrirAutoEscola) --clicks local money = 0 addEventHandler ( "onClientClick", root, function(_,state) if isEventHandlerAdded("onClientRender", root, painel) then if state == "down" then if isCursorOnElement(x*532, y*319, x*180, y*24) then selected = "Moto" money = 2000 elseif isCursorOnElement(x*532, y*349, x*180, y*24) then selected = "Carro" money = 5000 elseif isCursorOnElement(x*532, y*377, x*180, y*24) then selected = "Caminhão" money = 7000 end if isCursorOnElement(x*766, y*420, x*106, y*31) then if isEventHandlerAdded("onClientRender", root, painel) then showCursor(false) selected = "" removeEventHandler("onClientRender", root, painel) end end if isCursorOnElement(x*569, y*420, x*106, y*31) then if selected == "" then triggerServerEvent("infoAutoEscola",localPlayer, localPlayer, "Selecione uma Categoria", "info") return end if getPlayerMoney(getLocalPlayer()) >= money then triggerServerEvent("IniciarAutoEscola", localPlayer, localPlayer, selected,money) triggerServerEvent("AutoEscolaTeste",localPlayer,localPlayer) else triggerServerEvent("infoAutoEscola",localPlayer, localPlayer, "Você não tem dinheiro suficiente", "error") end if isEventHandlerAdded("onClientRender", root, painel) then showCursor(false) selected = "" removeEventHandler("onClientRender", root, painel) end end end end end) addEvent("CreateMarkerAutoEscola", true) addEventHandler("CreateMarkerAutoEscola", root, function(number) local x, y, z = markers[number][1], markers[number][2], markers[number][3] marker = createMarker(x, y, z , "checkpoint", 2.0, 255, 255, 255) if number == 2 then terminou = true end end) addEventHandler ( "onClientMarkerHit", getRootElement(), function(source) triggerServerEvent("onMarkerHitAutoEscola", localPlayer, source) finalizar() end) function finalizar() if isElement(marker) then destroyElement(marker) end if getElementData(getLocalPlayer(), "AutoEscolaDataStarted",false) then triggerServerEvent("infoAutoEscola",localPlayer, localPlayer,"Você terminou o teste","success") end end addEvent("FinalizarTesteAutoEscola", true) addEventHandler ( "FinalizarTesteAutoEscola", root, finalizar) local x,y = guiGetScreenSize() function isCursorOnElement(x, y, w, h) if (not isCursorShowing()) then return false end local mx, my = getCursorPosition() local fullx, fully = guiGetScreenSize() cursorx, cursory = mx*fullx, my*fully if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then return true else return false end end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end Server_Side Abrir_AutoEscola = createMarker(2770.561, -1628.517, 11.177, "cylinder", 1.2,16, 111, 231, 90) Blip = createBlipAttachedTo ( Abrir_AutoEscola, 38 ) function OpenguiAE(thePlayer) local account = getPlayerAccount (thePlayer) if isGuestAccount (account) then outputChatBox ( "#106FE7✘ #ffffffAutoEscola #106FE7✘➺ #FFFFFFVocê não pode fazer a carta deslogado, Crie uma Conta!", thePlayer, 255,255,255,true) return end if isElementWithinMarker(thePlayer, Abrir_AutoEscola) then if getElementData(thePlayer, "AutoEscolaDataStarted", true) then exports.infobox:addBox(thePlayer,"Você ja começou um teste","warning") return end triggerClientEvent(thePlayer,"AbrirPainelAutoEscola",thePlayer) end end addEventHandler( "onMarkerHit", Abrir_AutoEscola, OpenguiAE ) function addBoxAutoEscola(element,msg,type) exports.infobox:addBox(element,msg,type) end addEvent("infoAutoEscola", true) addEventHandler("infoAutoEscola", root, addBoxAutoEscola) Moto_Teste = {} Carro_Teste = {} Caminhao_Teste = {} function iniciar(thePlayer, selected,money) exports.infobox:addBox(thePlayer,"Iniciou o Teste de "..selected,"info") setElementData(thePlayer, "AutoEscolaDataPlayer", 1) setElementData(thePlayer, "AutoEscolaDataStarted", true) takePlayerMoney(thePlayer,tonumber(money)) if selected == "Moto" then Moto_Teste[thePlayer] = createVehicle(581,2777.118, -1610.536, 10.922,-0, 0, 272.231) warpPedIntoVehicle(thePlayer, Moto_Teste[thePlayer]) elseif selected == "Carro" then Carro_Teste[thePlayer] = createVehicle(415,2777.118, -1610.536, 10.922,-0, 0, 272.231) warpPedIntoVehicle(thePlayer, Carro_Teste[thePlayer]) elseif selected == "Caminhão" then Caminhao_Teste[thePlayer] = createVehicle(515,2777.118, -1610.536, 10.922,-0, 0, 272.231) warpPedIntoVehicle(thePlayer, Caminhao_Teste[thePlayer]) end end addEvent("IniciarAutoEscola", true) addEventHandler("IniciarAutoEscola", root, iniciar) addEvent("onMarkerHitAutoEscola", true) function teste(element) if isElement(element) then local number = tonumber((getElementData(element, "AutoEscolaDataPlayer") or 1)) if getElementData(element, "AutoEscolaDataStarted", true) then triggerClientEvent(element,"CreateMarkerAutoEscola",element, number) end addEventHandler("onMarkerHitAutoEscola", root, function(source) if source == element then setElementData(source, "AutoEscolaDataPlayer", number +1) if number == 2 then triggerClientEvent(source,"FinalizarTesteAutoEscola",source) exports.infobox:addBox(source,"Você terminou o teste","success") setElementData(source, "AutoEscolaDataStarted", false) if Moto_Teste[source] and isElement(Moto_Teste[source]) then destroyElement ( Moto_Teste[source] ) end if Carro_Teste[source] and isElement(Carro_Teste[source]) then destroyElement ( Carro_Teste[source] ) end if Caminhao_Teste[source] and isElement(Caminhao_Teste[source]) then destroyElement ( Caminhao_Teste[source] ) end return end teste(source) end end) end end addEvent("AutoEscolaTeste", true) addEventHandler("AutoEscolaTeste", root, teste) addEventHandler ( "onVehicleExit", getRootElement(), function(thePlayer) if getElementData(thePlayer,"AutoEscolaDataStarted") then exports.infobox:addBox(thePlayer,"Você falhou no teste","error") destroyElement(markerCheckpoint) setElementData(thePlayer, "AutoEscolaDataPlayer", nil) if Moto_Teste[thePlayer] and isElement(Moto_Teste[thePlayer]) then destroyElement ( Moto_Teste[thePlayer] ) end if Carro_Teste[thePlayer] and isElement(Carro_Teste[thePlayer]) then destroyElement ( Carro_Teste[thePlayer] ) end if Caminhao_Teste[thePlayer] and isElement(Caminhao_Teste[thePlayer]) then destroyElement ( Caminhao_Teste[thePlayer] ) end setElementData(thePlayer, "AutoEscolaDataStarted", false) end end) 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