Jump to content

Help Radar


WASSIm.

Recommended Posts

hi all. i have this radar but he is circle i want change it rectangle

local sx,sy = guiGetScreenSize() 
  
local enablePlayerRadar = false 
  
local posx = sy * 0.05 
local posy = sy * 0.725 
local height = sy * 0.225 
local centerleft = posx + height / 2 
local centertop = posy + height / 2 
local blipsize = height / 16 
local lpsize = height / 8 
local range = 100 
local scale = (sx/1440)*0.9 
  
local lp = getLocalPlayer() 
  
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 getDistanceRotation(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 
  
addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), 
    function  ( ) 
        setPlayerHudComponentVisible ( "radar", true ) 
    end 
) 
  
addEventHandler("onClientRender", getRootElement(),  
    function() 
        if ( enablePlayerRadar ) then 
         
            local px, py, pz = getElementPosition(lp) 
            local _,_,pr = getElementRotation(lp) 
            local attach = getElementAttachedTo (lp) 
            local cx,cy,_,tx,ty = getCameraMatrix() 
            local north = findRotation(cx,cy,tx,ty) 
             
            dxDrawImage(posx,posy,height,height, "north.png", north) 
            dxDrawImage(posx,posy,height,height, "radar.png") 
            for id, blip in ipairs(getElementsByType("blip")) do 
                if blip then --not getAttachedElements( localPlayer ) == blip 
                    local bx, by, bz = getElementPosition(blip) 
                    local dist = getDistanceBetweenPoints2D(px,py,bx,by) 
             
                    if dist > range then 
                        dist = tonumber(range) 
                    end 
                    local angle = 180-north + findRotation(px,py,bx,by) 
                    local cblipx, cblipy = getDistanceRotation(0, 0, height*(dist/range)/2, angle) 
                    local blipx = centerleft+cblipx-blipsize/2 
                    local blipy = centertop+cblipy-blipsize/2 
                    local yoff = 0 
             
                    local r,b,g,a = getBlipColor ( blip ) 
                    local id = getBlipIcon ( blip ) 
                    local size = getBlipSize ( blip ) 
                    local distb = getBlipVisibleDistance ( blip ) 
             
                    if dist < distb then 
                        if id == 0 then 
                            if (bz - pz) >= 5 then 
                                img = "0-up.png" 
                            elseif (bz - pz) <= -5 then 
                                img = "0-down.png" 
                            else 
                                img = "0.png" 
                            end 
                        else 
                            img = ""..id..".png" 
                            r,b,g,a = 255,255,255,255 
                        end 
                    end 
                    dxDrawImage(blipx - size, blipy - size, blipsize + size, blipsize + size, ":server/images/hud/blips/"..img.."", 0, 0, 0, tocolor(r,b,g,a)) 
                    if not blipnorth then 
                        blipnorth = createBlip(0, 60000, 0, 4) 
                    end 
                end 
            end 
            dxDrawImage(centerleft - lpsize/2, centertop - lpsize/2, lpsize,lpsize, ":server/images/hud/blips/2.png", north-pr, 0, 0, tocolor(255,255,255,255)) 
        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...