[Release] nMarker

Screen:

Showcase version 1.1 :
https://streamable.com/iih9dm

Showcase version 1.2 :
https://streamable.com/ooc7h6

Information:
Hey, this resource only show you the distance between your marker and your position,
i took inspiration from arma 3. i share this to be open source like this people can modify like they want.

Download

Version
1.1 Now it show like arma 3 the distance some thing like 1.1 km and no more 1000km
→ Thanks to RAMEX_DELTA_GTA for his help.

1.2 Added a condition to only show up your marker if the mini-map is not showing and some optimization.
→ Thanks Dislaik for your remind to not use two same function, i was tired.

11 Likes

trop trop bien

1 Like
            if distance > 999 then
                roundOverKm = round(distance)  * math.pow(10, -3)
				DrawText3DMarker(coord.x, coord.y, myPos.z + 10)
				DrawText3DTest(coord.x, coord.y, myPos.z + 2, roundOverKm.. " kilomètres")
			elseif distance > 0.1 and distance <= 999 then
				DrawText3DMarker(coord.x, coord.y, myPos.z)
				DrawText3DTest(coord.x, coord.y, myPos.z, round(distance).. " m")
            end

@Ninja_force

1 Like

Been looking for something like this for a while, nice job!

1 Like

You the best !

2 Likes

it is perfect! thanks!!!

2 Likes

it’s so perfect :ok_hand:

1 Like

Nice work, i ever had the same idea, but i very lazy to work :grimacing:

EDIT: i dont know why do you operate two drawtext separately

Screenshot_259

local function DrawText3DMarker(x,y,z,text)
    local onScreen,_x,_y=World3dToScreen2d(x,y,z)
    
    if onScreen then
        SetTextScale(0.3, 0.3)
        SetTextFont(0)
        SetTextProportional(1)
        SetTextColour(255, 255, 255, 255)
        SetTextDropshadow(0, 0, 0, 0, 55)
        SetTextEdge(2, 0, 0, 0, 150)
        SetTextDropShadow()
        SetTextOutline()
        SetTextEntry("STRING")
        SetTextCentre(1)
        AddTextComponentString(text)
        DrawText(_x,_y)
    end
end

local function round(num, idp)
    if idp and idp>0 then
        local mult = 10^idp
        return math.floor(num * mult + 0.5) / mult
    end
    return math.floor(num + 0.5)
end

--> No need native to check the distance with this :
local square = math.sqrt
local function getDistance(a, b) 
    local x, y, z = a.x-b.x, a.y-b.y, a.z-b.z
    return square(x*x+y*y+z*z)
end

Citizen.CreateThread(function()
    while true do
        if --[[not--]] IsRadarEnabled() then --> With this new condition it will show you your marker only if the mini-map is disabled.
            local waypoint = GetFirstBlipInfoId(8)
            if DoesBlipExist(waypoint) then
                local myPos = GetEntityCoords(GetPlayerPed(-1))
                local coord = Citizen.InvokeNative(0xFA7C7F0AADF25D09, waypoint, Citizen.ResultAsVector())
                local distance = getDistance(myPos, coord)
                
                if distance > 999 then
                    roundOverKm = round(distance)  * math.pow(10, -3) --> Thanks to RAMEX_DELTA_GTA for his help.
                    DrawText3DMarker(coord.x, coord.y, myPos.z, 'V\n' .. roundOverKm.. " kilometres")
                    --DrawText3DTest(coord.x, coord.y, myPos.z + 2, roundOverKm.. " kilomètres")
                elseif distance > 0.1 and distance <= 999 then
                    DrawText3DMarker(coord.x, coord.y, myPos.z, 'V\n' .. round(distance).. " m")
                    --DrawText3DTest(coord.x, coord.y, myPos.z, round(distance).. " m")
                end
            end
        end
        Citizen.Wait(0)
    end
end)

Screenshot_260

1 Like

Hey, thanks for your feed back, some time when you don’t sleep enough your mind is a little broken so ya i forgot that \n thanks a lot !

1 Like

I still love this… anyway to change it to miles/feet instead of km?

Sorry, it’s something that you will need to do your self, at the moment, i’m really noob with maths.
but if i get it, i will try to do it my self and update the code.

is that some thing like this that you want ?

that is getting closer, that would convert to about 103.787879 miles, so the math needs some love. wish i could help, i dont think the map is that big

think the whole area is supposed to be about 50 square miles

update link.

how to change km to feet! you can help me code?