Jump to content

Developer.

Members
  • Posts

    92
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Developer.

  1. Ok, sem problemas. Bom vou estar te passando dois tópicos, um é de como você estar usufruindo do fórum da maneira certa! É um tutorial em vídeo feito pelo Lord Henry link abaixo:

    O outro link é um outro tutorial, meio que um "passo-a-passo" feito pelo DNL291 sobre como começar na linguagem Lua no MTA. Leia com calma e paciência! Segue o link abaixo:

     

    Agora vamos lá.

    Primeiro o que é ELEMENT DATA? É uma forma de você salvar um dado ao player exemplo:  o player Eder esta sendo revistado, eu quero salvar isso a mim o que eu faço?

    coloco setElementData(playerRevistado, "sendo:Revistado", playerRevistado), dessa forma eu acabei de colocar um dado a mim.

    Agora se eu quiser ver se eu estou sendo revistado ou não? Eu faço isto:

    if getElementData(playerRevistado, "sendo:Revistado") == true then ou seja se eu tiver esta data "sendo:Revistado" então algo acontecerá comigo...

     

    Vamos ao código:

    1 - onde esta escrito local bank, coloque isto aqui:

        local bank = format(tonumber(getElementData(jogador, "Bank:Caixa"or 0));

    Caso não funcione o problema deve estar no nome da data "Bank:Caixa", para verificar vc tem q abrir o seu mod do banco e procurar por isto lá dentro!

    2 - para "adicionar a fome, sede e sono é necessário onde tem isto:

        local Fome = format(tonumber(getElementData(jogador, "hunger")) or 0); -- data da fome
        local Sede = format(tonumber(getElementData(jogador, "sede")) or 0); -- data da sede
        local Sono = format(tonumber(getElementData(jogador, "sono")) or 0); -- data do sono

    Os nomes "hunger", "sede" e "sono" precisam estar EXATAMENTE iguais ao que esta no seu mod de lanchonete! Para estar mudando é só apagar o que esta entre as aspas " ", e digitar com letras maiúsculas e minusculas o nome certo da data que esta lá no mod de lanchonete. Normalmente só abrir o arquivo e pesquisar por setElementData ou getelementData que vc encontrará.

    O básico é isso. Caso não tenha entendido só estar perguntando novamente, que tentarei lhe ajudar!

    Edit: E não se esqueça de ativar o debugscript 3!!

     

    • Like 1
  2. Olha sendo sincero, essa de arquivo sumir eu nunca vi, o que pode acontecer é que talvez você mudou o nome do seu arquivo e esqueceu de abri-lo novamente no editor de códigos, enfim tem algumas hipóteses. Relacionado ao código mudei algumas coisas  e adicioneis outras. Como eu não tenho todos os arquivos por exemplo os de imagem trabalhei no que pude!

    Obs: antes de iniciar o código verifique se tudo esta certinho no arquivo meta.xml e ligue o debugscript, digitando /debugscript 3 pra ligar e /debugscript 0 para desligar.

    Mude também as datas de fome, sede e sono para o seu sistema de lanchonete.

    Adicionei um sistema simples que permite o player desativar a hud pressionando o botão f10, caso queira mudar só olhar o sistema e procurar por "botao_ligar_hud"

    Segue abaixo o código:

    local screenW,screenH = guiGetScreenSize()
    local resW, resH = 1366,768
    local x, y = (screenW/resW), (screenH/resH)
    
    local jogador = getLocalPlayer()
    local botao_ligar_hud = "F10" -- para ligar ou desligar a hud.
    
    function hourFormat()
        local realtime = getRealTime()
        return
        string.format("%02d:%02d:%02d", realtime.hour, realtime.minute, realtime.second)
    end
    
    function format(val, decimal)
        if (decimal) then
          return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)
        else
          return math.floor(val+0.5)
        end
    end
    
    function drawHud()
        local dinheiro1 = format(getPlayerMoney(jogador));
    	local bank = format(getElementData(jogador, "Bank:Caixa") or "0");
    	
        local Procurado = getPlayerWantedLevel(jogador);
        local Emp =  (getElementData(jogador, "Emprego") or "Desempregado");
        local showammo1 = getPedAmmoInClip (jogador, getPedWeaponSlot(jogador));
        local showammo2 = getPedTotalAmmo(jogador) - getPedAmmoInClip(jogador);
    	local weapon = getPedWeapon (jogador);
    	local arma = getWeaponNameFromID (weapon);
    	local ID = (getElementData(jogador, "ID") or "N/A");
    	local armor = (getPedArmor(jogador));
    	local Fome = format(tonumber(getElementData(jogador, "hunger")) or "100"); -- data da fome
    	local Sede = format(tonumber(getElementData(jogador, "sede")) or"100"); -- data da sede
    	local Sono = format(tonumber(getElementData(jogador, "sono")) or "100"); -- data do sono
    	--local level = (getElementData(jogador, "Level") or "0");
    	
        dxDrawImage(x*1009, y*38, x*422, y*210, "images/fundo.png", 0, 0, 0, tocolor(3, 224, 251, 255), false)
        dxDrawImage(x*1159, y*48, x*111, y*20, "images/Vida.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(x*1159, y*78, x*114, y*21, "images/Colete.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(x*1159, y*119, x*116, y*21, "images/Fome.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(x*1159, y*150, x*116, y*21, "images/Fome.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    	dxDrawImage(x*1159, y*181, x*116, y*21, "images/Fome.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    	
        dxDrawText("fome %"..Fome, x*1196, y*48, x*1251, y*80, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText("colete %"..armor, x*1196, y*83, x*1251, y*115, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawImage(x*1256, y*20, x*100, y*109, "images/logocat.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText("Fome: "..Fome.."%", x*1196, y*124, x*1256, y*156, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText("Sede: "..Sede.."%", x*1196, y*146, x*1256, y*178, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText("Sono: "..Sono.."%", x*1196, y*181, x*1256, y*213, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText("Seu id: "..ID.."", x*1015, y*223, x*1360, y*259, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
            
        dxDrawImage(x*1035, y*133, x*100, y*97, "icons/0.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText("Arma: "..arma.. " || Pente: " ..tostring (showammo1).." / "..tostring (showammo2), x*1015, y*258, x*1132, y*276, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText(""..dinheiro1.."", x*1015, y*48, x*1091, y*73, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText(""..bank.."", x*1015, y*83, x*1112, y*129, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText(""..Emp.."", x*1196, y*258, x*1332, y*287, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawImage(x*1122, y*48, x*29, y*25, "images/logodinheiro.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(x*1122, y*75, x*29, y*24, "images/logobanco.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(x*1275, y*115, x*29, y*25, "images/comida.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(x*1280, y*145, x*24, y*26, "images/bebida.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(x*1278, y*179, x*27, y*24, "images/sono.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText(""..Procurado.."", x*1015, y*9, x*1090, y*38, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawImage(x*1009, y*24, x*22, y*14, "images/procurado.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    
        local cTime = hourFormat() or "00:00:00"
        dxDrawText ( "Hora: "..cTime.."",  x*1160, y*220, x*1275, y*238, tocolor ( 255, 255, 255, 255 ), 0.55, "bankgothic" ) 
    end
    addEventHandler("onClientRender", root, drawHud, false)
    
    function showHud (button, press)
        if button == botao_ligar_hud then
            if (press)then
                if not isEventHandlerAdded("onClientRender", root, drawHud) then
                    addEventHandler("onClientRender", root, drawHud, false)
                else
                    removeEventHandler("onClientRender", root, drawHud, false)
                end
            end
        end
    end
    addEventHandler("onClientKey", getRootElement(), showHud, false)
    
    local hudTable = {
        "ammo",
        "armour",
        "clock",
        "health",
        "money",
        "weapon",
        "wanted",
        "area_name",
        "vehicle_name",
        "breath",
        "clock"
    }
    
    addEventHandler("onClientResourceStart", resourceRoot,
    function()
        for _, hudComponents in ipairs(hudTable) do
            setPlayerHudComponentVisible(hudComponents, false)
        end
    end)
    	
    addEventHandler("onClientResourceStop", resourceRoot,
    function()
        for _, hudComponents in ipairs(hudTable) do
            setPlayerHudComponentVisible(hudComponents, true)
        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

    Para copiar o código corretamente, pressione o simbolo de prancheta que fica no lado superior esquerdo onde se iniciar o código!

    Caso de algum erro, verifique seu debugscript ou mande uma print aqui se necessário.

    • Like 1
  3. addCommandHandler("versujo", 
    function(player, cmd, target )
    	local accName = getAccountName(getPlayerAccount(player))
    	if not isObjectInACLGroup ("user."..accName, aclGetGroup("Policial")) then
    		outputChatBox("Ops! Sinto Muito :( , Você não tem permissão para executar esta função", player, 255, 0, 0)
    		return
        end
    	if target then
    	local targetplayer = getPlayerFromName(target)
            if targetplayer then
                local pX, pY, pZ = getElementPosition(player) -- posição do policial
                local bX, bY, bZ = getElementPosition(targetplayer) -- posição do abordado
                local dist = getDistanceBetweenPoints3D(pX, pY, pZ, bX, bY, bZ) -- calcula a distancia da duas posições
                if dist < 3 then -- se a distancia for menor que 3 então:
                    local Dinheiro_Sujo = getElementData ( targetplayer, "moneysujo" )
                        outputChatBox ( "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffO Jogador Tem: #FF0000R$"..Dinheiro_Sujo.."#ffffff Na Carteira !", player, 255, 0, 0, true )
                    end
                else --se não for então:
                    outputChatBox ( "#0037FF✘#ffffffINFO#0037FF✘➺ #ffffffVocê esta muito longe!", player, 255, 0, 0, true )
                end
            end
        end
    end)

    Obs: não testado

    Vê se isso funciona.

    • Thanks 1
  4. debug é para você ver se tem alguma linha de Código dando erro, aperte f8 e digite debugscript 3, quanto ao script eu testei e ta funcional.

    O que pode estar acontecendo é esse setPedAnimationSpeed não existir! Recomendo trocar por isso aqui:

    function setPedAnimationSpeed(player,anim,speed)
        setPedAnimation(player,anim,speed)
    end

    Não entendi muito bem seu script pois o player mesmo algemado ainda pode se mover acredito eu q ele deveria ficar imóvel mas enfim... 

    Ah e claro verifique se as ACLS BOPE e PMRJ existem e que sua conta tem permissão nelas!

     

     

     

  5. Bom o seu script não funciona pelo seguinte:

    if isObjectInAcl é uma verificação! Ou seja ela verifica se o player esta, tem, pode, não tem, não pode ou não esta. 

    No seu código você primeiro não esta verificando nada, segundo não colocou um end e terceiro não existe a variável accountName no seu código.

    (Logica): Para eu verificar algo eu tenho que estar antes do resultado certo?

    Um exemplo bem besta, antes de eu beber água o que eu preciso? Um copo e um filtro correto? Se eu não tenho o copo vou beber como? Mas se eu tenho o copo e não tenho o filtro da onde a água vai sair? Entende o que eu quero dizer? if seria você mesmo ver se tem o copo na sua mão e se o filtro esta na sua frente...

    Agora voltando ao seu código o que você esta verificando colocando o if isObjectInAcl lá em baixo? Depois de todo o código? Não tem o menor sentido concorda?

    Então o if isObjectInAcl tem q estar lá em cima certo?

    o que é end? end é o fim de algo em Lua, 'PARA TUDO TEM QUE HAVER UM FIM' nos códigos não é diferente, toda vez que tiver um if, é OBRIGATÓRIO ter um end.

    o que é accountName? accountName é uma variável. Variáveis são palavras, números ou símbolos que possuem um valor, no seu caso a VARIÁVEL  accountName possui o valor que é o Nome da Conta do Player, mas por que?

    Bem simples, quando você vai mexer no painel P para adicionar um player na acl, vc tem que digitar user.Nome da conta correto?

    No código você não esta adicionando nada, mas esta verificando se o player esta ali dentro então tem que pegar o nome da conta, entendeu?

    seu eu fizer isso:

     

    getAccountName(getPlayerAccount(thePlayer))

    ou fizer isso:

    accountName = getAccountName(getPlayerAccount(thePlayer))

    o resultado é o mesmo! Porém independente de qual forma seja, eu preciso pegar o nome da conta do player para a função isObjectInAcl.

    abaixo o código:

    function setPedAnimationSpeed(player,anim,speed)
    	triggerClientEvent(player, "animSped", player, player,anim,speed)
    end
    
    function setCuffPlayer(player)
    	setPedAnimation(player, nil)
    	setPedAnimation(player,'ped', 'pass_Smoke_in_car', 0, true, true, true)
    	setTimer(setPedAnimationSpeed,60,1,player, 'pass_Smoke_in_car', 0)
    	local x, y, z = getElementPosition(player)
    	local box = createObject(364, x, y, z)
    	exports.bone_attach:attachElementToBone(box, player, 12, 0,0,0,   0,40,-10)
    	setElementCollisionsEnabled(box, false)
    	setElementData(player,'cuffOb', box)
    	toggleControl(player, 'jump', false)
    	setTimer(function(player)
    		if getElementData(player,'cuff') and getElementData(player,'cuff') == true then
    			toggleControl(player, 'fire', false)
    		end
    	end,60,0,player)
    	toggleControl(player, 'crouch', false)
    end
    
    local corpACLS = { -- NOME DAS ACLS Q PODEM ALGEMAR UMA PESSOA!
    	"BOPE",
    	"PMRJ",
    }
    
    function cuff(hit,_,name)
    	local player = getPlayerFromName(name)
    	local x,y,z = getElementPosition(player)
        local x1,y1,z1 = getElementPosition(hit)
        if isPlayerPermission(hit) then -- FUNÇÃO UTIL, BASICAMENTE VERIFICA SE O POLICIAL (hit) ESTA DENTRO DE UMA DAS ACL'S BOPE OU PMRJ!
            if getDistanceBetweenPoints3D(x1,y1,z1,x,y,z) <= 20 then
                if not getElementData(player,'cuff') or getElementData(player,'cuff') ~= true then
                    if isPedInVehicle(player) then
                        setControlState(player,'enter_exit',true)
                        setTimer(setCuffPlayer,2800,1,player)
                        setElementData(player,'cuff', true)
                    else
                        setCuffPlayer(player)
                        setElementData(player,'cuff', true)
                    end
                    outputChatBox(' '..getPlayerName(hit)..'#ff0000 Algemou você',player,255,255,255,true)
                else
                    removeElementData(player,'cuff')
                    destroyElement(getElementData(player,'cuffOb'))
                    removeElementData(player, 'cuff')
                    toggleControl(player, 'jump', true)
                    toggleControl(player, 'crouch', true)
                    toggleControl(player, 'fire', true)
                    setPedAnimation(player, 'ped', 'pass_Smoke_in_car', 0, false, false, false, false)
                    outputChatBox(' '..getPlayerName(hit)..'#008800 Soltou suas algemas',player,255,255,255,true)
                end
            else
                outputChatBox("Você está longe demais!",hit,255,0,0,true)
            end
        end -- end do if ifPlayerPermission then
    end
    addCommandHandler('algemar',cuff)
    
    addEventHandler('onPlayerQuit', root,function()
    	if getElementData(source,'cuff') == true then
    		destroyElement(getElementData(source,'cuffOb'))
    		removeElementData(source, 'cuff')
    	end
    end)
    
    addEventHandler('onPlayerWasted',root,function()
    	if getElementData(source,'cuff') == true then
    		destroyElement(getElementData(source,'cuffOb'))
    		removeElementData(source, 'cuff')
    	end
    end)
    
    addEventHandler('onVehicleStartEnter', getRootElement(),
    function(player, seat)
    	if getElementData(player,'cuff') == true then
    		if seat ~= 0 then
    			destroyElement(getElementData(player,'cuffOb'))
    		else
    			cancelEvent()
    			outputChatBox('Você não pode dirigir você tem algemas!',player,255,0,0)
    		end
    	end
    end)
    
    setTimer(function()
    	for _,player in ipairs(getElementsByType("player")) do
    		if getElementData(player,'cuff') == true then
    			if isPedInWater(player) then
    				setTimer(function(player)
    					if isPedInWater(player) then
    					  killPed(player)
    					end
    				end,5000,1,player)
    			end
    		end
    	end
    end,1000,0)
    
    addEventHandler('onVehicleExit', getRootElement(),
    function(player, seat)
    	if getElementData(player,'cuff') == true then
    		setCuffPlayer(player)
    	end
    end)
    
    
    -- ABAIXO UMA FUNÇÃO UTIL QUE FOI DEMONSTRADA por @MainSCR no seu outro post, deveria ter usado isto em vez da outra!
    
    function isPlayerPermission(thePlayer) -- faz um loop das acls declaradas na tabela e verifica se a acl do jogador é uma das acls declarada na tabela
    	if isElement(thePlayer) and getElementType(thePlayer) == "player" then 
    		if isGuestAccount(getPlayerAccount(thePlayer)) then return end
    		for _, group in ipairs(corpACLS) do
    			if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup(group)) then
    -- preste atenção acima,                     ("user."..Nome da Conta                              , qual a acl       ))
    				return true
    			end
    		end
    	end
    	return false
    end

     

  6. Observações: o seu código inicial @Rangel funciona! Mesmo tendo coisas sem sentidos como "comando" e "nick" em um addEventHandler e demais coisas, funciona sim!

    A unica coisa que não ocorre é o player poder destruir depois de ter saído do servidor!

    já o código do @Angelo Pereira é totalmente funcional e melhorado inclusive ( meus parabéns)

    Dito isso vamos lá, você tem 2 formas de fazer este Spawn de viaturas:

    Sistema 1

    Para Criar a Vtr:

    local tableVehicle = {}
    local ACL = "BOMBEIROS"
    
    function spawnvtr ( mkr, dim )
        if (dim) then -- verifica a dimensão
            if mkr == Spawn1 then -- verifica se a marker hitada é a de spawn. Se for então:
                local accName = getAccountName ( getPlayerAccount ( source ) ) -- pega a account do player
                if not isObjectInACLGroup ("user."..accName, aclGetGroup ( ACL) ) then -- se ele não for bombeiro ( não estiver na acl) então:
                        outputChatBox("#FFFFFF| #E10000BOMBEIROS #FFFFFF| Somente #E10000BOMBEIROS #FFFFFFPodem Pegar Este Veiculo.", source,255,255,255, true) --  envia essa mensagem
                    return -- termina a função, por precaução eu costumo fazer isto para evitar bug's! Poderia também usar um else no lugar do return!
                end -- se eu usar else, esse end aqui deveria ficar embaixo do warpPed!
                if tableVehicle[source] then -- se existir um valor na tableVehicle
                    destroyElement ( tableVehicle[source] ) -- destroi oq esta na tableVehicle
                    tableVehicle[source] = nil --  coloca tableVehicle como nil (anti-bug)
                end
                tableVehicle[source] = createVehicle(529, -2410.876, -600.848, 132.619, 0, 0, 270 ) -- cria o veículo e insere ele na tableVehicle
                setElementHealth (tableVehicle[source] , 200000) -- não entendi o porque de 200.000 de vida mas ok...
                warpPedIntoVehicle ( source, tableVehicle[source]) -- coloca o player dentro do veículo criado
            end
        end
    end
    addEventHandler("onPlayerMarkerHit", getRootElement(), spawnvtr)
    -- Obs: é de boa pratica sempre fazer as verificações negativas antes! Ex:
    -- Se o player não tiver isto ou não tiver aquilo então a função para de ser executada ou retorna!
    -- isto muitas das vezes evita bug :)

    Para destruir a Vtr:

    function destroyvtr ( mkr, dim )
        if (dim) then
                if mkr == Destroy then
                    local accName = getAccountName ( getPlayerAccount ( source ) )
                    if not isObjectInACLGroup ("user."..accName, aclGetGroup (ACL) ) then
                            outputChatBox("#FFFFFF| #E10000BOMBEIROS #FFFFFF| Somente #E10000BOMBEIROS #FFFFFFPodem Destruir Este Veiculo.", source,255,255,255, true)
                        return
                    end
                if tableVehicle[source] then
                    destroyElement (tableVehicle[source])
                    tableVehicle[source] = nil
                end
            end
        end
    end
    addEventHandler("onPlayerMarkerHit", getRootElement(), destroyvtr)

    Para quando o player sair do servidor:

    function onQuit()
        for _, player in ipairs(getElementsByType("player")) do -- faz um loop nos players online
            if tableVehicle[player] and isElement(tableVehicle[player]) then -- se o player possuia uma viatura antes de sair então:
                destroyElement (tableVehicle[player]) -- destroi a viatura
                tableVehicle[player] = nil 
            end
        end
    end
    addEventHandler("onPlayerQuit", getRootElement(), onQuit)

    ______________________________________________________________________________________________________________________________________________________________________________________

     

    Sistema 2

    Para Criar a Vtr (mesmo código do outro sistema!):

    Obs: caso o player destrua a vtr, dará um erro no debug, mas nada grave!

    local tableVehicle = {}
    local ACL = "BOMBEIROS"
    
    function spawnvtr ( mkr, dim )
        if (dim) then -- verifica a dimensão
            if mkr == Spawn1 then -- verifica se a marker hitada é a de spawn. Se for então:
                local accName = getAccountName ( getPlayerAccount ( source ) ) -- pega a account do player
                if not isObjectInACLGroup ("user."..accName, aclGetGroup (ACL) ) then -- se ele não for bombeiro ( não estivar na acl) então:
                        outputChatBox("#FFFFFF| #E10000BOMBEIROS #FFFFFF| Somente #E10000BOMBEIROS #FFFFFFPodem Pegar Este Veiculo.", source,255,255,255, true) --  envia essa mensagem
                    return -- termina a função, por precaução eu costumo fazer isto para evitar bug's! Poderia também usar um else no lugar do return!
                end -- se eu usar else, esse end aqui deveria ficar embaixo do warpPed!
                if tableVehicle[source] then -- se existir um valor na tableVehicle
                    destroyElement ( tableVehicle[source] ) -- destroi oq esta na tableVehicle
                    tableVehicle[source] = nil --  coloca tableVehicle como nil (anti-bug)
                end
                tableVehicle[source] = createVehicle(529, -2410.876, -600.848, 132.619, 0, 0, 270 ) -- cria o veículo e insere ele na tableVehicle
                setElementHealth (tableVehicle[source] , 200000) -- não entendi o porque de 200.000 de vida mas ok...
                warpPedIntoVehicle ( source, tableVehicle[source]) -- coloca o player dentro do veículo criado
            end
        end
    end
    addEventHandler("onPlayerMarkerHit", getRootElement(), spawnvtr)

    Para destruir a Vtr:

    function destruir(mkr, dim )
        if (dim) then
            if mkr == Destroy then
                local accName = getAccountName ( getPlayerAccount ( source ) )
                if not isObjectInACLGroup ("user."..accName, aclGetGroup (ACL) ) then
                        outputChatBox("#FFFFFF| #E10000BOMBEIROS #FFFFFF| Somente #E10000BOMBEIROS #FFFFFFPodem Destruir Este Veiculo.", source,255,255,255, true)
                    return
                end
                local vehicle = getPedOccupiedVehicle(source) -- retorna o veiculo que o player tá
                local modelo =  getElementModel(vehicle) -- pega o modelo do veículo (id)
                local idViatura = {529, 429} -- tabela onde tem os id's que podem ser destruidos!
                for _, veiculo in ipairs(idViatura) do -- loop
                    if (isElement(vehicle)) and (getElementType(vehicle)=="vehicle") and (modelo == veiculo) then -- se o que hitou a marker for um veículo e, o modelo(id) dele esta na tabela então:
                        destroyElement (vehicle) -- destroi o veículo!
                    end
                end
            end
        end
    end
    addEventHandler("onPlayerMarkerHit", getRootElement(), destruir)

    No sistema 2 não será necessário a parte do player sair do servidor pois qualquer pessoa que POSSUA a TAG, poderá destruir a viatura.

    Só para meio de conhecimento ainda há outras formas, uma delas é com o executeSQLQuery (database interna)!

    Caso tenha alguma duvida só pergunta!

    Obs: tenha certeza q a ACL "BOMBEIROS" esta criada, e que você esta nela!!

    • Thanks 2
  7. function zrespFurke(auto, x, y, z)
    	createVehicle(auto, x, y, z)  -- you need 4 arguments
    end
    addEvent("triggerujZrespienie", true)
    addEventHandler("triggerujZrespienie", resourceRoot, zrespFurke)
    56 minutes ago, NoviceWithManyProblems said:

     

    
    g = 0
    
    addCommandHandler("auto", function(plr, cmd)
        if g == 0 then
            g = 1
            
            local screenW, screenH = guiGetScreenSize()
            okno = guiCreateWindow((screenW - 580) / 2, (screenH - 550) / 2, 580, 550, "Stwórz pojazd", false)
            guiWindowSetSizable(okno, false)
            guiSetAlpha(okno, 0.81)
    
            stworz = guiCreateButton(103, 401, 374, 109, "Stwórz", false, okno)
            guiSetProperty(stworz, "NormalTextColour", "FFAAAAAA")
            id = guiCreateEdit((580 - 378) / 2, (550 - 84) / 2, 378, 84, "ID POJAZDU", false, okno)
            showCursor(true)
    
            x, y, z = getElementPosition(localPlayer)
    
            addEventHandler("onClientGUIClick", stworz, triggeruj, false)
        else
            g = 0
            guiSetVisible(okno, false)
            guiSetVisible(stworz, false)
            guiSetVisible(id, false)
            showCursor(false)
        end
    end)
    
    function triggeruj(button)
        if button == "left" then
            local auto = guiGetText(id)
            auto = tonumber(auto)
            triggerServerEvent("triggerujZrespienie", root, auto, x, y, z) --now you have 4 arguments
        end
    end

     

    In the client-side you only return the position x, y, z ( 3 arguments) , you need to return auto!

  8. 87cX9Fi.jpg

    Esta é a nota oficial do MTA Brasil em relação a loja, basicamente o que acontece é que o MTA Brasil NÃO tem nada a ver com o mod, ele só disponibiliza o

    espaço ao CRIADOR para a divulgação! Minha recomendação é você entrar em contato com o CRIADOR e questiona-lo sobre a entrega.

    Normalmente esse criadores tem pagina no facebook, tem discord e demais meios de comunicação, verifique a descrição da postagem no MTA Brasil para encontrar

    o contato da pessoa.

    • Like 1
    • Thanks 1
  9.  

    Bom acredito eu que aqui não seja a seção certa para estar postando isto mas enfim. O cara entrou no seu servidor e logo após isto ele caiu?

    Primeiro você tem certeza que não foi problema na sua host?

    Segundo você divide senha do seu servidor ou deu acesso a alguma outra pessoa ao ftp, painel admin, ou até mesmo ao seu tc admin?

    Terceiro, verifique o console do seu tc admin, veja se tem algum comando efetuado pelo "cara", ou algo que envolva ele!

    • Like 1
  10. local tableVehicle = {}
    
    function serverSpawn(selectedList1,playerxyz)
        local x, y, z = getElementPosition ( playerxyz )
        local rx,ry,rz = getElementRotation(playerxyz)
        if ( isPedInVehicle (playerxyz) ) then
            outputChatBox( "[Error] Exit your current vehicle first.", playerxyz, 255, 0, 0, true )
        else
            if ( tableVehicle[playerxyz] ) then 
                destroyElement ( tableVehicle[playerxyz] )
                tableVehicle[playerxyz] = nil
            end
            local playerVehicle  = createVehicle ( selectedList1, x+1, y+1, z+0.5, rx,ry,rz )
            warpPedIntoVehicle ( playerxyz, playerVehicle  )
            tableVehicle[playerxyz] = playerVehicle 
        end
    end
    addEvent("spawncar",true)
    addEventHandler("spawncar",getRootElement(),serverSpawn)

    hm, try this...

    • Thanks 1
  11. local time = createTeam("NovoTime", 255, 0, 0) -- cria o time
    local markerTime = createMarker(0, 0, 0, "cylinder", 1.5. 0, 0, 255, 100) -- cria a marker
    -- acima onde esta os "0" coloque a posição onde irá ficar a marker
    
    function addTime(jogador)
        if not time then -- se der erro na criação do time então:
            outputChatBox("INFO: Erro! Informe a administração.", jogador, 255, 0, 0, true) -- envia uma mensagem de erro no chat
        else -- senão:
            setPlayerTeam(jogador, time) -- coloca o player no time
        end -- end do if not time
    end -- end da function
    addEventHandler("onMarkerHit", markerTime, addTime) -- adiciona o evento onMarkerHit 
    -- Obs: o evento onMarkerHit que possibilita ao player quando ele hitar/pisar/passar sobre determinado marker executar determinada função!
    -- neste caso ele passa pela marker (markerTime) e executa a funcão (addTime)

    Seria isto?

  12. Iae rapaziada, seguinte fiz um code simples só para aprender melhor tabela, até agora estava tudo normal criando as markers, a mensagem na tela e tudo mais.... porém agora estou com o seguinte problema:

    São 3 markers cada uma tem uma cadeira do lado. O que tenho em mente é que quando o player hitar uma das markers binde a tecla E, ao pressiona-la ele é colocado sobre a cadeira em que ele esta próximo. Mas no sistema atual o problema é que ele não reconhece qual cadeira é! Quero saber como eu posso fazer uma verificação para saber se a marker é da cadeira [1], [2] ou [3].

    Code: 

    local posChairs = {
        [1] = {1579.4000244141,-1675.8000488281 ,15.199999809265}, -- cadeira interrogado (suspeito) 1
        [2] = {1580, -1677.5, 15.199999809265}, -- cadeira interrogado (suspeito) 2
        [3] = {1582.0999755859, -1676.3000488281, 15.199999809265}, -- -- cadeira interrogador (policial)
    }
    
    local chairTable = {}
    
    function resStart()
        for i, chair in ipairs(posChairs) do
            chairTable[i] = createMarker(chair[1], chair[2], chair[3], "cylinder", 1.2, 255,0, 0, 100)
            outputChatBox(tostring(chairTable[i]))
            addEventHandler("onMarkerHit", chairTable[i], hittingMk)
            addEventHandler("onMarkerLeave", chairTable[i], leavingMk)
        end
    end
    addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), resStart)
    
    function resStopCircle()
        if chairTable[i] then
            destroyElement(chairTable[i])
            chairTable[i] = nil
            outputChatBox(tostring(chairTable[i]))
        end
    end
    addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), resStopCircle)
    
    function hittingMk (element, md)
        if (md) then
            if getElementType(element) == "player" then
                outputChatBox("hitou")
                exports.inMarkerMsg:create(element, "pressione E para sentar")
            end
        end
    end
    
    function leavingMk (element, md)
        if (md) then
            if getElementType(element) == "player"  then
                outputChatBox("saiu")
                exports.inMarkerMsg:delete(element)
            end
        end
    end

    Obs: estou ciente que se eu criar 3 variáveis e 3 eventos uma para cada cadeira dará certo (já testei e consegui!), porém irei criar mais cadeiras além de utilizar esse sistema em outras coisas!

    fazendo um for com a tabela (chairTable), percebi que há uma edentação um "prefixo" e um "valor":

            for k,v in pairs(chairTable) do
                outputChatBox("chairTable "..tostring(k)..", "..tostring(v))
            end

    Retorna:

    chairTable 1, userdata: 0x7289

    chairTable 2, userdata: 0x728c

    chairTable 3, userdata: 0x728f

    Tentei fazer uma verificação com if dessa forma (porém sem exito) :

    if chairTable[1] then
       outputChatBox("hitou1")
    elseif chairTable[2] then
       outputChatBox("hitou2")
    elseif chairTable[3] then
       outputChatBox("hitou3")
    end

    Será que tem como eu especificar a cadeira sem ter que criar para cada cadeira(marker), um evento e uma variável?

  13. 16 hours ago, Mopped said:

    Cara, vc me ajudou muito... se me permite, uma última pergunta:

    Caso eu queira adicionar uma interface (no caso um background para esse painel de fome/sede/sono), onde eu devo mudar no código para que ele faça a animação junto com os rectangles e os drawimage??

    2XSNDFD.png

    O código que eu queria colocar para que faça a animação junto é esse:

    
                dxDrawImage(x*48, y*565, x*210, y*134, "files/images/interface.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)

     

    Bom para você fazer isto tem alguns passos a serem seguidos vamos lá:

    1- posições: nesse "fundo" temos as posições:

    x = 48

    y = 565

    w = 210

    h = 134

    O importante desses números todos é a posição y ou seja o 565, que é onde deverá ocorrer a animação. Se você viu as linhas comentadas acho que sabe do que estou falando!

    2 -  Valores em tabela: Temos duas tabelas, a tabela onde tem a posição do radar ( up ) e a outra onde tem as posições acima do radar ( down )

    Primeiro  vamos adicionar o valor na tabela ( up ) dessa forma:

    local up = {
        [1] = {y*634},
        [2] = {y*677},
        [3] = {y*718},
        [4] = {y*565}, -- valor y do dxDrawImage
    }

    Ok, temos o valor na primeira tabela. Agora vamos a segunda: 

    Como eu não tenho o valor exato de onde ficaria vamos ter que fazer um conta simples, para obtê-lo

    Para isso eu pego o valor Y do primeiro retângulo menos o valor Y do "fundo"

    ficaria assim 634 - 565 o resultado é 69 px ( px é pixels)

    Agora, na tabela ( down ) o que temos que fazer é  subtrair o valor do primeiro retângulo menos a nossa diferença:

    local down = {
        [1] = {y*426},
        [2] = {y*464},
        [3] = {y*502},
    }

    426 - 69 que é igual a 357 px ( px é pixels)

    e fica assim a tabela 2 ( down )

    local down = {
        [1] = {y*426},
        [2] = {y*464},
        [3] = {y*502},
        [4] = {y*357},
    }

    Agora que obtemos os dois valores vamos as funções.

    3 - Variáveis e interpolate: Perceba que para cada retângulo temos um interpolate novo, isto se deve ao fato de que cada retângulo possui sua própria posição.

    Nas duas functions ( onVeh e onFoot ) teremos que adicionar novos interpolates

    Vamos fazer assim:

    onVeh:

        local x1, y1, z1 = interpolate(0, up[1][1], 0, 0, down[1][1], 0, inicio2, 1000, "Linear")
        local x2, y2, z2 = interpolate(0, up[2][1], 0, 0, down[2][1], 0, inicio2, 1000, "Linear")
        local x3, y3, z3 = interpolate(0, up[3][1], 0, 0, down[3][1], 0, inicio2, 1000, "Linear")
        local x4, y4, z4 = interpolate(0, up[4][1], 0, 0, down[4][1], 0, inicio2, 1000, "Linear") -- interpolate do dxDrawImage (o fundo)

    onFoot:

            local x1, y1, z1 = interpolate(0, down[1][1], 0, 0, up[1][1], 0, inicio, 1000, "Linear")
            local x2, y2, z2 = interpolate(0, down[2][1], 0, 0, up[2][1], 0, inicio, 1000, "Linear")
            local x3, y3, z3 = interpolate(0, down[3][1], 0, 0, up[3][1], 0, inicio, 1000, "Linear")
            local x4, y4, z4 = interpolate(0, down[4][1], 0, 0, up[4][1], 0, inicio, 1000, "Linear") -- interpolate do "fundo"

    Criamos 6 novas variáveis, 3 em cada function, agora vamos adicionar o dxDrawImage:

    4 - Adicionando o dx: pegamos o dx que você tem e colocamos ele ACIMA  dos demais dessa forma:

    041Rokr.jpg

    OBS: DX FUNCIONAM COMO CAMADAS

    ex: Se temos um retângulo e embaixo desse retângulo temos uma imagem, a imagem irá cobrir, irá se sobrepor ao retângulo!

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

     

    5 - Adicionando a animação:  Aqui iremos apagar o valor x*565 do dxDrawImage e substituir pela variável y4, dessa forma:

    dxDrawImage(x*48, y4, x*210, y*134, "files/images/interface.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)

    Motivo: como dito anteriormente variáveis possuem valores ( ex: oi = tchau, se eu der print(oi) o que aparecerá no console é a palavra "tchau").

    Quando eu tiro o valor y*565 e substituo pela variável y4 o que estou fazendo é colocar a animação no dxDrawImage ( o fundo).

    Obs: Não se esqueça de adicionar o interpolate e o dx nas duas functions  onVeh e onFoot!!

    Feito todos esses passos, esta pronto! Agora temos um fundo com animação. :)

    Caso não entenda alguma parte leia novamente! xD rs, mas caso ainda reste duvidas só perguntar. ;) 

    @Mopped

     

    • Like 1
    • Thanks 1
  14.  

    3 minutes ago, Mopped said:

    Agora ele está mostrando apenas o ícone da fome (que no caso acredito que está mostrando esse pq seja o primeiro)

    E a Rectangle que indica a fome/sede do jogador:

    local fome = getElementData(getLocalPlayer(), "AirNewSCR_Fome")

    local sede = getElementData(getLocalPlayer(), "AirNewSCR_Sede")

    não está contando, apenas é um quadrado sem nada, sem função.

    o4wwhrD.png

    Qual o erro no debug?

  15. Hm, estranho essa parte de ficar duplicando, pois tem a verificação e a remoção do evento mas enfim.

    Tente o código abaixo.

    Obs: na hora de copiar clique neste botão > http://prntscr.com/qi9y1p

    Assim é certeza que você copiou o código corretamente!

     

    local screenW,screenH = guiGetScreenSize()
    local resW, resH = 1366,768
    local x, y = (screenW/resW), (screenH/resH)
    local font1 = dxCreateFont('files/fonts/font.ttf', 37, false);
    local font2 = dxCreateFont('files/fonts/font.ttf', 25, false);
    local font3 = dxCreateFont('files/fonts/font3.ttf', 20, false);
    local font4 = dxCreateFont('files/fonts/font3.ttf', 25, false);
    local font5 = dxCreateFont('files/fonts/font.ttf', 25, false);
    local fontprice = dxCreateFont('files/fonts/pricedownbl.ttf', 25, false);
    local font10 = dxCreateFont('files/fonts/font10.ttf', 25, false);
    local font11 = dxCreateFont('files/fonts/font11.ttf', 25, false);
    
    function hud()
        if (not isPlayerMapVisible()) then
            local money = ("%008d"):format(getPlayerMoney(getLocalPlayer())) 
            local job = getElementData(getLocalPlayer(), "Emprego") or "Desempregado"
            local cargo = getElementData(localPlayer, "DNL:Cargo") or "Civil"
            local level = getElementData(getLocalPlayer(), "Level") or 0
            local banco = ("%008d"):format(getElementData(getLocalPlayer(), "Bank:Royal")) or 0
            local xp = getElementData(getLocalPlayer(), "LSys:EXP") or 0
            local fome = getElementData(getLocalPlayer(), "AirNewSCR_Fome")
            local sede = getElementData(getLocalPlayer(), "AirNewSCR_Sede")
            local showammo1 = getPedAmmoInClip (localPlayer,getPedWeaponSlot(localPlayer))
    	    local showammo2 = getPedTotalAmmo(localPlayer)-getPedAmmoInClip(localPlayer)
    	    local showammo3 = getPedTotalAmmo(getLocalPlayer())
    	    local clip = getPedAmmoInClip (getLocalPlayer())
    	    local weapon = getPedWeapon ( getLocalPlayer() )
            local arma = getWeaponNameFromID ( weapon )
            local color1 = tocolor(0,255,0,90)
            local Sono = getElementData(getLocalPlayer(), "sono")
            local vehicle = getPedOccupiedVehicle( getLocalPlayer() )
            
            local time = getRealTime()
            local hours = time.hour
            local minutes = time.minute
            local seconds = time.second
            local years = time.year + 1900 
            local month = time.month + 1 
            local day = time.monthday
        if (hours >= 0 and hours < 10) then
            hours = "0"..time.hour
        end
        if (minutes >= 0 and minutes < 10) then
        	minutes = "0"..time.minute
        end
        if (seconds >= 0 and seconds < 10) then
        	seconds = "0"..time.second
        end
           dxDrawText(job, x*1495, y*110, x*1026, y*90, tocolor(255, 255, 255, 255), x*0.60, fontprice, "center", "center", false, false, false, false, false)
            dxDrawText('Level: '..level, x*1490, y*185, x*1026, y*90, tocolor(255, 255, 255, 255), x*0.60, fontprice,"center", "center", false, false, false, false, false)
            dxDrawText('EXP: '..xp, x*1490, y*220, x*1026, y*90, tocolor(255, 255, 255, 255), x*0.60, fontprice,"center", "center", false, false, false, false, false)
            dxDrawText(''..money, x*1505, y*275, x*1026, y*90, tocolor(144,238,144), x*0.70, fontprice, "center", "center", false, false, false, false, false)
            dxDrawText(''..banco, x*1505, y*325, x*1026, y*90, tocolor(30, 144, 255, 255), x*0.70, fontprice, "center", "center", false, false, false, false, false)
            dxDrawText(""..hours..":"..minutes..":"..seconds.."", x*1498, y*380, x*1026, y*90, tocolor(255, 255, 255, 255), x*0.45, font10, "center", "center", false, false, false, false, false)
            dxDrawText(""..day.."/"..month.."/"..years.."", x*1498, y*420, x*1026, y*90, tocolor(255, 255, 255, 255), x*0.40, font10, "center", "center", false, false, false, false, false)
            dxDrawText('KMKRP', x*1445, y*-10, x*1026, y*90, tocolor(255, 255, 255, 255), x*0.70, font3, "center", "center", false, false, false, false, false) 
            dxDrawText('#', x*1360, y*-10, x*1026, y*90, tocolor(255, 255, 255, 255), x*0.70, font10, "center", "center", false, false, false, false, false)   
            dxDrawImage(x*1153, y*597, x*210, y*134, "files/images/interface.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
            dxDrawImage(x*1275, y*-4, x*80, y*85, "files/images/logo.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
            dxDrawImage(x*1185, y*196, x*24, y*24, "files/images/card.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
             dxDrawImage(x*1185, y*172, x*24, y*24, "files/images/money.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
            dxDrawText("Arma: "..arma.. " || Munição: " ..tostring (showammo1).." / "..tostring (showammo2), x*216, y*1480, x*132, y*20, tocolor(255, 255, 255, 255), 0.40, font10, "center", "center", false, false, false, false, false)
        end
    end
    
    local up = {
        [1] = {y*634},
        [2] = {y*677},
        [3] = {y*718},
    }
    
    local down = {
        [1] = {y*426},
        [2] = {y*464},
        [3] = {y*502},
    }
    
    function onVeh()
        local x1, y1, z1 = interpolate(0, up[1][1], 0, 0, down[1][1], 0, inicio2, 1000, "Linear")
        local x2, y2, z2 = interpolate(0, up[2][1], 0, 0, down[2][1], 0, inicio2, 1000, "Linear")
        local x3, y3, z3 = interpolate(0, up[3][1], 0, 0, down[3][1], 0, inicio2, 1000, "Linear")
       
        dxDrawImage(x*54, y1, x*36, y*36, "files/images/comida.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)        
        dxDrawRectangle(x*100, y1, x*150, y*35, tocolor(0, 0, 0, 140), false)    
        dxDrawRectangle(x*100, y1, x*150/100*fome, y*35, tocolor(255, 165, 0), false)
    
        dxDrawImage(x*54, y2, x*36, y*36, "files/images/sede.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)              
        dxDrawRectangle(x*100, y2, x*150, y*35, tocolor(0, 0, 0, 140), false)
        dxDrawRectangle(x*100, y2, x*150/100*sede, y*35, tocolor(16, 102, 231, 200), false)
    
        dxDrawImage(x*54, y3, x*36, y*36, "files/images/iconeSONO.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
        dxDrawRectangle(x*100, y3, x*150, y*35, tocolor(0, 0, 0, 140), false)
        dxDrawRectangle(x*100, y3, x*150/100*Sono, y*35, tocolor(138, 43, 226, 200), false)
    end
    
    function onFoot()
        if inicio then
            local x1, y1, z1 = interpolate(0, down[1][1], 0, 0, up[1][1], 0, inicio, 1000, "Linear") -- animação retangulo 1
            local x2, y2, z2 = interpolate(0, down[2][1], 0, 0, up[2][1], 0, inicio, 1000, "Linear") -- animação retangulo 2
            local x3, y3, z3 = interpolate(0, down[3][1], 0, 0, up[3][1], 0, inicio, 1000, "Linear") -- animação retangulo 3
    
            dxDrawImage(x*54, y1, x*36, y*36, "files/images/comida.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)        
            dxDrawRectangle(x*100, y1, x*150, y*35, tocolor(0, 0, 0, 140), false)    
            dxDrawRectangle(x*100, y1, x*150/100*fome, y*35, tocolor(255, 165, 0), false)
    
            dxDrawImage(x*54, y2, x*36, y*36, "files/images/sede.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)              
            dxDrawRectangle(x*100, y2, x*150, y*35, tocolor(0, 0, 0, 140), false)
            dxDrawRectangle(x*100, y2, x*150/100*sede, y*35, tocolor(16, 102, 231, 200), false)
    
            dxDrawImage(x*54, y3, x*36, y*36, "files/images/iconeSONO.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
            dxDrawRectangle(x*100, y3, x*150, y*35, tocolor(0, 0, 0, 140), false)
            dxDrawRectangle(x*100, y3, x*150/100*Sono, y*35, tocolor(138, 43, 226, 200), false)
        else
            dxDrawImage(x*54, y*634, x*36, y*36, "files/images/comida.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)        
            dxDrawRectangle(x*100, y*634, x*150, y*35, tocolor(0, 0, 0, 140), false)    
            dxDrawRectangle(x*100, y*634, x*150/100*fome, y*35, tocolor(255, 165, 0), false)
    
            dxDrawImage(x*54, y*677, x*36, y*36, "files/images/sede.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)              
            dxDrawRectangle(x*100, y*677, x*150, y*35, tocolor(0, 0, 0, 140), false)
            dxDrawRectangle(x*100, y*677, x*150/100*sede, y*35, tocolor(16, 102, 231, 200), false)
    
            dxDrawImage(x*54, y*718, x*36, y*36, "files/images/iconeSONO.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
            dxDrawRectangle(x*100, y*718, x*150, y*35, tocolor(0, 0, 0, 140), false)
            dxDrawRectangle(x*100, y*718, x*150/100*Sono, y*35, tocolor(138, 43, 226, 200), false)
        end
    end
    addEventHandler("onClientRender", root, onFoot, false)
    
    function onVehEnter(p)
        if p == getLocalPlayer() then
            if (not inicio2) then
                inicio2 = getTickCount()
                addEventHandler("onClientRender", root, onVeh, false)
                if isEventHandlerAdded( 'onClientRender', root, onFoot) then
                    removeEventHandler('onClientRender', root, onFoot, false)
                end
                if inicio then
                    inicio = nil
                end
            end
        end
    end
    addEventHandler ("onClientVehicleEnter", root, onVehEnter)
    
    function onVehExit(p)
        if p == getLocalPlayer() then
            if (not inicio) then
                inicio = getTickCount()
                addEventHandler("onClientRender", root, onFoot, false)
                if isEventHandlerAdded( 'onClientRender', root, onVeh) then
                    removeEventHandler('onClientRender', root, onVeh, false)
                end
                if inicio2 then
                    inicio2 = nil
                end
           end
        end
    end
    addEventHandler ("onClientVehicleExit", root, onVehExit)
    
    local components = { "area_name", "radio", "vehicle_name" }
    local hud_components = {"armour", "wanted", "weapon", "money", "health", "clock", "breath", "ammo", "radar"}
    
    function setHud()
        addEventHandler("onClientRender", getRootElement(), hud)
        for _, hud_component in ipairs( hud_components) do
            setPlayerHudComponentVisible( hud_component, false )
        end
        for _, component in ipairs( components ) do
            setPlayerHudComponentVisible( component, false )
        end
    end
    addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), setHud)
    
    function removeHud()
        for _, hud_component in ipairs( hud_components) do
            setPlayerHudComponentVisible( hud_component, true )
        end
    end
    addEventHandler("onClientResourceStop", getResourceRootElement(getThisResource()), removeHud)
    
    function interpolate(varX1, varY1, varZ1, varX2, varY2, varZ2, inicio, timer, animation)
        local tempo = getTickCount()
        local fim = inicio + timer
        local tempoDecorrido = tempo - inicio
        local duracao = fim - inicio
        local progresso = tempoDecorrido / duracao 
        if (progresso > 1) then
    		progresso = 1
        end
        local varX1, varY1, varZ1 = interpolateBetween (varX1, varY1, varZ1, varX2, varY2, varZ2, progresso, animation) 
        return varX1, varY1, varZ1
    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
    
    function convertNumber ( number )   
        local formatted = number   
        while true do       
            formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1.%2')     
            if ( k==0 ) then       
                break   
            end   
        end   
        return formatted 
    end

     

    • Thanks 1
  16. -- tabela posição Y que fica no mesmo lugar que o radar
    local posSubir = {
        [1] = {634}, -- retangulo 1
        [2] = {677}, -- retangulo 2
        [3] = {718}, -- retangulo 3
    }
    -- tabela posição Y que fica acima do radar
    local posDescer = {
        [1] = {426}, -- retangulo 1
        [2] = {464}, -- retangulo 2
        [3] = {502}, -- retangulo 3
    }
    
    
        -- x = posição x
        -- y = posição y
        -- w = largura
        -- h = altura
         
        -- dx é tipo um plano cartesiano: (https://s1.static.brasilescola.uol.com.br/be/conteudo/images/plano-formado-por-duas-retas-perpendiculares-para-marcar-localizacoes-57d931d798001.jpg)
    
    
        -- x é a (reta) ← 0 →
    
    	--                           ↑
        -- y é o que (sobe ou desce) 0
    	--                           ↓
    
    
    
    -- dx quando o player ENTRAR no veiculo
    function onVeh()
        --    variaveis     func.util  x1     y1         z1  x2      y2         z2   tick   tempo   tipo animação
        local x1, y1, z1 = interpolate(0, posSubir[1][1], 0, 0, posDescer[1][1], 0, inicio2, 1000, "Linear") -- animação retangulo 1
        local x2, y2, z2 = interpolate(0, posSubir[2][1], 0, 0, posDescer[2][1], 0, inicio2, 1000, "Linear") -- animação retangulo 2
        local x3, y3, z3 = interpolate(0, posSubir[3][1], 0, 0, posDescer[3][1], 0, inicio2, 1000, "Linear") -- animação retangulo 3
        
      -- retangulos 1 ↓
        --          x    y   w   h
        dxDrawImage(849, y1, 36, 36, "files/images/comida.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)        
        dxDrawRectangle(895, y1, 150, 35, tocolor(0, 0, 0, 140), false)    
        dxDrawRectangle(895, y1, 150/100*fome, 35, tocolor(255, 165, 0), false)
      
      -- retangulos 2 ↓
        dxDrawImage(849, y2, 36, 36, "files/images/sede.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)              
        dxDrawRectangle(895, y2, 150, 35, tocolor(0, 0, 0, 140), false)
        dxDrawRectangle(895, y2, 150/100*sede, 35, tocolor(16, 102, 231, 200), false)
      
    -- retangulos 3 ↓
        dxDrawImage(849, y3, 36, 36, "files/images/iconeSONO.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
        dxDrawRectangle(895, y3, 150, 35, tocolor(0, 0, 0, 140), false)
        dxDrawRectangle(895, y3, 150/100*Sono, 35, tocolor(138, 43, 226, 200), false)
    
        -- perceba que só alteramos com o valor de Y com as variaveis y1, y2 e y3. Essas variaveis é o que contem a animação
      	-- lembre-se variavel contem um valor, no caso dessas o valor são as animações!
    
    end
    
    -- dx quando o player SAIR no veiculo
    function onFoot()
        if inicio then  -- verifica se existe o tick (inicio) (anti-bug)
    
            local x1, y1, z1 = interpolate(0, posDescer[1][1], 0, 0, posSubir[1][1], 0, inicio, 1000, "Linear") -- animação retangulo 1
            local x2, y2, z2 = interpolate(0, posDescer[2][1], 0, 0, posSubir[2][1], 0, inicio, 1000, "Linear") -- animação retangulo 2
            local x3, y3, z3 = interpolate(0, posDescer[3][1], 0, 0, posSubir[3][1], 0, inicio, 1000, "Linear") -- animação retangulo 3
    
            dxDrawImage(849, y1, 36, 36, "files/images/comida.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)        
            dxDrawRectangle(895, y1, 150, 35, tocolor(0, 0, 0, 140), false)    
            dxDrawRectangle(895, y1, 150/100*fome, 35, tocolor(255, 165, 0), false)
    
            dxDrawImage(849, y2, 36, 36, "files/images/sede.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)              
            dxDrawRectangle(895, y2, 150, 35, tocolor(0, 0, 0, 140), false)
            dxDrawRectangle(895, y2, 150/100*sede, 35, tocolor(16, 102, 231, 200), false)
    
            dxDrawImage(849, y3, 36, 36, "files/images/iconeSONO.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
            dxDrawRectangle(895, y3, 150, 35, tocolor(0, 0, 0, 140), false)
            dxDrawRectangle(895, y3, 150/100*Sono, 35, tocolor(138, 43, 226, 200), false)
        else
            dxDrawImage(849, 634, 36, 36, "files/images/comida.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)        
            dxDrawRectangle(895, 634, 150, 35, tocolor(0, 0, 0, 140), false)    
            dxDrawRectangle(895, 634, 150/100*fome, 35, tocolor(255, 165, 0), false)
    
            dxDrawImage(849, 677, 36, 36, "files/images/sede.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)              
            dxDrawRectangle(895, 677, 150, 35, tocolor(0, 0, 0, 140), false)
            dxDrawRectangle(895, 677, 150/100*sede, 35, tocolor(16, 102, 231, 200), false)
    
            dxDrawImage(849, 718, 36, 36, "files/images/iconeSONO.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
            dxDrawRectangle(895, 718, 150, 35, tocolor(0, 0, 0, 140), false)
            dxDrawRectangle(895, 718, 150/100*Sono, 35, tocolor(138, 43, 226, 200), false)
        end
    end
    addEventHandler("onClientRender", root, onFoot, false)
    
    -- evento onde o player entra no veículo
    function onVehEnter(p)
        if p == getLocalPlayer() then -- verificação se thePlayer(p) é igual ao client
            inicio2 = getTickCount() -- salva o tempo 
            addEventHandler("onClientRender", root, onVeh, false) -- adicionar o dx de entrar
            if isEventHandlerAdded( 'onClientRender', root, onFoot) then -- se o dx de sair existir então:
                removeEventHandler('onClientRender', root, onFoot, false) -- remove / destroi ele
            end
        end
    end
    addEventHandler ("onClientVehicleEnter", root, onVehEnter)
    
    -- evento onde o player sai do veículo
    function onVehExit(p)
        if p == getLocalPlayer() then -- verificação se thePlayer(p) é igual ao client
            inicio = getTickCount() -- salva o tempo
            addEventHandler("onClientRender", root, onFoot, false) -- adicionar o dx de sair
            if isEventHandlerAdded( 'onClientRender', root, onVeh) then -- se o dx de entrar existir então:
                removeEventHandler('onClientRender', root, onVeh, false) -- remove / destroi ele
            end
        end
    end
    addEventHandler ("onClientVehicleExit", root, onVehExit)
    
    --------------------------------------------------------- funções uteis -------------------------------------------------------------------
    
    -- interpolate       posX   posY   posZ   posX1  posY1  posX1   tick   tempo  tipo de animação
    function interpolate(varX1, varY1, varZ1, varX2, varY2, varZ2, inicio, timer, animation)
        local tempo = getTickCount() -- pega o tempo
        local fim = inicio + timer -- conta
        local tempoDecorrido = tempo - inicio -- conta
        local duracao = fim - inicio -- mais conta
        local progresso = tempoDecorrido / duracao -- resultado da contas
        if (progresso > 1) then -- verificação
    		progresso = 1
        end
      -- no interpolate ele requer no min. 8 argumentos 
      -- start: (onde começa) 
      -- end: (onde termina)
      -- progresso: o tempo que leva para ele ir do inicio ao fim
      -- animation: o tipo de animação
      --                                                 arg1,  arg2,  arg3,  arg4,  arg5,  arg6,    arg7,    arg8
        --    3 variaveis                        start:   x     y      z   end: x     y      z     progresso  animation
        local varX1, varY1, varZ1 = interpolateBetween (varX1, varY1, varZ1, varX2, varY2, varZ2, progresso, animation) 
        --                                               
        return varX1, varY1, varZ1 -- retorna as posições para as variaveis
    end
    
    -- EventAdded             nome evento      elemento evento   nome da função
    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
    
    --------------------------------------------------------- funções uteis -------------------------------------------------------------------

    Não estou com muito tempo pra explicar mas o código é esse ai. Leia as linhas comentadas!

    Se vc entender o básico de logica acho que consegue entender oq tentei passar...

    Quanto ao que vc me mandou no pv, desculpa mas não costumo ajudar assim. Prefiro soltar os códigos aqui, tanto para outras pessoas que tenham a mesma duvida ou até mesmo para outras pessoas que já entendam melhor que eu vir e melhorar o código.

    Espero ter ajudado, caso tenha duvidas pode perguntar o quanto quiser que tentarei lhe ajudar :)

     

    @Mopped

  17. Mesma coisa que o Lord Comentou, porém com animação e MUUUUITO mais linhas...

    -- tabela posição do radar
    local posSubir = {
        [1] = {218, 609, 168, 28},
        [2] = {218, 647, 168, 28},
        [3] = {218, 685, 168, 28},
    }
    -- tabela posição acima do radar
    local posDescer = {
        [1] = {218, 426, 168, 28},
        [2] = {218, 464, 168, 28},
        [3] = {218, 502, 168, 28},
    }
    
    -- dx quando o player ENTRAR no veiculo
    function onVeh()
        local x1, y1, z1 = interpolate(0, posSubir[1][2], 0, 0, posDescer[1][2], 0, inicio2, 1000, "Linear") -- animação retangulo 1
        local x2, y2, z2 = interpolate(0, posSubir[2][2], 0, 0, posDescer[2][2], 0, inicio2, 1000, "Linear") -- animação retangulo 2
        local x3, y3, z3 = interpolate(0, posSubir[3][2], 0, 0, posDescer[3][2], 0, inicio2, 1000, "Linear") -- animação retangulo 3
    
        dxDrawRectangle(posSubir[1][1], y1, posSubir[1][3], posSubir[1][4], tocolor(255, 255, 255, 255), false) -- retangulo 1
        dxDrawRectangle(posSubir[2][1], y2, posSubir[2][3], posSubir[2][4], tocolor(255, 255, 255, 255), false) -- retangulo 2
        dxDrawRectangle(posSubir[3][1], y3, posSubir[3][3], posSubir[3][4], tocolor(255, 255, 255, 255), false) -- retangulo 3
    end
    
    -- dx quando o player SAIR no veiculo
    function onFoot()
        if inicio then -- (anti-bug) verifica se a váriavel inicio existe, se ela existir então:
            local x1, y1, z1 = interpolate(0, posDescer[1][2], 0, 0, posSubir[1][2], 0, inicio, 1000, "Linear") -- animação retangulo 1
            local x2, y2, z2 = interpolate(0, posDescer[2][2], 0, 0, posSubir[2][2], 0, inicio, 1000, "Linear") -- animação retangulo 2
            local x3, y3, z3 = interpolate(0, posDescer[3][2], 0, 0, posSubir[3][2], 0, inicio, 1000, "Linear") -- animação retangulo 3
    
            dxDrawRectangle(posDescer[1][1], y1, posDescer[1][3], posDescer[1][4], tocolor(255, 255, 255, 255), false) -- retangulo 1
            dxDrawRectangle(posDescer[2][1], y2, posDescer[2][3], posDescer[2][4], tocolor(255, 255, 255, 255), false) -- retangulo 2
            dxDrawRectangle(posDescer[3][1], y3, posDescer[3][3], posDescer[3][4], tocolor(255, 255, 255, 255), false) -- retangulo 3
        else -- se a váriavel não existir então:
            dxDrawRectangle(218, 609, 168, 28, tocolor(255, 255, 255, 255), false) -- retangulo sem animação 1
            dxDrawRectangle(218, 647, 168, 28, tocolor(255, 255, 255, 255), false) -- retangulo sem animação 2
            dxDrawRectangle(218, 685, 168, 28, tocolor(255, 255, 255, 255), false) -- retangulo sem animação 3
        end
    end
    addEventHandler("onClientRender", root, onFoot)
    
    -- evento onde o player entra no veículo
    function onVehEnter()
        inicio2 = getTickCount() -- salva o tempo 
        addEventHandler("onClientRender", root, onVeh) -- adicionar o dx de entrar
        if isEventHandlerAdded( 'onClientRender', root, onFoot) then -- se o dx de sair existir então:
            removeEventHandler('onClientRender', root, onFoot) -- remove / destroi ele
        end
    end
    addEventHandler ("onClientVehicleEnter", root, onVehEnter)
    
    -- evento onde o player sai do veículo
    function onVehExit()
        inicio = getTickCount() -- salva o tempo
        addEventHandler("onClientRender", root, onFoot) -- adicionar o dx de sair
        if isEventHandlerAdded( 'onClientRender', root, onVeh) then -- se o dx de entrar existir então:
            removeEventHandler('onClientRender', root, onVeh) -- remove / destroi ele
        end
    end
    addEventHandler ("onClientVehicleExit", root, onVehExit)
    
    --------------------------------------------------------- funções uteis -------------------------------------------------------------------
    
    -- interpolate       posX   posY   posZ   posX1  posY1  posX1   tick   tempo  tipo de animação
    function interpolate(varX1, varY1, varZ1, varX2, varY2, varZ2, tick1, timer, animation)
        local tick2 = getTickCount()
        local fim = tick1 + timer
        local tempoDecorrido = tick2 - tick1
        local duracao = fim - inicio 
        local progresso = tempoDecorrido / duracao
        if (progresso > 1) then
    		progresso = 1
    	end
        local varX1, varY1, varZ1 = interpolateBetween (varX1, varY1, varZ1, varX2, varY2, varZ2, progresso, animation) 
        return varX1, varY1, varZ1
    end
    
    -- EventAdded             nome evento      elemento evento   nome da função
    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
    
    --------------------------------------------------------- funções uteis -------------------------------------------------------------------

     

    • Confused 1
  18. Bom esta perca ocorre devido ao fato de que o setElementData trabalha somente na "sessão" atual do player, toda vez que ele sair ou reconectar, ele irá iniciar uma nova "sessão", no seu caso para salvar estas informações vc vai precisar de:

    getElementData  verifica a data do porte se for verdadeiro "true" ou seja lá o valor que você tenha colocado para a data então

    setAccountData  seta uma data na conta do player

    getAccountData verifica se existe a data criada com setAccountData

    setElementData seta a data do porte novamente, fazendo com o player não a perca!

    Basicamente o que vc deve fazer é toda vez que o player entrar no servidor se ele já tiver o porte da-lo novamente a ele!

    Eventos Usados:

    onPlayerQuit  para quando o player sair do servidor, vc irá verificar se ele tem o porte (getElementData) e salvar na conta (setAccountData)

    onPlayerLogin  para quando o player Logar no servidor, vc irá verificar se a conta dele esta salva o porte ( getAccountData) e dará novamente a ele ( setElementData)

     

×
×
  • Create New...