Jump to content

Radar Blips


RenanPG

Recommended Posts

  • Moderators

Well, your whole code isn't needed but I would like to see how you are calculating the x and y for the dxDrawImageSection

Also, what is the size of the radar map image ? 3000x3000 ? 6000x6000 ?

Thanks

Link to comment
    local px = ((x + 6000) / 2) - 100 
    local py = ((-y + 6000) / 2) - 100 
 

The whole image is 6000x6000.

here is my map.

 

    if x >= -3200 then 
        if x <= 3200 then 
            if y >= -3200 then 
                if y <= 3200 then 
                imagem = "mapa.jpg" 
                else 
                imagem = "agua.png" 
                end 
            else 
            imagem = "agua.png" 
            end 
        else 
        imagem = "agua.png" 
        end 
    else 
    imagem = "agua.png" 
    end 
 

and i use that to replace txture when the player is in middle of the sea. that makes the map infinite.

Link to comment

Maybe this helps you, might be a bit tricky since its not the whole code of my radar, but maybe this gives you a basic idea of how you could do it.

  
local function getCameraRotation () 
    px, py, pz, lx, ly, lz = getCameraMatrix() 
    local rotz = 6.2831853071796 - math.atan2 ( ( lx - px ), ( ly - py ) ) % 6.2831853071796 
    local rotx = math.atan2 ( lz - pz, getDistanceBetweenPoints2D ( lx, ly, px, py ) ) 
    --Convert to degrees 
    rotx = math.deg(rotx) 
    rotz = math.deg(rotz)    
    return rotz 
end 
  
function findRotation(x1,y1,x2,y2) 
  
  local t = -math.deg(math.atan2(x2-x1,y2-y1)) 
  if t < 0 then t = t + 360 end; 
  return t; 
  
end 
  
function getPointFromDistanceRotation(x, y, dist, angle) 
  
    local a = math.rad(90 - angle); 
    local dx = math.cos(a) * dist; 
    local dy = math.sin(a) * dist; 
    return x+dx, y+dy; 
  
end 
  

     
  
    if getPedOccupiedVehicle(localPlayer) ~= false then  
        theVehicle = getPedOccupiedVehicle(localPlayer) 
    elseif getCameraTarget(localPlayer) ~= false then  
        theVehicle = getCameraTarget(localPlayer) 
    else 
        return 
    end 
  
    local rotation = getCameraRotation()     
  
for i, p in pairs(getClientPlayersInArena(arenaElement)) do 
            if getElementData(p, "state") == "Alive" then 
                if getPedOccupiedVehicle(p) and getPedOccupiedVehicle(p) ~= theVehicle then 
                    local x, y, z = getElementPosition(getPedOccupiedVehicle(p)) 
                                         
                            local name = getPlayerName(p) 
                            local c1, c2 = string.find(name, '#%x%x%x%x%x%x') 
                            if c1 then 
                            blipr, blipg, blipb = getColorFromString(string.sub(name, c1, c2)) 
                            else 
                                blipr = 255 
                                blipg = 255 
                                blipb = 255 
                            end 
     
                            local distance = getDistanceBetweenPoints2D(x, y, lx,ly) 
                            local rotation2 = findRotation(x,y,lx,ly) 
                            local , yd = getPointFromDistanceRotation(startwidth+(width/2), startheight+(height/2), distance/3.3, rotation2-rotation)  
                             
                            if  < startwidth+edgeVertical then 
                                 = startwidth+edgeVertical 
                            elseif  > startwidth+width-edgeVertical then 
                                 = startwidth+width-edgeVertical 
                            end 
                             
                            if yd < startheight+edgeVertical then 
                                yd = startheight+edgeVertical 
                            elseif yd > startheight+height then 
                                yd = startheight+height 
                            end 
                             
                            dxDrawRectangle ( -4, yd-4, 8, 8, tocolor ( 0, 0, 0, 255 ) )   
                            dxDrawRectangle (-3, yd-3, 6, 6, tocolor (blipr, blipg, blipb, 255 ) )     
                end  
            end  
    end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...