Gustavo Freire Posted March 28, 2020 Share Posted March 28, 2020 (edited) Estava querendo criar um painel dx que aparecesse quando algum player entrasse no marker até aí tudo bem, porém quando fui colocar a função pra quando o player saísse do marker o painel fechasse começou a dar o seguinte erro no debugscript: ERROR:Server triggered clientside Event:Fechar_Painel, but event is not added clientside segue o script: --<><><><><CLIENT-SIDE><><><><> local screenW,screenH = guiGetScreenSize() local resW, resH = 1280, 960 local x, y = (screenW/resW), (screenH/resH) local painel = false function dx_Painel () if painel == true then dxDrawText("TESTE", screenW * 0.3265, screenH * 0.3581, screenW * 0.6837, screenH * 0.6211, tocolor(255, 255, 255, 255), 3.00, "default", "center", "center", false, false, false, false, false) end end function abrir_painel () if painel == false then addEventHandler("onClientRender", getRootElement(), dx_Painel) painel = true end end addEvent("Event:Abrir_Painel", true) addEventHandler("Event:Abrir_Painel", getRootElement(), abrir_painel) function fechar_painel () if painel == true then painel = false removeEventHandler("onClientRender", getRootElement(), dx_Painel) addEvent("Event:Fechar_Painel", true) addEventHandler("Event:Fechar_Painel", getRootElement(), fechar_painel) end end --<><><><><SERVER-SIDE><><><><> local marker = createMarker (2035.43018, 1499.35742, 10.82031 -1, "cylinder", 1.5 ,50,100,100) function abrir_painel (hitElement) if getElementType(hitElement) == "player" then triggerClientEvent(hitElement, "Event:Abrir_Painel", hitElement) end end addEventHandler("onMarkerHit", marker, abrir_painel) function fechar_painel (leaveElement) if getElementType(leaveElement) == "player" then triggerClientEvent(leaveElement, "Event:Fechar_Painel", leaveElement) outputChatBox("Teste", source, 0, 154, 255) end end addEventHandler("onMarkerLeave", marker, fechar_painel) Me perdoe se utilizei algum recurso de forma errada Edited March 28, 2020 by Gustavo Freire Link to comment
Angelo Pereira Posted March 28, 2020 Share Posted March 28, 2020 Basicamente, seu erro diz o seguinte : Foi enviado um trigger do server-side para o client-side , porem, quando foi chamado esse evento, não foi encontrado no seu client-side, porquê? está dentro de uma função. Modo Errado (O que você fez). function fechar_painel () if painel == true then painel = false removeEventHandler("onClientRender", getRootElement(), dx_Painel) addEvent("Event:Fechar_Painel", true) --/> O ERRO ESTA AQUI ! addEventHandler("Event:Fechar_Painel", getRootElement(), fechar_painel) --/> O ERRO ESTA AQUI ! end end Modo Correto. function fechar_painel () if painel == true then painel = false removeEventHandler("onClientRender", getRootElement(), dx_Painel) end end addEvent("Event:Fechar_Painel", true) addEventHandler("Event:Fechar_Painel", getRootElement(), fechar_painel) 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