beast99 Posted August 30, 2019 Share Posted August 30, 2019 Bom dia, estou fazendo meu sistema de porte de armas, com o botão em gui no alpha 0, mas, parece que o triggerServerEvent não funciona, fiz o sistema de fechar no client funcionou de boa, agora quando clico no adquirir porte, ele não faz simplesmente nada. (no script abaixo vou deixar com alpha) Client Side: local screenW,screenH = guiGetScreenSize() local resW, resH = 1366,768 local x, y = (screenW/resW), (screenH/resH) local render = false local Porte = createMarker(296.087, -38.088, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior(Porte, 1) function botoes() local botonfechar = guiCreateButton(875, 152, 42, 37,"",false) guiSetAlpha(botonfechar,0) local porte = guiCreateButton(418, 467, 240, 103,"",false) guiSetAlpha(porte,0) local glock = guiCreateButton(668, 467, 240, 103,"",false) guiSetAlpha(glock,0) addEventHandler("onClientGUIClick",botonfechar, function() removeEventHandler("onClientRender",root,panel) guiSetVisible(botonfechar,false) guiSetVisible(porte,false) guiSetVisible(glock,false) showCursor(false) end) end addEventHandler("onClientGUIClick", porte, clickarporte) function clickarporte() triggerServerEvent ("porte",getLocalPlayer(),porte) end addEventHandler("onClientGUIClick", glock, glockear) function glockear() triggerServerEvent ("comprarglock",getLocalPlayer(),comprarglock) end function panel() dxDrawRectangle(395, 155, 523, 436, tocolor(0, 0, 0, 126), false) dxDrawLine(395 - 1, 152 - 1, 395 - 1, 189, tocolor(79, 0, 0, 208), 1, false) dxDrawLine(395 - 1, 189, 918, 189, tocolor(79, 0, 0, 208), 1, false) dxDrawLine(918, 189, 918, 152 - 1, tocolor(79, 0, 0, 208), 1, false) dxDrawRectangle(395, 152, 523, 37, tocolor(0, 0, 0, 208), false) dxDrawText("PORTE DE ARMAS", 393, 148, 918, 189, tocolor(255, 255, 255, 255), 1.20, "sans", "center", "center", false, false, false, false, false) dxDrawRectangle(413, 199, 489, 245, tocolor(0, 0, 0, 69), false) dxDrawText("LEMBRANDO, O PORTE DE ARMAS APENAS COBRE A GLOCK, E PARA ADQUIRIR A MESMA, TÉRA QUE A COMPRAR, A GLOCK CUSTA 100K POR SER LEGAL.", 416, 197, 902, 444, tocolor(255, 255, 255, 255), 1.50, "default", "center", "center", false, true, false, false, false) dxDrawRectangle(875, 152, 42, 37, tocolor(0, 0, 0, 186), false) dxDrawText("ADQUIRIR PORTE", 418, 463, 658, 570, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false) dxDrawText("ADQUIRIR GLOCK", 669, 465, 908, 570, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false) dxDrawText("X", 876, 148, 916, 188, tocolor(255, 255, 255, 255), 1.30, "default", "center", "center", false, false, false, false, false) end function markerPanel (hitPlayer, matchingDimension) if (hitPlayer == localPlayer) then addEventHandler("onClientRender", root, panel) render = true showCursor(true) botoes() end end addEventHandler ("onClientMarkerHit", Porte, markerPanel) Server Side: local Entrar = createMarker (1310.129, -1368.674, 13.552-1, "cylinder", 1.2, 20, 70, 230, 95 ) local EntradaBlip = createBlipAttachedTo ( Entrar, 23 ) setBlipVisibleDistance ( EntradaBlip, 150 ) local Sair = createMarker(285.418, -40.954, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior ( Sair, 1 ) local Porte2 = createMarker(296.087, -38.088, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior(Porte2, 1) thePed = createPed(120, 296.103, -40.216, 1001.516) setElementInterior ( thePed, 1 )-- Creates a ped function cancelPedDamage() cancelEvent() -- Cancels the onClientPedDamage event end addEventHandler("onClientPedDamage", thePed, cancelPedDamage) function onmarker(marker,md) if (md) then if marker == Entrar then setTimer ( setElementInterior, 400, 1, source, 1 ) setTimer ( setElementPosition, 400, 1, source, 286.067, -39.416, 1001.516 ) setTimer ( setElementRotation, 900, 1, source, 0, 0, 358 ) fadeCamera ( source, false, 0.1, 0, 0, 0 ) setTimer ( fadeCamera, 900, 1, source , true, 0.5 ) end if marker == Sair then setTimer ( setElementInterior, 400, 1, source, 0 ) setTimer ( setElementDimension, 400, 1, source, 0 ) setTimer ( setElementPosition, 400, 1, source, 1310.116, -1371.456, 13.589 ) setTimer ( setElementRotation, 900, 1, source, 0, 0, 177 ) fadeCamera ( source, false, 0.1, 0, 0, 0 ) setTimer ( fadeCamera, 900, 1, source , true, 0.5 ) end end end addEventHandler("onPlayerMarkerHit",getRootElement(),onmarker) --------------------------- CODE ------------------------------------ addEvent("porte", true, porte3) addEventHandler("porte", getRootElement(), porte3) function porte3(source) if ( getPlayerMoney (source) >= 100000 ) then if getElementData(source, "Porte3") == false then takePlayerMoney(source, 300000) setElementData(source, "Porte3", true) outputChatBox("#727272[Porte]#ff0000Voce adquiriu o porte de arma", source, 255, 255, 255, true) else outputChatBox("#727272[Porte]#ff0000Voce já tem um porte de arma", source, 255, 255, 255, true) end end end Link to comment
Other Languages Moderators Lord Henry Posted August 30, 2019 Other Languages Moderators Share Posted August 30, 2019 (edited) Você está errando 2x aí. Primeiro que vc está criando os botões local e dai não consegue mais acessar eles fora daquela função onde foram criados. Logo, somente a função de fechar funciona, pois é a única que está dentro do escopo da função botoes. Crie os botões sem o local. Segundo que você oculta os botões ao fechar o painel, mas quando abre o painel você cria novos botões. Isso faz com que vários botões invisíveis vão sendo criados e acumulados a medida que você abre e fecha o painel. Na função de fechar o painel, destrua os botões em vez disso. addEventHandler ("onClientGUIClick", botonfechar, function() removeEventHandler ("onClientRender", root, panel) destroyElement (botonfechar) destroyElement (porte) destroyElement (glock) botonfechar = nil porte = nil glock = nil showCursor (false) end) Você teria percebido isso se usasse /debugscript 3. Ele iria avisar que o botão não foi encontrado. Edited August 30, 2019 by Lord Henry 1 Link to comment
beast99 Posted August 30, 2019 Author Share Posted August 30, 2019 22 minutes ago, Lord Henry said: Você está errando 2x aí. Primeiro que vc está criando os botões local e dai não consegue mais acessar eles fora daquela função onde foram criados. Logo, somente a função de fechar funciona, pois é a única que está dentro do escopo da função botoes. Crie os botões sem o local. Segundo que você oculta os botões ao fechar o painel, mas quando abre o painel você cria novos botões. Isso faz com que vários botões invisíveis vão sendo criados e acumulados a medida que você abre e fecha o painel. Na função de fechar o painel, destrua os botões em vez disso. addEventHandler ("onClientGUIClick", botonfechar, function() removeEventHandler ("onClientRender", root, panel) destroyElement (botonfechar) destroyElement (porte) destroyElement (glock) botonfechar = nil porte = nil glock = nil showCursor (false) end) Você teria percebido isso se usasse /debugscript 3. Ele iria avisar que o botão não foi encontrado. Eu usei o debugscript, mas deve ter sido falta de atenção, vou testar assim que chegar em casa, valeu lord. Link to comment
beast99 Posted August 30, 2019 Author Share Posted August 30, 2019 Ai lord, cheguei em casa, fui testar, não funcionou, porque será? Client: local screenW,screenH = guiGetScreenSize() local resW, resH = 1366,768 local x, y = (screenW/resW), (screenH/resH) local render = false local Porte = createMarker(296.087, -38.088, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior(Porte, 1) function botoes() botonfechar = guiCreateButton(875, 152, 42, 37,"",false) guiSetAlpha(botonfechar,255) porte = guiCreateButton(418, 467, 240, 103,"",false) guiSetAlpha(porte,255) glock = guiCreateButton(668, 467, 240, 103,"",false) guiSetAlpha(glock,255) addEventHandler ("onClientGUIClick", botonfechar, function() removeEventHandler ("onClientRender", root, panel) destroyElement (botonfechar) destroyElement (porte) destroyElement (glock) botonfechar = nil porte = nil glock = nil showCursor (false) end) end addEventHandler("onClientGUIClick", porte, function() triggerServerEvent ("porte",getLocalPlayer(),porte) end) addEventHandler("onClientGUIClick", glock, glockear) function glockear() triggerServerEvent ("comprarglock",getLocalPlayer(),comprarglock) end function panel() dxDrawRectangle(395, 155, 523, 436, tocolor(0, 0, 0, 126), false) dxDrawLine(395 - 1, 152 - 1, 395 - 1, 189, tocolor(79, 0, 0, 208), 1, false) dxDrawLine(395 - 1, 189, 918, 189, tocolor(79, 0, 0, 208), 1, false) dxDrawLine(918, 189, 918, 152 - 1, tocolor(79, 0, 0, 208), 1, false) dxDrawRectangle(395, 152, 523, 37, tocolor(0, 0, 0, 208), false) dxDrawText("PORTE DE ARMAS", 393, 148, 918, 189, tocolor(255, 255, 255, 255), 1.20, "sans", "center", "center", false, false, false, false, false) dxDrawRectangle(413, 199, 489, 245, tocolor(0, 0, 0, 69), false) dxDrawText("LEMBRANDO, O PORTE DE ARMAS APENAS COBRE A GLOCK, E PARA ADQUIRIR A MESMA, TÉRA QUE A COMPRAR, A GLOCK CUSTA 100K POR SER LEGAL.", 416, 197, 902, 444, tocolor(255, 255, 255, 255), 1.50, "default", "center", "center", false, true, false, false, false) dxDrawRectangle(875, 152, 42, 37, tocolor(0, 0, 0, 186), false) dxDrawText("ADQUIRIR PORTE", 418, 463, 658, 570, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false) dxDrawText("ADQUIRIR GLOCK", 669, 465, 908, 570, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false) dxDrawText("X", 876, 148, 916, 188, tocolor(255, 255, 255, 255), 1.30, "default", "center", "center", false, false, false, false, false) end function markerPanel (hitPlayer, matchingDimension) if (hitPlayer == localPlayer) then addEventHandler("onClientRender", root, panel) render = true showCursor(true) botoes() end end addEventHandler ("onClientMarkerHit", Porte, markerPanel) Server: local Entrar = createMarker (1310.129, -1368.674, 13.552-1, "cylinder", 1.2, 20, 70, 230, 95 ) local EntradaBlip = createBlipAttachedTo ( Entrar, 23 ) setBlipVisibleDistance ( EntradaBlip, 150 ) local Sair = createMarker(285.418, -40.954, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior ( Sair, 1 ) local Porte2 = createMarker(296.087, -38.088, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior(Porte2, 1) thePed = createPed(120, 296.103, -40.216, 1001.516) setElementInterior ( thePed, 1 )-- Creates a ped function cancelPedDamage() cancelEvent() -- Cancels the onClientPedDamage event end addEventHandler("onClientPedDamage", thePed, cancelPedDamage) function onmarker(marker,md) if (md) then if marker == Entrar then setTimer ( setElementInterior, 400, 1, source, 1 ) setTimer ( setElementPosition, 400, 1, source, 286.067, -39.416, 1001.516 ) setTimer ( setElementRotation, 900, 1, source, 0, 0, 358 ) fadeCamera ( source, false, 0.1, 0, 0, 0 ) setTimer ( fadeCamera, 900, 1, source , true, 0.5 ) end if marker == Sair then setTimer ( setElementInterior, 400, 1, source, 0 ) setTimer ( setElementDimension, 400, 1, source, 0 ) setTimer ( setElementPosition, 400, 1, source, 1310.116, -1371.456, 13.589 ) setTimer ( setElementRotation, 900, 1, source, 0, 0, 177 ) fadeCamera ( source, false, 0.1, 0, 0, 0 ) setTimer ( fadeCamera, 900, 1, source , true, 0.5 ) end end end addEventHandler("onPlayerMarkerHit",getRootElement(),onmarker) --------------------------- CODE ------------------------------------ addEvent("porte", true) addEventHandler("porte", root, function(source) if ( getPlayerMoney (source) >= 100000 ) then if getElementData(source, "Porte") == false then takePlayerMoney(source, 300000) setElementData(source, "Porte3", true) outputChatBox("#727272[Porte]#ff0000Voce adquiriu o porte de arma", source, 255, 255, 255, true) else outputChatBox("#727272[Porte]#ff0000Voce já tem um porte de arma", source, 255, 255, 255, true) end end end) Link to comment
Other Languages Moderators Lord Henry Posted August 30, 2019 Other Languages Moderators Share Posted August 30, 2019 Qual erro aparece no /debugscript 3? 1 Link to comment
beast99 Posted August 30, 2019 Author Share Posted August 30, 2019 https://imgur.com/wYjSRah esse é o que aparece, e eu não percebi o porquê.. Link to comment
DNL291 Posted August 30, 2019 Share Posted August 30, 2019 Os botões estão sendo criados depois, então vai retornar um valor nulo. Coloque os eventos junto com a função que está criando os botões. 1 Link to comment
Other Languages Moderators Lord Henry Posted August 30, 2019 Other Languages Moderators Share Posted August 30, 2019 Ele está dizendo que os botões porte e glock não existem. 1 Link to comment
beast99 Posted August 31, 2019 Author Share Posted August 31, 2019 (edited) 13 hours ago, Lord Henry said: Ele está dizendo que os botões porte e glock não existem. Voltando, agora ele está dizendo o seguinte: https://imgur.com/FwmS0BE Eu sei que tem a ver com o source, mas não consegui resolver denovo. Server Side: local Entrar = createMarker (1310.129, -1368.674, 13.552-1, "cylinder", 1.2, 20, 70, 230, 95 ) local EntradaBlip = createBlipAttachedTo ( Entrar, 23 ) setBlipVisibleDistance ( EntradaBlip, 150 ) local Sair = createMarker(285.418, -40.954, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior ( Sair, 1 ) local Porte2 = createMarker(296.087, -38.088, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior(Porte2, 1) thePed = createPed(120, 296.103, -40.216, 1001.516) setElementInterior ( thePed, 1 )-- Creates a ped function cancelPedDamage() cancelEvent() -- Cancels the onClientPedDamage event end addEventHandler("onClientPedDamage", thePed, cancelPedDamage) function onmarker(marker,md) if (md) then if marker == Entrar then setTimer ( setElementInterior, 400, 1, source, 1 ) setTimer ( setElementPosition, 400, 1, source, 286.067, -39.416, 1001.516 ) setTimer ( setElementRotation, 900, 1, source, 0, 0, 358 ) fadeCamera ( source, false, 0.1, 0, 0, 0 ) setTimer ( fadeCamera, 900, 1, source , true, 0.5 ) end if marker == Sair then setTimer ( setElementInterior, 400, 1, source, 0 ) setTimer ( setElementDimension, 400, 1, source, 0 ) setTimer ( setElementPosition, 400, 1, source, 1310.116, -1371.456, 13.589 ) setTimer ( setElementRotation, 900, 1, source, 0, 0, 177 ) fadeCamera ( source, false, 0.1, 0, 0, 0 ) setTimer ( fadeCamera, 900, 1, source , true, 0.5 ) end end end addEventHandler("onPlayerMarkerHit",getRootElement(),onmarker) --------------------------- CODE ------------------------------------ addEvent("porte", true) addEventHandler("porte", root, function(player) if getElementData(player, "Porte") == false then setElementData(player, "Porte", true) outputChatBox("#727272[Porte]#ff0000Voce adquiriu o porte de arma", source, 255, 255, 255, true) else outputChatBox("#727272[Porte]#ff0000Voce já tem um porte de arma", source, 255, 255, 255, true) end end ) Client Side: local screenW,screenH = guiGetScreenSize() local resW, resH = 1366,768 local x, y = (screenW/resW), (screenH/resH) local render = false local Porte = createMarker(296.087, -38.088, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior(Porte, 1) function botoes() botonfechar = guiCreateButton(875, 152, 42, 37,"",false) guiSetAlpha(botonfechar,255) porte = guiCreateButton(418, 467, 240, 103,"",false) guiSetAlpha(porte,255) glock = guiCreateButton(668, 467, 240, 103,"",false) guiSetAlpha(glock,255) addEventHandler("onClientGUIClick", porte, function() triggerServerEvent ("porte",getLocalPlayer(), comprar) end) addEventHandler("onClientGUIClick", glock, function() triggerServerEvent ("comprarglock",getLocalPlayer(),comprarglock) end) addEventHandler ("onClientGUIClick", botonfechar, function() removeEventHandler ("onClientRender", root, panel) destroyElement (botonfechar) destroyElement (porte) destroyElement (glock) botonfechar = nil porte = nil glock = nil showCursor (false) end) end addEventHandler("onClientGUIClick", porte, function() triggerServerEvent ("porte",getLocalPlayer(),porte) end) addEventHandler("onClientGUIClick", glock, glockear) function glockear() triggerServerEvent ("comprarglock",getLocalPlayer(),comprarglock) end function panel() dxDrawRectangle(395, 155, 523, 436, tocolor(0, 0, 0, 126), false) dxDrawLine(395 - 1, 152 - 1, 395 - 1, 189, tocolor(79, 0, 0, 208), 1, false) dxDrawLine(395 - 1, 189, 918, 189, tocolor(79, 0, 0, 208), 1, false) dxDrawLine(918, 189, 918, 152 - 1, tocolor(79, 0, 0, 208), 1, false) dxDrawRectangle(395, 152, 523, 37, tocolor(0, 0, 0, 208), false) dxDrawText("PORTE DE ARMAS", 393, 148, 918, 189, tocolor(255, 255, 255, 255), 1.20, "sans", "center", "center", false, false, false, false, false) dxDrawRectangle(413, 199, 489, 245, tocolor(0, 0, 0, 69), false) dxDrawText("LEMBRANDO, O PORTE DE ARMAS APENAS COBRE A GLOCK, E PARA ADQUIRIR A MESMA, TÉRA QUE A COMPRAR, A GLOCK CUSTA 100K POR SER LEGAL.", 416, 197, 902, 444, tocolor(255, 255, 255, 255), 1.50, "default", "center", "center", false, true, false, false, false) dxDrawRectangle(875, 152, 42, 37, tocolor(0, 0, 0, 186), false) dxDrawText("ADQUIRIR PORTE", 418, 463, 658, 570, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false) dxDrawText("ADQUIRIR GLOCK", 669, 465, 908, 570, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false) dxDrawText("X", 876, 148, 916, 188, tocolor(255, 255, 255, 255), 1.30, "default", "center", "center", false, false, false, false, false) end function markerPanel (hitPlayer, matchingDimension) if (hitPlayer == localPlayer) then addEventHandler("onClientRender", root, panel) render = true showCursor(true) botoes() end end addEventHandler ("onClientMarkerHit", Porte, markerPanel) Edited August 31, 2019 by MesaDowN Link to comment
beast99 Posted August 31, 2019 Author Share Posted August 31, 2019 Poderia alguém me ajudar? Peço desculpa estar sendo impaciente.. Link to comment
DNL291 Posted September 1, 2019 Share Posted September 1, 2019 Tente: local screenW,screenH = guiGetScreenSize() local resW, resH = 1366,768 local x, y = (screenW/resW), (screenH/resH) local render = false local Porte = createMarker(296.087, -38.088, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior(Porte, 1) function botoes() botonfechar = guiCreateButton(875, 152, 42, 37,"",false) guiSetAlpha(botonfechar,255) porte = guiCreateButton(418, 467, 240, 103,"",false) guiSetAlpha(porte,255) glock = guiCreateButton(668, 467, 240, 103,"",false) guiSetAlpha(glock,255) guiSetVisible(glock, false) guiSetVisible(porte, false) guiSetVisible(botonfechar, false) addEventHandler("onClientGUIClick", porte, function() triggerServerEvent ("porte",getLocalPlayer(), comprar) end) addEventHandler("onClientGUIClick", glock, function() triggerServerEvent ("comprarglock",getLocalPlayer(),comprarglock) end) addEventHandler ("onClientGUIClick", botonfechar, function() removeEventHandler ("onClientRender", root, panel) destroyElement (botonfechar) destroyElement (porte) destroyElement (glock) botonfechar = nil porte = nil glock = nil showCursor (false) end) end function panel() dxDrawRectangle(395, 155, 523, 436, tocolor(0, 0, 0, 126), false) dxDrawLine(395 - 1, 152 - 1, 395 - 1, 189, tocolor(79, 0, 0, 208), 1, false) dxDrawLine(395 - 1, 189, 918, 189, tocolor(79, 0, 0, 208), 1, false) dxDrawLine(918, 189, 918, 152 - 1, tocolor(79, 0, 0, 208), 1, false) dxDrawRectangle(395, 152, 523, 37, tocolor(0, 0, 0, 208), false) dxDrawText("PORTE DE ARMAS", 393, 148, 918, 189, tocolor(255, 255, 255, 255), 1.20, "sans", "center", "center", false, false, false, false, false) dxDrawRectangle(413, 199, 489, 245, tocolor(0, 0, 0, 69), false) dxDrawText("LEMBRANDO, O PORTE DE ARMAS APENAS COBRE A GLOCK, E PARA ADQUIRIR A MESMA, TÉRA QUE A COMPRAR, A GLOCK CUSTA 100K POR SER LEGAL.", 416, 197, 902, 444, tocolor(255, 255, 255, 255), 1.50, "default", "center", "center", false, true, false, false, false) dxDrawRectangle(875, 152, 42, 37, tocolor(0, 0, 0, 186), false) dxDrawText("ADQUIRIR PORTE", 418, 463, 658, 570, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false) dxDrawText("ADQUIRIR GLOCK", 669, 465, 908, 570, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false) dxDrawText("X", 876, 148, 916, 188, tocolor(255, 255, 255, 255), 1.30, "default", "center", "center", false, false, false, false, false) end function markerPanel (hitPlayer, matchingDimension) if (hitPlayer == localPlayer) then addEventHandler("onClientRender", root, panel) render = true showCursor(true) guiSetVisible(glock, true) guiSetVisible(porte, true) guiSetVisible(botonfechar, true) end end addEventHandler ("onClientMarkerHit", Porte, markerPanel) server local Entrar = createMarker (1310.129, -1368.674, 13.552-1, "cylinder", 1.2, 20, 70, 230, 95 ) local EntradaBlip = createBlipAttachedTo ( Entrar, 23 ) setBlipVisibleDistance ( EntradaBlip, 150 ) local Sair = createMarker(285.418, -40.954, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior ( Sair, 1 ) local Porte2 = createMarker(296.087, -38.088, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior(Porte2, 1) thePed = createPed(120, 296.103, -40.216, 1001.516) setElementInterior ( thePed, 1 )-- Creates a ped function cancelPedDamage() cancelEvent() -- Cancels the onClientPedDamage event end addEventHandler("onClientPedDamage", thePed, cancelPedDamage) function onmarker(marker,md) if (md) then if marker == Entrar then setTimer ( setElementInterior, 400, 1, source, 1 ) setTimer ( setElementPosition, 400, 1, source, 286.067, -39.416, 1001.516 ) setTimer ( setElementRotation, 900, 1, source, 0, 0, 358 ) fadeCamera ( source, false, 0.1, 0, 0, 0 ) setTimer ( fadeCamera, 900, 1, source , true, 0.5 ) end if marker == Sair then setTimer ( setElementInterior, 400, 1, source, 0 ) setTimer ( setElementDimension, 400, 1, source, 0 ) setTimer ( setElementPosition, 400, 1, source, 1310.116, -1371.456, 13.589 ) setTimer ( setElementRotation, 900, 1, source, 0, 0, 177 ) fadeCamera ( source, false, 0.1, 0, 0, 0 ) setTimer ( fadeCamera, 900, 1, source , true, 0.5 ) end end end addEventHandler("onPlayerMarkerHit",getRootElement(),onmarker) --------------------------- CODE ------------------------------------ addEvent("porte", true) addEventHandler("porte", root, function() if getElementData(client, "Porte") == false then setElementData(client, "Porte", true) outputChatBox("#727272[Porte]#ff0000Voce adquiriu o porte de arma", client, 255, 255, 255, true) else outputChatBox("#727272[Porte]#ff0000Voce já tem um porte de arma", client, 255, 255, 255, true) end end ) 1 Link to comment
beast99 Posted September 1, 2019 Author Share Posted September 1, 2019 4 hours ago, DNL291 said: Tente: local screenW,screenH = guiGetScreenSize() local resW, resH = 1366,768 local x, y = (screenW/resW), (screenH/resH) local render = false local Porte = createMarker(296.087, -38.088, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior(Porte, 1) function botoes() botonfechar = guiCreateButton(875, 152, 42, 37,"",false) guiSetAlpha(botonfechar,255) porte = guiCreateButton(418, 467, 240, 103,"",false) guiSetAlpha(porte,255) glock = guiCreateButton(668, 467, 240, 103,"",false) guiSetAlpha(glock,255) guiSetVisible(glock, false) guiSetVisible(porte, false) guiSetVisible(botonfechar, false) addEventHandler("onClientGUIClick", porte, function() triggerServerEvent ("porte",getLocalPlayer(), comprar) end) addEventHandler("onClientGUIClick", glock, function() triggerServerEvent ("comprarglock",getLocalPlayer(),comprarglock) end) addEventHandler ("onClientGUIClick", botonfechar, function() removeEventHandler ("onClientRender", root, panel) destroyElement (botonfechar) destroyElement (porte) destroyElement (glock) botonfechar = nil porte = nil glock = nil showCursor (false) end) end function panel() dxDrawRectangle(395, 155, 523, 436, tocolor(0, 0, 0, 126), false) dxDrawLine(395 - 1, 152 - 1, 395 - 1, 189, tocolor(79, 0, 0, 208), 1, false) dxDrawLine(395 - 1, 189, 918, 189, tocolor(79, 0, 0, 208), 1, false) dxDrawLine(918, 189, 918, 152 - 1, tocolor(79, 0, 0, 208), 1, false) dxDrawRectangle(395, 152, 523, 37, tocolor(0, 0, 0, 208), false) dxDrawText("PORTE DE ARMAS", 393, 148, 918, 189, tocolor(255, 255, 255, 255), 1.20, "sans", "center", "center", false, false, false, false, false) dxDrawRectangle(413, 199, 489, 245, tocolor(0, 0, 0, 69), false) dxDrawText("LEMBRANDO, O PORTE DE ARMAS APENAS COBRE A GLOCK, E PARA ADQUIRIR A MESMA, TÉRA QUE A COMPRAR, A GLOCK CUSTA 100K POR SER LEGAL.", 416, 197, 902, 444, tocolor(255, 255, 255, 255), 1.50, "default", "center", "center", false, true, false, false, false) dxDrawRectangle(875, 152, 42, 37, tocolor(0, 0, 0, 186), false) dxDrawText("ADQUIRIR PORTE", 418, 463, 658, 570, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false) dxDrawText("ADQUIRIR GLOCK", 669, 465, 908, 570, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false) dxDrawText("X", 876, 148, 916, 188, tocolor(255, 255, 255, 255), 1.30, "default", "center", "center", false, false, false, false, false) end function markerPanel (hitPlayer, matchingDimension) if (hitPlayer == localPlayer) then addEventHandler("onClientRender", root, panel) render = true showCursor(true) guiSetVisible(glock, true) guiSetVisible(porte, true) guiSetVisible(botonfechar, true) end end addEventHandler ("onClientMarkerHit", Porte, markerPanel) server local Entrar = createMarker (1310.129, -1368.674, 13.552-1, "cylinder", 1.2, 20, 70, 230, 95 ) local EntradaBlip = createBlipAttachedTo ( Entrar, 23 ) setBlipVisibleDistance ( EntradaBlip, 150 ) local Sair = createMarker(285.418, -40.954, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior ( Sair, 1 ) local Porte2 = createMarker(296.087, -38.088, 1001.516-1.1, "cylinder", 1.2, 20, 70, 230, 95) setElementInterior(Porte2, 1) thePed = createPed(120, 296.103, -40.216, 1001.516) setElementInterior ( thePed, 1 )-- Creates a ped function cancelPedDamage() cancelEvent() -- Cancels the onClientPedDamage event end addEventHandler("onClientPedDamage", thePed, cancelPedDamage) function onmarker(marker,md) if (md) then if marker == Entrar then setTimer ( setElementInterior, 400, 1, source, 1 ) setTimer ( setElementPosition, 400, 1, source, 286.067, -39.416, 1001.516 ) setTimer ( setElementRotation, 900, 1, source, 0, 0, 358 ) fadeCamera ( source, false, 0.1, 0, 0, 0 ) setTimer ( fadeCamera, 900, 1, source , true, 0.5 ) end if marker == Sair then setTimer ( setElementInterior, 400, 1, source, 0 ) setTimer ( setElementDimension, 400, 1, source, 0 ) setTimer ( setElementPosition, 400, 1, source, 1310.116, -1371.456, 13.589 ) setTimer ( setElementRotation, 900, 1, source, 0, 0, 177 ) fadeCamera ( source, false, 0.1, 0, 0, 0 ) setTimer ( fadeCamera, 900, 1, source , true, 0.5 ) end end end addEventHandler("onPlayerMarkerHit",getRootElement(),onmarker) --------------------------- CODE ------------------------------------ addEvent("porte", true) addEventHandler("porte", root, function() if getElementData(client, "Porte") == false then setElementData(client, "Porte", true) outputChatBox("#727272[Porte]#ff0000Voce adquiriu o porte de arma", client, 255, 255, 255, true) else outputChatBox("#727272[Porte]#ff0000Voce já tem um porte de arma", client, 255, 255, 255, true) end end ) Opa DNL, funcionou sim, apenas tive que dar uma mechida em alguns negocios, valeu amigão 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