Referencing specific values in an array . lua

Asked

Viewed 38 times

1

In that case I created a math.random with the values from 1 to 2 that will lead me to a coordinate of a specific delivery. I created a table with the corresponding values. But since then I can’t get my thread to access a certain value within my array. How could I change my code so getting access to the determined values?

local entregaCords = {

    [1] = { x= 152.378, y= -986.520, z= 30.0919 },

    [2] = { x= 170.051, y= -993.134, z= 30.0919 },
}

while true do
    Citizen.Wait(1)
    local ui = GetMinimapAnchor()
    local distance = GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()),entregaCords[destino].x,entregaCords[destino].y,entregaCords[destino].z,true)
    if emservico then
        drawTxt(ui.right_x+0.050,ui.bottom_y-0.076,1.0,1.0,0.35,"PRESSIONE ~r~F7 ~w~PARA CANCELAR A MISSÃO",255,255,255,150)
        drawTxt(ui.right_x+0.050,ui.bottom_y-0.058,1.0,1.0,0.45,"ENTREGUE ~g~"..quantidade.."~w~ " ..v.text ,255,255,255,255)
        if distance <= 50 then
                DrawMarker(21,entregaCords[destino].x,entregaCords[destino].y,entregaCords[destino].z+0.10,0,0,0,0,180.0,130.0,1.0,1.0,1.0,211,176,72,100,1,0,0,1)
            if distance < 3 then
                DrawText3Ds(entregaCords[destino].x,entregaCords[destino].y,entregaCords[destino].z, "[H] Entregar "..v.text)
                if IsControlJustPressed(0,101) then
                    TriggerServerEvent('entrega:itensReceber', quantidade)
                    destinoAntigo = destino
                    TriggerEvent('entrega:permissao')
                    CriandoBlip(entregaCords,destino)
                end
            end
        end
    end
end

I did a lot of research and somehow I didn’t come to a consensus on how to work on that. Thank you!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.