-
Posts
83 -
Joined
-
Last visited
Everything posted by noonbr
-
hot [DUVIDA] Problema em definir um elemento.
noonbr replied to noonbr's topic in Programação em Lua
@DNL291, foi! Vlw mesmo -
Boa noite, estou com um problema referente a elemento. CLIENT-SIDE: function venderAK(button) if button == "left" then outputChatBox("O jogador "..getPlayerName(localPlayer).." vendeu uma arma ilegal e está procurado agora.") guiSetEnabled(source, false) triggerServerEvent("dArma", resourceRoot) end end addEventHandler("onClientGUIClick", botao1, venderAK, false) SERVER-SIDE: function droparArma(thePlayer) nivel = getPlayerWantedLevel(thePlayer) nivel = tonumber(nivel + 1) takeWeapon(thePlayer, 30) setPlayerWantedLevel(thePlayer, nivel) end addEvent("dArma", true) addEventHandler("dArma", resourceRoot, droparArma) Erro: https://prnt.sc/py98xo
-
script [DUVIDA] Como chamar função de server-side no client-side?
noonbr replied to noonbr's topic in Programação em Lua
- 2 replies
-
- duvida
- server-side
-
(and 4 more)
Tagged with:
-
Boa tarde, estou com uma dúvida. Quero fazer com que o jogador perca a arma após clicar em um botão CEGUI, mas não consigo utilizando takeWeapon, pois esta é uma função server-side. Queria saber como posso executar essa função em server-side. Sei que tem jeito, mas como sou iniciante não tenho conhecimento. Quem puder me ajudar receberá Thanks! Obrigado pela compreensão
- 2 replies
-
- duvida
- server-side
-
(and 4 more)
Tagged with:
-
O seu preço vc coloca na hora da venda e ele aceita ou o dinheiro é por fora (p.ex: /enviardinheiro)?
-
Boa noite, fiz um script quase completo, queria perguntar se existe algumas trocas que eu poderia fazer para deixá-lo mais curto e/ou otimizado. SERVER-SIDE: entrada = createMarker(1411.7902832031, -1699.7880859375, 14.1, "arrow", 1, 255,255,0, 50) saida = createMarker(-2029.7740478516, -119.3343963623, 1035.7, "arrow", 1, 255,255,0, 50) cnh = createMarker(-2033.0969238281,-117.43886566162,1034.2, "cylinder", 1, 255,0,0, 50) etapas = { (createMarker(-868.33447265625,-1079.029296875,94.109962463379, "checkpoint", 0, 255,0,0, 20)), (createMarker(-798.85778808594,-1009.9039916992,81.114715576172, "checkpoint", 0, 255,0,0, 20)), (createMarker(-623.44805908203,-991.40704345703,66.213768005371, "checkpoint", 0, 255,0,0, 20)), (createMarker(-526.03784179688,-904.98547363281,55.71215057373, "checkpoint", 0, 255,0,0, 20)), (createMarker(-385.86874389648,-837.59167480469,47.206745147705, "checkpoint", 0, 255,0,0, 20)), (createMarker(-298.58383178711,-875.92852783203,46.712970733643, "checkpoint", 0, 255,0,0, 20)), (createMarker(-342.224609375,-780.23712158203,31.194166183472, "checkpoint", 0, 255,0,0, 20)) } carro = createVehicle(402, 0,0,0) function marker() setElementInterior(saida, 3) setElementInterior(cnh, 3) end marker() function mensagem(hitElement) if getElementData(hitElement, "cnh-carro") == false then outputChatBox("| DETRAN | digite #ff0000/cnh #ffffffpara fazer a sua.", hitElement, 255,255,255, true) else outputChatBox("| DETRAN | você já possui a carteira de habilitação.", hitElement, 255,255,255, true) end end addEventHandler("onMarkerHit", cnh, mensagem) function inicio(thePlayer) if isElementWithinMarker(thePlayer, cnh) and getElementData(thePlayer, "cnh-carro") == false then fadeCamera(thePlayer, false) setTimer ( function ( ... ) setElementInterior(thePlayer, 0) setElementPosition(thePlayer, -876.94409179688,-1112.4317626953,98.609375) setElementInterior(carro, 0) setElementPosition(carro, -876.94409179688,-1112.4317626953,98.609375) warpPedIntoVehicle(thePlayer, carro) setMarkerSize(etapas[1], 3) end, 1000, 1, thePlayer) setTimer ( function ( ... ) fadeCamera(thePlayer, true) end, 2000, 1, thePlayer) end end addCommandHandler("cnh", inicio) function etapa1(hitElement) setMarkerSize(etapas[1], 0) setMarkerSize(etapas[2], 3) end addEventHandler("onMarkerHit", etapas[1], etapa1) function etapa2(hitElement) setMarkerSize(etapas[2], 0) setMarkerSize(etapas[3], 3) end addEventHandler("onMarkerHit", etapas[2], etapa2) function etapa3(hitElement) setMarkerSize(etapas[3], 0) setMarkerSize(etapas[4], 3) end addEventHandler("onMarkerHit", etapas[3], etapa3) function etapa4(hitElement) setMarkerSize(etapas[4], 0) setMarkerSize(etapas[5], 3) end addEventHandler("onMarkerHit", etapas[4], etapa4) function etapa5(hitElement) setMarkerSize(etapas[5], 0) setMarkerSize(etapas[6], 3) end addEventHandler("onMarkerHit", etapas[5], etapa5) function etapa6(hitElement) setMarkerSize(etapas[6], 0) setMarkerSize(etapas[7], 3) end addEventHandler("onMarkerHit", etapas[6], etapa6) function etapa7(hitElement) setMarkerSize(etapas[7], 0) outputChatBox("| INSTRUTOR DIZ: você concluiu o teste camarada, pegue sua carteira de habilitação.", hitElement) destroyElement(carro) fadeCamera(hitElement, false) setTimer ( function () setElementInterior(hitElement, 3) setElementPosition(hitElement, -2029.2668457031,-116.76811218262,1035.171875) setElementData(hitElement,"cnh-carro", true) fadeCamera(hitElement, true) end, 2000, 1, hitElement) end addEventHandler("onMarkerHit", etapas[7], etapa7) function aoSair(thePlayer) setMarkerSize(etapas[1], 0) outputChatBox("| INSTRUTOR DIZ: você saiu do veículo e não terminou a prova.", thePlayer) destroyElement(carro) fadeCamera(thePlayer, false) setTimer ( function () setElementInterior(thePlayer, 3) setElementPosition(thePlayer, -2029.2668457031,-116.76811218262,1035.171875) fadeCamera(thePlayer, true) end, 2000, 1, thePlayer) end addEventHandler("onVehicleExit", getRootElement(), aoSair) Depois pretendo fazer o CLIENT-SIDE em CEGUI. Obrigado pela compreensão
-
O seu é editável? Copie as linhas de código dele aqui.
-
script [AJUDA] Mesmo clicando na window executa o botão.
noonbr replied to noonbr's topic in Programação em Lua
Perdão, kk. pedestre = createPed(46, 1504.4595947266,-1709.5983886719,14.046875, 270) setElementFrozen(pedestre, true) markerEmprego = createMarker(1504.5090332031,-1709.5562744141,14.046875, "cylinder", 1.5, 255,255,255, 0) janela = guiCreateWindow(0.37, 0.35, 0.25 , 0.2, "ENTREGADOR - desenvolvido por GOD", true, janela) botao1 = guiCreateButton(0, 0.7, 1.2, 0.20, "FECHAR CONVERSA", true, janela) botao2 = guiCreateButton(0, 0.2, 1.2 , 0.20, "PEGAR O EMPREGO", true, janela) botao3 = guiCreateButton(0, 0.45, 1.2 , 0.20, "SAIR DO EMPREGO", true, janela) guiWindowSetMovable(janela, false) guiWindowSetSizable(janela, false) guiSetVisible(janela, false) guiSetVisible(botao1, false) guiSetVisible(botao2, false) function cancelarAtaqueEmPed(attacker) cancelEvent() end addEventHandler("onClientPedDamage", getRootElement(), cancelarAtaqueEmPed) function pegarEmprego(hitPlayer) guiSetVisible(janela, true) guiSetVisible(botao1, true) guiSetVisible(botao2, true) showCursor(true) end addEventHandler("onClientMarkerHit", markerEmprego, pegarEmprego) function fecharConversa(button) if button == "left" then guiSetVisible(janela, false) guiSetVisible(botao1, false) guiSetVisible(botao2, false) outputChatBox("| ENTREGADOR | até mais, "..getPlayerName(localPlayer)..".") showCursor(false) end end addEventHandler("onClientGUIClick", botao1, fecharConversa) -
script [AJUDA] Mesmo clicando na window executa o botão.
noonbr posted a topic in Programação em Lua
Olá, o problema que estou enfrentado é que mesmo clicando na window, nas partes que não possuem botão, os dois botões estão sendo executado simultaneamente, mas não quero que isso aconteça, alguém consegue me ajudar? pedestre = createPed(46, 1504.4595947266,-1709.5983886719,14.046875, 270) setElementFrozen(pedestre, true) markerEmprego = createMarker(1504.5090332031,-1709.5562744141,14.046875, "cylinder", 1.5, 255,255,255, 0) janela = guiCreateWindow(0.37, 0.35, 0.25 , 0.2, "PEGAR EMPREGO", true) botao1 = guiCreateButton(0, 0.7, 1.2, 0.28, "FECHAR CONVERSA", true, janela) botao2 = guiCreateButton(0, 0.3, 1.2 , 0.28, "PEGAR O EMPREGO", true, janela) guiWindowSetMovable(janela, false) guiWindowSetSizable(janela, false) guiSetVisible(janela, false) guiSetVisible(botao1, false) guiSetVisible(botao2, false) function cancelarAtaqueEmPed(attacker) cancelEvent() end addEventHandler("onClientPedDamage", getRootElement(), cancelarAtaqueEmPed) function pegarEmprego(hitPlayer) guiSetVisible(janela, true) guiSetVisible(botao1, true) guiSetVisible(botao2, true) showCursor(true) outputChatBox("Olá mundo.") end addEventHandler("onClientMarkerHit", markerEmprego, pegarEmprego) Quem puder me ajudar receberá Thanks! O que está acontecendo: https://prnt.sc/ptvwl3 -
Iniciei no script faz pouco tempo. Queria saber qual é a função de for k,v (table) , para que serve, for só pega dois valores de uma tabela? Exemplos que posso utilizar com for , obrigado desde de já. Quem puder me ajuda receberá thanks.
-
Quando utilizo: function aoSair(player) outputChatBox("| AVISO | você tem 30 segundos para voltar ao veículo.", player, 255,255,255, true) setTimer (function ( ) destroyElement(source) end, 30000, 1) end addEventHandler("onVehicleExit", getRootElement(), aoSair) o veículo não se destrói. Erro: Expected element at argument 1, got nil. Imagino que o erro aconteça porquê depois do jogador sair, source não é mais veículo, mas não sei como resolver. Outra coisa, estou usando esse método de destruir porque não consigo achar outra opção (sou novato em script). Queria que o veículo retornasse ao seu lugar padrão depois de 30 segundos: pegarEmprego = createMarker(1847.2760009766,-1873.8081054688,12.878125, "cylinder", 2, 255,255,255, 100) ped = createPed(20, 1847.7249755859,-1873.9541015625,13.578125, 90, false) setElementFrozen(ped, true) function mule(BVOMule) car1 = createVehicle(414, 1780.3957519531,-1889.2502441406,13.38960647583,-0, 0, 268.3544921875) car2 = createVehicle(414, 1780.3957519531,-1889.2502441406-5,13.38960647583,-0, 0, 268.3544921875) car3 = createVehicle(414, 1780.3957519531,-1889.2502441406-10,13.38960647583,-0, 0, 268.3544921875) end addEventHandler("onResourceStart", resourceRoot, mule) function aoEntrar(player) skin = getElementModel(player) gEM = getElementModel(source) if ( gEM == 414 ) then if skin == 20 then if getElementData(player, "Entregador") then else outputChatBox("| SERVIÇO | você precisa estar com a skin.", player) cancelEvent() end else end end end addEventHandler( "onVehicleStartEnter", getRootElement(), aoEntrar ) function msgEmprego(hitElement) if getElementType(hitElement) == "player" then if getElementData(hitElement, "Entregador") == false then outputChatBox("#ffffff| EMPREGO | digite #ff0000/conversar #ffffffpara conversar com o entregador.", hitElement, 255,255,25, true) end end end addEventHandler("onMarkerHit", pegarEmprego, msgEmprego) function aoSair(player) outputChatBox("| AVISO | você tem 30 segundos para voltar ao veículo.", player, 255,255,255, true) setTimer (function ( ) destroyElement(source) end, 1000, 1) end addEventHandler("onVehicleExit", getRootElement(), aoSair) function conversarComEntregador(playerSource) if isElementWithinMarker(playerSource, pegarEmprego) then if getElementModel(playerSource) == 20 then outputChatBox("#ffffffENTREGADOR: você já está com a roupa de entregador, pode trabalhar.", playerSource, 255,255,255, true) else outputChatBox("#ffffffENTREGADOR: lhe dei a roupa de entregador, pode ir trabalhar.", playerSource, 255,255,255, true) setPlayerSkin(playerSource, 20) setElementData(playerSource, "Entregador", true) end end end addCommandHandler("conversar", conversarComEntregador)
-
@DNL291, obrigado, agora foi. É que como disse que era pra ser um valor float e estava como exemplo 0.0 (no wiki) achei que fosse de pequenos valores. Obrigado mesmo mano!
-
O problema que estou enfrentado é que estou conseguindo criar um ped(pedestre), mas não estou conseguindo rotacioná-lo. ped = createPed( 20 , 1847.7277832031 , -1873.6942138672 , 13.578125 , 0.01, false) Obs.: o quinto argumento deve ser um número float, tentei colocar vários outros (do que está no acima), como 0.1, 0.13, 1.5, 1.932 e a rotação não acontece.
-
Mas é que como o getElementType está abaixo do getPedOccupiedVehicle, eu imaginei que ao pegar o tipo do elemento de playerSource que está dentro do carro o tipo seria vehicle. Obrigado pela resposta, de qualquer modo, Thanks!
-
Quando utilizo isso: function elementType(playerSource) if getPedOccupiedVehicle(playerSource) then local gET = getElementType(playerSource) outputChatBox("O seu tipo é:"..gET..".", playerSource, 255,255,255, true) end end addCommandHandler("tipo", elementType) o resultado sai: player e não vehicle, por quê? Como faço para sair vehicle?
-
@Lord Henry, fala pra ele que não se deve utilizar source como parâmetro.
-
Olá, estou com dificuldades em algumas situações referente ao GUI. 1. Tentei utilizar o if (botao == "left") then mas acabou que nenhum botão executava a função; 2. Tento utilizar o elemento button na segunda função, mas não consigo (Expected element at argument 2, got nil); 3. Quando clico na caixa de texto para digitar o texto ele envia o texto, sem ao menos me esperar digitar, ele envia no outputChatBox o que estava pré-definido. function openButton() if (getElementData(localPlayer, "opennedButton")) then outputChatBox("| ERRO | O botão já está aberto.") else outputChatBox("Você abriu o botão.") setElementData(localPlayer, "opennedButton", true) showCursor(true) botao = guiCreateButton(0.5, 0.5, 0.09, 0.05,"Enviar mensagem", true) botaoedit = guiCreateEdit(0.59, 0.5, 0.15, 0.05, "Escreva uma mensagem aqui.", true) guiEditSetMaxLength(botaoedit, 37) end end addCommandHandler("abrirbotao", openButton) function breakButton() setElementData(localPlayer,"opennedButton", false) end addCommandHandler("tirar", breakButton) function onClickButton(button) if (botao == "left") then guiSetVisible(botao, false) guiSetVisible(botaoedit, false) showCursor(false) setElementData(localPlayer, "opennedButton", false) texto = guiGetText(botaoedit) outputChatBox(texto) end end addEventHandler("onClientGUIClick", button, onClickButton) Obrigado pela atenção e compreensão de todos. Quem puder me ajudar irá receber Thanks!
-
[AJUDA] Existe removeElementData no lado do cliente?
noonbr replied to noonbr's topic in Programação em Lua
Obrigado, se eu utilizar em vez de removeElementData e usar o false ele remove também? -
Boa noite, estou tendo problemas em remover um elemento do lado do cliente, estou usando: function button() local data = getElementData(localPlayer, "abriu") if (data == true ) then outputChatBox("Você já está com o painel aberto.") else setElementData(localPlayer, "abriu", true) buttonss = guiCreateButton(0.5, 0.2, 0.2, 0.05, "Olá Mundo!", true) showCursor(true) end end addCommandHandler("button", button) function hideCursor(button, state, absoluteX, absoluteY) destroyElement(buttonss) showCursor(false) outputChatBox("Olá mundo!") removeElementData(localPlayer, "abriu") end addEventHandler("onClientGUIClick", root, hideCursor) Estava indo tão bem, até porque o setElementData está funcionando corretamente, já o amigo removeElementData não quer funcionar em client-side, alguém pode me ajudar? Agradeço desde já a compreensão :v
-
[AJUDA] Como limitar o isElementWithinMarker no Client?
noonbr replied to noonbr's topic in Programação em Lua
O problema é que esses dxDraw aparece em qualquer marker que eu passo, queria limitar somente a um marker específico. -
Queria saber como posso usar o isElementWithinMarker, não posso utilizar source como parâmetro, obrigado Lord Henry kkk. Realmente estou travado, tentei utilizar player como primeiro argumento do isElementWith.... mas não deu certo. local plugMarker1 = createMarker (1534.4379882813,-1675.3631591797,13.3828125, "cylinder", 1, 255, 255, 255, 100) function plug(startedResource) setElementInterior(plugMarker1, 6) setElementPosition(plugMarker1, 254.49601745605, 67.918395996094, 1005.7) end addEventHandler("onClientResourceStart", root, plug) function windowPlug(hitPlayer) local x,y = guiGetScreenSize() function textPlug() local level = getPlayerWantedLevel(player) if (level >= 1 ) then dxDrawRectangle(x/4, y/3, x/2, y/4.9, tocolor(0,0,0, 100)) dxDrawRectangle(x/4, y/3.018, x/2, y/10, tocolor(0,0,0, 150)) dxDrawText("DELEGACIA DE POLÍCIA - LOS SANTOS", x/3.3, y/2.85, x/2, y/2, tocolor(0,0,255), 1.7, 1.7, "pricedown", "left", "top") dxDrawText("VOCÊ ESTÁ PROCURADO", x/2.75, y/2.2, x/2, y/2, tocolor(255,255,255), 1.7, 1.7, "pricedown", "left", "top") else dxDrawRectangle(x/4, y/3, x/2, y/4.9, tocolor(0,0,0, 100)) dxDrawRectangle(x/4, y/3.018, x/2, y/10, tocolor(0,0,0, 150)) dxDrawText("DELEGACIA DE POLÍCIA - LOS SANTOS", x/3.3, y/2.85, x/2, y/2, tocolor(0,0,255), 1.7, 1.7, "pricedown", "left", "top") dxDrawText("VOCÊ ESTÁ PROCURADO", x/2.9, y/2.2, x/2, y/2, tocolor(255,255,255), 1.7, 1.7, "pricedown", "left", "top") dxDrawText("NÃO", x/2.45, y/2.2, x/2, y/2, tocolor(255,0,0), 1.7, 1.7, "pricedown", "left", "top") end end addEventHandler("onClientRender", root, textPlug) end addEventHandler("onClientMarkerHit", root, windowPlug) Vlw Lord Henry, tmj meu mano.
-
When the usage is the same as the vehicle is teleported along with me, the isPedInVehicle is false. local tp1 = createMarker(1530.607421875,-1685.4215087891,13.3828125, "cylinder", 1, 255,255,255,100) function msg(hitElement) if (isPedInVehicle(hitElement) == false) then outputChatBox("Hello World!", hitElement) setElementPosition(hitElement, 1522.2706298828,-1687.1689453125,13.546875, true) end end addEventHandler("onMarkerHit", tp1, msg) Even if I use a car in the marker it is teleported but the other functions do not occur, just the setElementPosition.
-
Olá, estou tendo um problema que talvez seja fácil de resolver, quebrei cabeça mas até agora nada. O problema é que mesmo eu verificando com if isPedInVehicle(source) se o jogador estiver realmente em um carro ele não será teleportado, mas parece que não está funcionando, veja: SERVER.Lua local markerInput = createMarker(1555.1072998047, -1675.6097412109, 16.69611, "arrow", 1, 255,255,0, 50) local markerOutput = createMarker(1555.1072998047, -1675.6097412109, 16.69611, "arrow", 1, 255,255,0, 50) function inputPD(source) local isPed = isPedInVehicle(source) if (isPed == false) then if isElementWithinMarker(source, markerInput) then setElementInterior(source, 6) setElementPosition(source, 246.6756439209,65.71768951416,1003.640625, true) outputChatBox("#ffffff| SS | Você entrou na #ff0000Delegacia de Polícia#ffffff.", source, 255,255,255, true) end else outputChatBox("#ffffff| SS | Você não pode entrar com veículo na DP.", source, 255,255,255, true) end end addEventHandler("onMarkerHit", getRootElement(), inputPD) Obs.: A mensagem do else aquela do outputChatBox aparece, mas mesmo assim o jogador é teleportado, veja: https://prnt.sc/plhefn
-
Olá, quero entender como funciona os scripts em MTA, portanto estava pesquisando sobre os elementos dentro de uma função, quando usar os argumentos, pra que servem etc. Porém num processo de criação básico onde eu uso function joinPlayer(source) outputChatBox("Seja bem-vindo ao servidor.", source) spawnPlayer(source, 1000, 10, 10) end addEventHandler("onPlayerJoin", getRootElement(), joinPlayer) -- quando pede um elemento, coloque getRootElement(). o script não funciona direito. Ele envia a mensagem ao jogador 'source' mas o spawnPlayer não funciona. Porém quando eu troco o parâmetro de source > player tudo começa a funcionar normal. function joinPlayer(player) outputChatBox("Seja bem-vindo ao servidor.", source) spawnPlayer(source, 1000, 10, 10) end addEventHandler("onPlayerJoin", getRootElement(), joinPlayer) -- quando pede um elemento, coloque getRootElement(). Eu queria saber porque somente ao trocar de parâmetro o erro sai e o que de fato é 'SOURCE' que eu tanto procuro no site de script do MTA e nunca acho. Tenho em mente que seja como o player mas quando eu utilizo player em parâmetros e funções ás vezes ocorrem erros/conflitos e eu não sei porque, já que player é um elemento de fato. Alguém poderia me responder então: O que é Source? Por que acontece os conflitos quando uso parâmetro de nome 'player'? Por que o 'source' não aparece sobre explicação do que seja? AGRADEÇO IMENSAMENTE DESDE JÁ! MUITO OBRIGADO DE <3! (Quem responder recebe 'Thanks').
