Jump to content

rxqp

Members
  • Posts

    25
  • Joined

  • Last visited

Posts posted by rxqp

  1. O source do evento onVehicleEnter e o veiculo, use uma condição para saber se o veiculo no qual ele entrou e o veiculo de trabalho do mesmo

    ex

    function Exit_Veh (source)
        if getElementData(source, "Viagem") == true then
            exports.Scripts_Dxmessages:outputDx(source, "Você tem 60 segundos para voltar pro caminhão", "warning")
            Tempo[source] = setTimer ( function()
                canceljobtimer (source)
                setElementData(source, "Viagem", false)
                exports.Scripts_Dxmessages:outputDx(source, "Você Saiu da Van, Mercadoria Cancelada!", "warning")
            end, 10000, 1 )
        end
    end
    addEventHandler ("onVehicleExit", getRootElement(), Exit_Veh)
    
    function Enter_Veh (player)
        if (Caminhao[player]) and isElement(Caminhao[player]) then
            if source == [[--(var do veiculo do player)--]] then
                if isTimer(Tempo[source]) then
                    killTimer(Tempo[source])
                    exports.Scripts_Dxmessages:outputDx(source, "Você voltou pro seu veículo", "warning")
                end
            end
        end
    end
    addEventHandler ("onVehicleEnter", getRootElement(), Enter_Veh)

     

  2. vc pode usar a função util isEventHandlerAdded pra verificar se o painel esta renderizando (lembrando que e uma função util)

    ex
     

    addEventHandler("onClientKey", root, function (button, press)
        if isEventHandlerAdded("onClientRender", getRootElement(), LoginPanel) then
            if button == "F1" or button == "F2" or button == "F3" or button == "F4" or button == "F5" or button == "F6" or button == "F7" or button == "b" or button == "F9" or button == "F10" or button == "F11" or button == "F12" then
                cancelEvent()
            end
        end
    end)

    Lembrando que quando for fazer a verificação de um valor boolean, não e nescessario inserir a condição, apenas com o if (verificação) then ele reconhece que caso o valor seja true para continuar essa função

     

    obs: use no client (mude a função do isEventHandlerAdded)

  3. Exemplo abaixo:

     

    markers = {
        [1] = {x, y, z},
        [2] = {x, y, z},
        [3] = {x, y, z},
        [4] = {x, y, z},
    }
    
    addCommandHandler("command", function(source)
        if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Console")) then
            local number = math.random(1, 4)
            marker = createMarker(markers[number][1], markers[number][2], markers[number][3], "cylinder", 2.0, 255, 255, 255)
          blip = createBlipAttachedTo(marker, 10)
        end
    end)
    
    addCommandHandler("destroymarker", function(source)
        if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Console")) then
            if isElement(marker) then
                destroyElement(marker)
            end
        end
    end)
    
        

     

  4. Edit: O outputChatBox pode bugar por estar sendo usado dentro de um for, vc pode usar esta função para pegar os players proximos

     

    function pegarPlayersProximos(elemento)
        if isElement(elemento) and getElementType(elemento) then
            for i, v in ipairs(getElementsByType("player")) do
                if v ~= elemento then
                    local x, y, z = getElementPosition(elemento)
                    local x2, y2, z2 = getElementPosition(v)
                    if getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) < 3 then
                    end
                    return v
                end
            end
        end
    end
    
              

     

  5. Exemplo:

     

    config = {
    	markerInicio = {x, y, z},
    }
    
    markers = {
    	[1] = {x, y, z},
    	[2] = {x, y, z},
    }
    
    marker = createMarker(config.markerInicio[1], config.markerInicio[2], config.markerInicio[3], "cylinder", 2.0, 255, 255, 255)
    
    addEventHandler("onMarkerHit", marker, function(source)
    	if getPedOccupiedVehicle(source) then
    		outputChatBox("Use /corrida para iniciar a corrida")
    	end
    end)
    
    addCommandHandler("corrida", function(source)
    	if isElementWithinMarker(source, marker) then
    		setElementPosition(source, x, y, z)
    			veh = createVehicle(vehicleID, x, y, z)
    				warpPedIntoVehicle(source, veh)
    			setElementData(source, "Augusto.Marker", 1)
    		criarMarker(source)
    	end
    end
    
    function criarMarker(element)
    	if isElement(element) then
    		local number = tonumber((getElementData(element, "Augusto.Marker") or 1))
    		local x, y, z = markers[number][1], markers[number][2], markers[number][3]
    		markerCheckpoint = createMarker(x, y, z , "checkpoint", 2.0, 255, 255, 255)
    addEventHandler("onMarkerHit", markerCheckpoint, function(source)
    	if source == element then
    		setElementData(source, "Augusto.marker", number +1)
    			destroyElement(markerCheckpoint)
    				criarMarker(source)
    			end
    		end)
    	end
    end

    Obs: Não testei

    lembrando que voce pode usar a condição "until" (ate) para verificar se acabou os checkpoints

  6. Exemplo: (Acabei de fazer)

     

    addCommandHandle("local", function(source, commandName, ...)
    local msg = table.concat({...}, " ")
    if not (...) then return end
    	for i, v in ipairs(getElementsByType("player")) do
    		if v ~= source then
    			local x, y, z = getElementPosition(source)
    			local x2, y2, z2 = getElementPosition(v)
    			if getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) < 3 then
    				outputChatBox("[MENSAGEM LOCAL] "..getPlayerName(source)..": "..msg, v, 255, 255, 255, true)
    			end
    		end
    	end
    end

    Obs: E nescessario testar

  7. A função onClientRender (como vc provavelmente sabe) fica sempre sendo executada (enquanto o evento estiver ativo)

    voce pode criar um dxEditBox pra verificar a caixinha de edit, vc usa condições dentro do onClientRender pra isso, ex:

     

    local pID = createElement("Augusto.playerId")
    
    addEventHandler("onClientRender", getRootElement(), function()
    local playerID = getElementData(pID, "text2") or "" --text2 e o elemento padrão de texto do dxEditBox
    
    if getPlayerID(tonumber(playerId)) then
    --Nesta condição, o script encontrou o id especificado na caixinha do dxEditBox
    
    else
    --Aqui não encontrou as informações 
    dxDrawText("Não Encontrado", w, h, x, y) 
    	end
    end)

    Espero que tenha conseguido entender : )

  8. Provavel que no client-side da hud, as variaveis de fome e sede podem n ser reconhecidas, vou deixar 2 exemplo abaixo 

    local fome = getElementData(localPlayer, "Augusto.fome")
    local sede = getElementData(localPlayer, "Augusto.sede")

    neste codigo acima, ele so indentificara o elemento caso o player tenha, caso ele não tenha retornara nil, isso que pode estar causando o problema, de uma olhada no codigo e altere para isso

     

    local fome = getElementData(localPlayer, "Augusto.fome") or 0
    local sede = getElementData(localPlayer, "Augusto.sede") or 0

    caso o script nao consiga indentificar esses elementos no player, ele tem uma segunda opção (or/ou)

  9. Vc pode pegar a posição do veiculo em uma variavel local e setar a position do player de acordo com essa posição
     

    Exemplo Simples:

    addCommandHandler("sair", function(source)
    	if isPlayerAttachedInVehicle(source) then
    		local pVeh = playerVehicle
    		local x, y, z = getElementPosition(pVeh)
    		detachElements(source, pVeh)
    		setElementPosition(source, x, y +2, z)
    	end
    end)

    Obs: Na suposição, isPlayerAttachedInVehicle seria uma função util e playerVehicle, uma variavel setada no comando de agarrar, mas tmb pode ser utilizado elementData (menos eficiente por ser um script "global" (usado em todo o servidor) pois caso o servidor tenha muitos players pode acarretar lag

  10. Um exemplo de banimento por quitar algemado:

     

    addEventHandler("onPlayerQuit", root, function(quitType)
    	if quitType == "Quit" then
    		if getElementData(source, "Augusto.Algemado") then
    			banPlayer(source, true, false, false, "Servidor", "Deslogou Algemado", 600000) --10 Minutos
    		end
    	end
    end)

     

  11. Bom dia/tarde/noite, estou tentando programar um launcher para mta (em csharp), queria saber se alguem conhece algum request do mta que abra o processo e conecte-se a um servidor igual ao fivem

    Ex do fivem

    System.Diagnostics.Process.Start($"fivem://connect/IPDOSERVIDOR");

     

  12. Preciso que renasça um ped apos o cara passar por um certo marker, alguem sabe uma função, procurei pela mta wiki em ped functions e n achei alguma que funcionasse

    Como ainda (depois de meses) nao sei editar o topico, eu ja consegui fazer com que eles renasçam mas da pra bugar o sistema, alguem sabe se da (adicionando na acl Admin) pra reiniciar o script apos o cara pisar no marker?

     

     

    Motivo de dar para bugar:

    function finalizar(source)
    	if isPedDead(alvo1) then
    			if isPedDead(alvo2) then
    							if isPedDead(alvo3) then
    											if isPedDead(alvo4) then
    															if isPedDead(alvo5) then
    																			if isPedDead(alvo6) then
    																							if isPedDead(alvo7) then
    																											if isPedDead(alvo8) then
    																															if isPedDead(alvo9) then
    																																			if isPedDead(alvo10) then
    setElementFrozen(source, false)
    	outputChatBox("---------------------------", localPlayer, 0, 255, 255, true)
    	outputChatBox("Va ate a porta para sair do treinamento", localPlayer, 0, 255, 255, true)
    	outputChatBox("---------------------------", localPlayer, 0, 255, 255, true)
    end
    end
    end
    end
    end
    end
    end
    end
    end
    end
    end
    addCommandHandler("finalizar", finalizar)

    Obs: da pra dar finalizar mesmo sem matar os peds depois que eles sao setados (setElementHealth) com 100 de vida

    Como ainda (depois de meses) nao sei editar o topico, eu ja consegui fazer com que eles renasçam mas da pra bugar o sistema, alguem sabe se da (adicionando na acl Admin) pra reiniciar o script apos o cara pisar no marker?

     

     

    Motivo de dar para bugar:

    function finalizar(source)
    	if isPedDead(alvo1) then
    			if isPedDead(alvo2) then
    							if isPedDead(alvo3) then
    											if isPedDead(alvo4) then
    															if isPedDead(alvo5) then
    																			if isPedDead(alvo6) then
    																							if isPedDead(alvo7) then
    																											if isPedDead(alvo8) then
    																															if isPedDead(alvo9) then
    																																			if isPedDead(alvo10) then
    setElementFrozen(source, false)
    	outputChatBox("---------------------------", localPlayer, 0, 255, 255, true)
    	outputChatBox("Va ate a porta para sair do treinamento", localPlayer, 0, 255, 255, true)
    	outputChatBox("---------------------------", localPlayer, 0, 255, 255, true)
    end
    end
    end
    end
    end
    end
    end
    end
    end
    end
    end
    addCommandHandler("finalizar", finalizar)

    Obs: da pra dar finalizar mesmo sem matar os peds depois que eles sao setados (setElementHealth) com 100 de vida

    Como ainda (depois de meses) nao sei editar o topico, eu ja consegui fazer com que eles renasçam mas da pra bugar o sistema, alguem sabe se da (adicionando na acl Admin) pra reiniciar o script apos o cara pisar no marker?

     

     

    Motivo de dar para bugar:

    function finalizar(source)
    	if isPedDead(alvo1) then
    			if isPedDead(alvo2) then
    							if isPedDead(alvo3) then
    											if isPedDead(alvo4) then
    															if isPedDead(alvo5) then
    																			if isPedDead(alvo6) then
    																							if isPedDead(alvo7) then
    																											if isPedDead(alvo8) then
    																															if isPedDead(alvo9) then
    																																			if isPedDead(alvo10) then
    setElementFrozen(source, false)
    	outputChatBox("---------------------------", localPlayer, 0, 255, 255, true)
    	outputChatBox("Va ate a porta para sair do treinamento", localPlayer, 0, 255, 255, true)
    	outputChatBox("---------------------------", localPlayer, 0, 255, 255, true)
    end
    end
    end
    end
    end
    end
    end
    end
    end
    end
    end
    addCommandHandler("finalizar", finalizar)

    Obs: da pra dar finalizar mesmo sem matar os peds depois que eles sao setados (setElementHealth) com 100 de vida

  13. Acho que esse vai ser o ultimo post, o que tem de errado no codigo, o player consegue mexer quando tem o setTimer, mas quando nao tem o setTimer ele fica freezado, mas dps nao "desfreeza"

    function curar(player)
         if isElementWithinMarker(player, hpMarker) then
            setElementPosition(player, 1187.147, -1322.853, 13.559, true)
            setElementFrozen(player, freeze)
            setElementHealth(player, 100) 
            setPedAnimation(Medico, "police", "plc_drgbst_02", 5000 , false, false, false, false, 250)
           outputChatBox("Voce Esta Sendo Curado!", player, 0, 255, 255)
           takePlayerMoney(player, 500)
           setElementFrozen(player, true)
           setTimer(curar, 5000, 5000, setElementFrozen(player, false))
        end
        end
    
    
    
    addCommandHandler("curar", curar)

     

  14. Vo te explicar o script que quero criar, o player vai no hospital, vai ter um marker bem pequeno em frente ao medico, onMarkerHit vai dizer no chat "Digite /consultar para saber seu estado medico, Digite /curar Para fazer um tratamento, Ai quando o cara der /curar, queria que o ped usasse a animação de revistar por 10 segundos (loop) e nesse tempo o player nao conseguiria se mexer(frozen)ai a vida dele subia

  15. Eu nao entendi muito bem esse setPedAnimation, Achei que o "ped" era realmente um ped, eu peguei essa animação no site na wiki de animações mesmo, e o addCommandHandler eu nao adicionei ao post por que achei que nao seria nescessario, mas ta aqui

    addCommandHandler("curar", curar)

    Tambem queria saber como parar a animação depois de 10 segundos e tambem dar frozen no player Pra ele "ficar parado" enquanto o medico "examina" ele

    EDIT: Tmb como dar frozen no ped

     

  16. Preciso de ajuda para setar uma animação pra um npc quando um comando for dado
    OBS: Preciso de ajuda no setPedAnimation, Pois o resto esta funcionando certinho

    Medico = createPed (70, 1187.1165771484,-1323.5570068359,13.559015274048)
    function curar(player)
           setElementHealth(player, 100) 
           outputChatBox("Voce foi curado com sucesso!", player, 0, 255, 255)
           takePlayerMoney(player, 500)
           setPedAnimation(Medico, "ped", "coptraf_stop")
        end

     

  17. Preciso de ajuda, to aprendendo agr a criar scripts, e sem a função consultar o marker aparece e o outputChatBox funciona certinho, mas quando coloco a função consultar o marker nao aparece EDIT: Pode deixar, ja consegui, usei o debugscript 3 e percebi que faltava um "then", so to falando isso pq nn sei excluir

    consulta.Lua
    
    
    
    hpMarker = createMarker(1188.3895263672,-1323.0168457031,12.566656112671, "cylinder", 2.0, 0, 255, 255)
    
    
    function msg(player)
        outputChatBox("Digite /consultar para saber seu estado medico", player, 0, 255, 255, true)
    end
    
    addEventHandler("onMarkerHit", hpMarker, msg)
    
    
    function consultar(player)
        if isElementWithinMarker(player, hpMarker)
        vida = getElementHealth(player)
        outputChatBox("Sua vida: "..vida.. ", Digite /curar para fazer um tratamento", player, 0, 255, 255, true)
        end
        end
    
        addCommandHandler("consultar", consultar)
    meta
    
    
    <meta>
    <script src="consulta.Lua" type="server"/>
    </meta>

     

  18. mRevisao = createMarker(1911.6433105469, -1776.1658935547, 11.901125907898, "cylinder", 4.5, 255, 255, 255, 50)

    function revisao(source)
             VeiculoPlayer = getPedOccupiedVehicle(source)
        if VeiculoPlayer then 
            situacao = getElementHealth(VeiculoPlayer)
        if situacao >=500
                outputChatBox("Seu veiculo esta em otimo estado.", source, 255, 255, 255, true)
        elseif situacao <=500
        outputChatBox("Seu veiculo precisa de conserto!", source, 255, 255, 255, true)
          end
         end
        end
        addEventHandler("onMarkerHit", mRevisao, revisao)


    Estou aprendendo agora a criar scripts, alguem pode me dizer o que esta errado pfv
    Objetivo: Quando o veiculo entrar no marker vai mandar no chat uma mensagem no chat dizendo a situação do veiculo dele
    Obs: Vi no youtube

     

×
×
  • Create New...