Jump to content

LucasST

Members
  • Posts

    61
  • Joined

  • Last visited

Posts posted by LucasST

  1. Vou dar um exemplo por enquanto utilizando ElementData, pois acl utilizaria eventos para a verificação da mesma.

     

    Spoiler
    
    local drawDistance = 7
    g_StreamedInPlayers = {}
    
    function onClientRender()
        local cx, cy, cz, lx, ly, lz = getCameraMatrix()
        if getElementData(localPlayer, "STAFF") then
            for k, player in pairs(g_StreamedInPlayers) do
                if isElement(player) and isElementStreamedIn(player) then
                    local vx, vy, vz = getPedBonePosition(player, 4)
                    local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz)
                    if dist < drawDistance and isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false) then
                        local x, y = getScreenFromWorldPosition(vx, vy, vz + 0.3)
                        if x and y then
                            if getElementAlpha(player) > 0 then -- se o alpha do player for maior que 0 mostra o ID
                                local ID = getElementData(player, "ID") or "N/A"
                                local w = dxGetTextWidth(ID, 0.1, "default-bold")
                                local h = dxGetFontHeight(1, "default-bold")
                                dxDrawText(""..ID.."", x - 1 - w / 1, y - 1 - h - 12, w, h, CorTag, 1.20, "default-bold", "left", "top", false, false, false, false, false)   
                                CorTag = tocolor(255, 255, 255)
                                if getElementData(player, "Cor", true) then
                                    CorTag = tocolor(0, 255, 0)
                                end
                            end
                        end
                    end
                else
                    table.remove(g_StreamedInPlayers, k)
                end
            end
        end
    end
    addEventHandler("onClientRender", root, onClientRender)
    
    function CorTagid ()
        if getElementData(localPlayer, "Cor", true) then
            setElementData(localPlayer, "Cor", false)
        else
            setElementData(localPlayer, "Cor", true)
        end
    end
    bindKey ( "z", "both", CorTagid )
    
    function onClientElementStreamIn()
        if getElementType(source) == "player" and source ~= getLocalPlayer() then
            setPlayerNametagShowing(source, false)
            table.insert(g_StreamedInPlayers, source)
        end
    end
    addEventHandler("onClientElementStreamIn", root, onClientElementStreamIn)
    
    function onClientResourceStart()
        local players = getElementsByType("player")
        for k, v in pairs(players) do
            if isElementStreamedIn(v) and v ~= getLocalPlayer() then
                setPlayerNametagShowing(v, false)
                table.insert(g_StreamedInPlayers, v)
            end
        end
    end
    addEventHandler("onClientResourceStart", resourceRoot, onClientResourceStart)

     

     

  2. Criação das Tabelas

    dbExec(connection, "CREATE TABLE IF NOT EXISTS shops (id INT, type INT, x REAL, y REAL, z REAL, rotation REAL, skin INT, interior INT, dimension INT)")

     

     

    Query

    local Query = dbQuery(connection, "INSERT INTO shops (x, y, z, dimension, interior, rotation, skin, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", x, y, z, dim, int, rot, skinid, shopid)

     

    local result = dbPoll(Query, -1)
    dbFree(Query)

     

     

    ou

     

     

    dbExec(connection, "INSERT INTO shops (x, y, z, dimension, interior, rotation, skin, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", x, y, z, dim, int, rot, skinid, shopid)

     

  3. É Possível utilizar posições do seu mouse para mover objetos ?, testei uns exemplos do próprio fórum mais não está retornando as posições corretas.

     

    Obj = {}
    
    function teste()
        if Obj[localPlayer] and isElement(Obj[localPlayer]) then
            destroyElement(Obj[localPlayer])
            Obj[localPlayer] = nil
        end
        Obj[localPlayer] = createObject(964, 656.042, -1120.322, 48.605)
    end
    addCommandHandler("teste2",teste)
    
    addEventHandler( "onClientRender", getRootElement( ),
    function ()
        if isCursorShowing() and Obj[localPlayer] and isElement(Obj[localPlayer]) then
            local sx, sy = guiGetScreenSize()
            local relX, relY = getCursorPosition()
            local cursorX, cursorY = relX * sx, relY * sy
            local camX, camY, camZ = getCameraMatrix()
            local cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ = getWorldFromScreenPosition(cursorX, cursorY, 1000)
            local z = getGroundPosition(Vector3(getElementPosition(localPlayer)))
            setElementPosition(Obj[localPlayer], cursorWorldPosX, cursorWorldPosY, z)
        end
    end
    )

     

  4. 
    
    local screenW, screenH = guiGetScreenSize ()
    local resW, resH = 1920,1080
    local x, y = (screenW/resW), (screenH/resH)
    
    TabelasInfos = {
        {"Julio"},
        {"Maria"},
        {"Lucas"},
        {"João"},
        {"Julia"},
        {"Marcos"},
        {"Daniel"},
        {"Sabrina"},
        {"Thiago"},
    }
    
    
    function Abrir_Painel()
        if isEventHandlerAdded("onClientRender",getRootElement(), DxTest) then
            removeEventHandler("onClientRender",root,DxTest)
            showCursor(false)
        else
            addEventHandler("onClientRender",root,DxTest)
            showCursor(true)
            Pos = {
                [1] = {1,726, 330, 343, 37},
                [2] = {2,726, 405, 343, 37},
                [3] = {3,726, 480, 343, 37},
                [4] = {4,726, 555, 343, 37},
            }
            Selecionado = 0
        end
    end
    bindKey("l","down",Abrir_Painel)
    
    function DxTest()
        dxDrawRectangle(x*724, y*261, x*345, y*381, tocolor(1, 0, 0, 102), false)
        dxDrawRectangle(x*725, y*258, x*344, y*63, tocolor(1, 0, 0, 248), false)
        for i = 1,#Pos do
            if #TabelasInfos >= Pos[i][1] then
                local Index = Pos[i][1]
                if Selecionado == Index then
                    dxDrawRectangle(x*Pos[i][2],y*Pos[i][3],x*Pos[i][4],y*Pos[i][5], tocolor(1, 0, 0, 200), false)
                else
                    dxDrawRectangle(x*Pos[i][2],y*Pos[i][3],x*Pos[i][4],y*Pos[i][5], tocolor(1, 0, 0, 150), false)
                end
                dxDrawText(""..TabelasInfos[Index][1].."", x*(Pos[i][2] + 160), y*(Pos[i][3] +11), x*1070, y*369, tocolor(255, 254, 254, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
            end
        end
    end
    
    
    function TrocarPos(button)
        if isEventHandlerAdded("onClientRender",root,DxTest) then
            if isCursorOnElement(x*724, y*319, x*345, y*321) then
                if button == "mouse_wheel_down" then
                    if #TabelasInfos > Pos[#Pos][1] then
                        for i = 1,#Pos do
                            Pos[i][1] = Pos[i][1] +1
                        end
                    end
                elseif button == "mouse_wheel_up" then
                    if Pos[1][1] ~= 1 then
                        for i = 1,#Pos do
                            Pos[i][1] = Pos[i][1] -1
                        end
                    end
                end
            end
        end
    end
    bindKey("mouse_wheel_down", "down",TrocarPos)
    bindKey("mouse_wheel_up", "down",TrocarPos )
    
    
    function SelecionarPos(b,s)
        if isEventHandlerAdded("onClientRender",root,DxTest) then
            if b == "left" and s == "down" then
                for i = 1,#Pos do
                    if isCursorOnElement(x*Pos[i][2],y*Pos[i][3],x*Pos[i][4],y*Pos[i][5]) then
                        if Selecionado ~= Pos[i][1] then
                            Selecionado = Pos[i][1]
                        else
                            Selecionado = 0
                        end
                    end
                end
            end
        end
    end
    addEventHandler("onClientClick",root,SelecionarPos)
    
    
    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 isCursorOnElement(x, y, w, h)
    	if (not isCursorShowing()) then
    		return false
    	end
    	local mx, my = getCursorPosition()
    	local fullx, fully = guiGetScreenSize()
    	cursorx, cursory = mx*fullx, my*fully
    	if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
    		return true
    	else
    		return false
    	end
    end

    A Antiga ficou com muitas coisas desnecessárias, dei uma melhorada.

  5. function finalizartrab (player, dimension) -- <-- NÃO EXISTE O PARAMETRO THE VEHICLE NO ONMARKERHIT, AQUI SERIA DIMENSÃO
    	if getElementData(player,"trabAviaoParte3") then
    		if veh[player] and isElement(veh[player]) then
    			local vehicle = getPedOccupiedVehicle(player) -- NÃO PRECISA COLOCAR VARIAS VARIAVEIS DE VEICULO PQ 1 JÁ BASTA
                if vehicle then
    				local currentFreezeStatus = isElementFrozen ( vehicle )
    				local newFreezeStatus = not currentFreezeStatus
    				setElementPosition(vehicle, 1477.443, 1712.498, 11.2 + 1.5)
    				setElementRotation(vehicle, -0, 0, 359.225)
    				setElementFrozen ( vehicle, true )
    				outputChatBox ( "[#FF0000 Aeronauta #000000]#FFFFFF Os passageiros estao deembarcando, aguarde...", player, 0, 0, 0, true )
    				setElementVisibleTo ( entraga3final, player, false )
    				setElementVisibleTo ( blipentrega3, player, false )
    				setElementData(player, "trabAviaoParte3", false)
    				setElementData(player, "emTrabalho", false)
    				setTimer (function()
    					outputChatBox ( "[#FF0000 Aeronauta #000000]#FFFFFF Todos os passageiros deembarcaram. Voce terminou seu trabalho com sucesso!", sourplayerce, 0, 0, 0, true )
    					outputDebugString("[TrabAviao] "..getPlayerName(player):gsub("#%x%x%x%x%x%x","").." Completou o trabalho de aviao!",3,0,255,0)
    					local model = getElementModel(vehicle)
    					if model == 592 or model == 577 then
    						outputChatBox ( "[#FF0000 Aeronauta #000000]#FFFFFF E Recebeu mais #00FF00R$45.000#FFFFFF por entregar com o Andromada ou AT-400, totalizando #00FF00R$75.000", player, 0, 0, 0, true )
    						givePlayerMoney (player, 45000)
    					else
    						outputChatBox ( "[#FF0000 Aeronauta #000000]#FFFFFF E Recebeu mais #00FF00R$30.000#FFFFFF, totalizando #00FF00R$60.000", player, 0, 0, 0, true )
    						givePlayerMoney (player, 30000)
    					end
                        destroyElement(veh[player])
                        veh[player] = nil
    				end, 5000, 1)
    			end
    		end
    	end
    end
    addEventHandler( "onMarkerHit", entraga3final, finalizartrab )

    Você Estava Destruindo o Veiculo Dps Conferindo o Modelo Dele, Sendo que ele Não Existe Mais, Assim Causando o Erro.

    • Thanks 1
  6. local progress = interpolateBetween(0,0,0,100,0,0,(getTickCount() - tick)/5000, "Linear")

    Não esqueça de coloca o

    tick = getTickCount()

    Ao abrir o painel, tbm utilize o math.floor para converter os números quebrados (1.5,2.5) para números inteiros [Apenas coloque se quiser utilizar em porcentagem (50%, 51%)]

  7. Você Pode Estar Utilizando o setTimer para colocar o delay, e identificar se ele passou por um ElementData ou por uma Tabela.

    Exemplo Que Recomendo :

    PassouMarker = {}
    Marker1 = createMarker ( 1005.14197, 831.82520, 32.85537, "cylinder", 1.5, 255, 255, 255, 50 ) 
    
    function msg(thePlayer)
        if getElementType(thePlayer) == "player" then -- ISSO É PRA NÃO DAR ERRO NO DEBUG QUANDO PASSAR NO MARKER COM UM VEICULO
            if not PassouMarker[thePlayer] then
                outputChatBox("=============== ARMAS PRF ================",player, 0, 0, 255, true)
                outputChatBox("- Digite /rifle para pegar seu Rifle.",player, 255, 255, 0, true)
                outputChatBox("- Digite /sub para pegar sua Submetralhadora.",player, 255, 255, 0, true)
                outputChatBox("- Digite /shotgun para pegar sua Shotgun.",player, 255, 255, 0, true)
                outputChatBox("- Digite /deagle para pegar sua Pistola.",player, 255, 255, 0, true)
                outputChatBox("- Digite /tazer para pegar seu Tazer.",player, 255, 255, 0, true)
                outputChatBox("- Digite /cacetete para pegar seu Cacetete.",player, 255, 255, 0, true)
                outputChatBox("=============== ARMAS PRF ================",player, 0, 0, 255, true)
                PassouMarker[thePlayer] = true
                setTimer(function()
                    PassouMarker[thePlayer] = false
                end,5000,1) -- 5000 = 5 Segundos, o 1 Seria Para Só Fazer 1 vez
            end
        end
    end
    addEventHandler("onMarkerHit", Marker1, msg)

    Outro Exemplo  :

    Marker1 = createMarker ( 1005.14197, 831.82520, 32.85537, "cylinder", 1.5, 255, 255, 255, 50 ) 
    
    function msg(thePlayer)
        if getElementType(thePlayer) == "player" then -- ISSO É PRA NÃO DAR ERRO NO DEBUG QUANDO PASSAR NO MARKER COM UM VEICULO
            if not getElementData(thePlayer, "PassouMarker") then
                outputChatBox("=============== ARMAS PRF ================",player, 0, 0, 255, true)
                outputChatBox("- Digite /rifle para pegar seu Rifle.",player, 255, 255, 0, true)
                outputChatBox("- Digite /sub para pegar sua Submetralhadora.",player, 255, 255, 0, true)
                outputChatBox("- Digite /shotgun para pegar sua Shotgun.",player, 255, 255, 0, true)
                outputChatBox("- Digite /deagle para pegar sua Pistola.",player, 255, 255, 0, true)
                outputChatBox("- Digite /tazer para pegar seu Tazer.",player, 255, 255, 0, true)
                outputChatBox("- Digite /cacetete para pegar seu Cacetete.",player, 255, 255, 0, true)
                outputChatBox("=============== ARMAS PRF ================",player, 0, 0, 255, true)
                setElementData(thePlayer,"PassouMarker",true)
                setTimer(function()
                    setElementData(thePlayer,"PassouMarker",false)
                end,5000,1) -- 5000 = 5 Segundos, o 1 Seria Para Só Fazer 1 vez
            end
        end
    end
    addEventHandler("onMarkerHit", Marker1, msg)

     

  8. Spoiler
    
    DiasMes = {
        [2021] = {
            [1] = 31,
            [2] = 28,
            [3] = 31,
            [4] = 30,
            [5] = 30,
            [6] = 30,
            [7] = 31,
            [8] = 31,
            [9] = 30,
            [10] = 31,
            [11] = 30,
            [12] = 31,
        },
        [2022] = {
            [1] = 31,
            [2] = 28,
            [3] = 31,
            [4] = 30,
            [5] = 30,
            [6] = 30,
            [7] = 31,
            [8] = 31,
            [9] = 30,
            [10] = 31,
            [11] = 30,
            [12] = 31,
        },
    }
    
    local time = getRealTime()
    diaHj = time.monthday
    mesHj = time.month +1
    anoHj = time.year +1900
    dias = 100
    if DiasMes[anoHj] then
        for i = 1, dias do
            if mesHj == 13 then
                mesHj = 1
                diaHj = 1
                anoHj = anoHj +1
            end
            if diaHj == DiasMes[anoHj][mesHj] then
                mesHj = mesHj +1
                diaHj = 1
            else
                diaHj = diaHj +1
            end
        end
        print(diaHj,mesHj,anoHj)
    end

     

    Opa Estou Tentando Fazer uma Soma da Data de Hoje + a quantidade de dias que eu quero, dps disso ele irá retornar a data enquanto passarem esses dias, Estava funcionando normalmente só que quando chega ao mês 13 coloquei para setar o ano +1 e coloquei o mês e data como 1, só que invés de setar o ano +1 ele está fazendo a repetição 2x, isso setando o ano como 2023, a dúvida seria se pode estar acontecendo isso pelo loop ou por algum erro no código e se há alguma maneira de resolver.

  9. Acho que dei uma entendida no que você precisa

    -----[Marker Entrar] -----
    
    Markers_Enter = {
        {1, 1, -3, 4, 3}, -- interior, dimensão, x, y, z
        {1, 2, 1, 3, 3}, -- interior, dimensão, x, y, z
    }
     
    Markers_Enter_House = {} 
    
    for i,v in ipairs(Markers_Enter) do
        Markers_Enter_House[i] = createMarker(v[3], v[4], v[5], "cylinder", 1, 0, 0, 0, 50)
        createBlipAttachedTo(Markers_Enter_House[i],10)
     
        addEventHandler("onMarkerHit", Markers_Enter_House[i], function(hitElement)
            if getElementType(hitElement) == "player" then
                setElementInterior(hitElement, Markers_Enter[i][1], 222.990234375, 1289.876953125, 1082.1328125)
                setElementDimension(hitElement, Markers_Enter[i][2])
            end
        end)
    end
    
    function returnCoordsFromDimension(dimensao)
        for i,v in ipairs(Markers_Enter) do
            if v[2] == dimensao then
                return v[3],v[4],v[5]
            end
        end
        return false
    end
    
    -----[Marker Sair] -----
    
    Markers_Exit_House = {}
    
    Markers_Exit = {
        {1, 1, -1.13671875, 1.4052734375, 3.1171875}, -- interior, dimensão, x, y, z
        {1, 2, 4.259765625, 2.890625, 3.1171875}, -- interior, dimensão, x, y, z
    }
    
    for i,v in ipairs(Markers_Exit) do
        Markers_Exit_House[i] = createMarker(223.134765625, 1286.8, 1082, "cylinder", 1, 0, 0, 0, 50)
        setElementDimension(Markers_Exit_House[i], v[2])
        
        addEventHandler("onMarkerHit", Markers_Exit_House[i], function(hitElement)
            if getElementType(hitElement) == "player" then
                local x,y,z = returnCoordsFromDimension(getElementDimension(hitElement))
                if x,y,z then
                    setElementInterior(hitElement, 0, x,y,z)
                    setElementDimension(hitElement, 0)
                end
            end
        end)
    end

    Nesse código que mandei acima ele pega na tabela Markers_Enter qual a localização que ele vai sair pela minha dimensão para ele voltar no mesmo lugar que ele entrou

  10. Você utiliza o createRadarArea Para Estar Criando uma Area no seu Radar, Após isso você pode utilizar o createMarker ou createColRectangle.

    Porque utiliza-los : Não existe um evento em si para saber quando uma pessoa entra em uma área no Radar (ou pelo menos que eu conheça), então você cria um Marker ou um ColRectangle nessa área do radar, após isso utilize os Eventos onMarkerHit ou onColShapeHit para Saber Quando uma Pessoa Adentra no Marker ou no Col.

  11. -----[Marker Entrar] -----
    
    Markers_Enter = {
        {1, 1, -3, 4, 3}, -- interior, dimensão, x, y, z
        {1, 2, 1, 3, 3}, -- interior, dimensão, x, y, z
    }
     
    Markers_Enter_House = {} 
    
    for i,v in ipairs(Markers_Enter) do
        Markers_Enter_House[i] = createMarker(v[3], v[4], v[5], "cylinder", 1, 0, 0, 0, 50)
        createBlipAttachedTo(Markers_Enter_House[i],10)
     
        addEventHandler("onMarkerHit", Markers_Enter_House[i], function(hitElement)
            if getElementType(hitElement) == "player" then
                setElementInterior(hitElement, Markers_Enter[i][1], 222.990234375, 1289.876953125, 1082.1328125)
                setElementDimension(hitElement, Markers_Enter[i][2])
            end
        end)
    end
    
    
    
    -----[Marker Sair] -----
    
    Markers_Exit_House = {}
    
    Markers_Exit = {
        {1, 1, -1.13671875, 1.4052734375, 3.1171875}, -- interior, dimensão, x, y, z
        {1, 2, 4.259765625, 2.890625, 3.1171875}, -- interior, dimensão, x, y, z
    }
    
    for i,v in ipairs(Markers_Exit) do
        Markers_Exit_House[i] = createMarker(223.134765625, 1286.8, 1082, "cylinder", 1, 0, 0, 0, 50)
        setElementDimension(Markers_Exit_House[i], v[2])
        
        addEventHandler("onMarkerHit", Markers_Exit_House[i], function(hitElement)
            if getElementType(hitElement) == "player" then
                setElementInterior(hitElement, 0, Markers_Exit[i][3],Markers_Exit[i][4],Markers_Exit[i][5])
                setElementDimension(hitElement, 0)
            end
        end)
    end

    Tente isso.

  12. marker_aleatoriosS = {
        {1872.08, -1308.8, 18.147},
        {1893.097, -1314.732, 23.151},
        {1892.831, -1316.274, 28.152},
        {1872.101, -1317.594, 33.147},
        {1876.034, -1321.604, 38.147},
        {1876.088, -1309.743, 43.147},
        {1873.865, -1322.412, 48.069},
        --Para não pegar repetido 
        {1872.08, -1308.8, 18.147},
        {1893.097, -1314.732, 23.151},
        {1892.831, -1316.274, 28.152},
        {1872.101, -1317.594, 33.147},
        {1876.034, -1321.604, 38.147},
        {1876.088, -1309.743, 43.147},
        {1873.865, -1322.412, 48.069},
    }
    
    Object_ferro = {}
    marker_EntregarS = {}
    --ID do objeto barra de ferro 2960
    
    	
    function pegarFerroS(player,cmd)
        local x, y, z = getElementPosition(marker_ferro)
        local Random_Pos = math.random(#marker_aleatoriosS)
            if not isPedInVehicle(player) then 
                if isElementWithinMarker(player, marker_ferro) then
                if getElementData(player, "Ferro") == false then
                    if getElementData(player, "Pedreiro") == true then
                        setPedAnimation(player, "CARRY", "liftup", 1.0, false)
                        setTimer(function()
                            if isElement(Object_ferro[player]) then destroyElement(Object_ferro[player]) end
                            if isElement(marker_EntregarS[player]) then destroyElement(marker_EntregarS) end
                            setElementData(player, "Recompensa", 0)
                            setPedAnimation(player, nil)
                            setElementData(player, "Ferro", true)
                            toggleControl(player, "jump", false)
                            toggleControl(player, "fire", false)
                            toggleControl(player, "aim_weapon", false)
                            setPedAnimation( player, "CARRY", "crry_prtial", 4.1, true, true, true )
                            marker_EntregarS[player] = createMarker ( marker_aleatoriosS[Random_Pos][1], marker_aleatoriosS[Random_Pos][2], marker_aleatoriosS[Random_Pos][3] -2.2, "cylinder", 2.5, 16, 111, 231, 50)
                            setElementVisibleTo(marker_EntregarS, root, false)
                            setElementVisibleTo(marker_EntregarS, player, true)
                            addEventHandler("onMarkerHit", marker_EntregarS[player], fim_Emprego)
                            Object_ferro[player] = createObject(2960, x, y, z)
                            exports.bone_attach:attachElementToBone(Object_ferro[player], player, 4, 0, 0.4, - 0.6, -90, 0, 0 )
                        end, 1000,1)
                    end
                end
            end
        end
    end
    addCommandHandler("ferro", pegarFerroS)

    Sua maneira de tabela estava incorreta, estava pegando a index de uma tabela como essa.

     

    {1872.08, -1308.8, 18.147,1893.097, -1314.732, 23.151}

     

    • Thanks 1
×
×
  • Create New...