Jump to content

GTA 5 Radar


xeon17

Recommended Posts

Hello guys

I want to ask how i can make this gta 5 radar run all time on my server , i mean when the player enter on server the radar need to show.

The script is from Bonsai's Multigamemode .

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 
  
local screenx, screeny = guiGetScreenSize() 
local sW, sH =  (screenx/1280), (screeny/960) 
local edgeHorizontal = 25.6*sW 
local edgeVertical = 3*sW 
local width = 320*sW 
local height = 192*sH 
local startwidth = 25.6*sW 
local startheight = 720*sH 
local blipsize = 16 
local blipr, blipg, blipb 
local totalsize = 1600 
local theTarget 
local t 
local showRadar = true 
local myRenderTarget1 = dxCreateRenderTarget( width, height, true ) 
  
function drawRadar() 
  
if getElementData(localPlayer, "Arena") == "Login" or getElementData(localPlayer, "Arena") == "Lobby" or showRadar == false then return end 
  
    if getPedOccupiedVehicle(localPlayer) ~= false then  
        theTarget = getPedOccupiedVehicle(localPlayer) 
    elseif getCameraTarget(localPlayer) ~= false then  
        theTarget = getCameraTarget(localPlayer) 
    else 
        return 
    end 
     
    --background 
    dxDrawRectangle ( startwidth, startheight, width, height, tocolor ( 0, 155, 255, 50 ) ) 
     
    local arena = getElementData(localPlayer, "Arena") 
  
    dxDrawRectangle ( startwidth, startheight, width, edgeVertical, tocolor ( 0, 0, 0, 255 ) ) 
    dxDrawRectangle ( startwidth, startheight, edgeVertical, height, tocolor ( 0, 0, 0, 255 ) ) 
    dxDrawRectangle ( startwidth, startheight+height, width, edgeHorizontal, tocolor ( 0, 0, 0, 255 ) )  
    dxDrawRectangle ( startwidth+width-edgeVertical, startheight, edgeVertical, height, tocolor ( 0, 0, 0, 255 ) ) 
  
    local rotation = getCameraRotation()     
     
  
    local xp, yp, zp = getElementPosition(theTarget) 
    widthmap = (totalsize/2)+((totalsize/2)/2998)*xp 
    heightmap = (totalsize/2)-((totalsize/2)/2998)*yp 
     
    dxSetRenderTarget( myRenderTarget1, true )  
        dxDrawImage( -widthmap+(width/2), -heightmap+(height/2), totalsize, totalsize, "img/map.png", rotation, ((totalsize/2)/2998)*xp, -((totalsize/2)/2998)*yp, tocolor ( 255, 255, 255, 255 )) 
    dxSetRenderTarget()  
     
    dxDrawImage ( startwidth+edgeVertical, startheight+edgeVertical, width-edgeVertical*2, height-edgeVertical, myRenderTarget1, 0, 0, 0, tocolor ( 255, 255, 255, 255 ), false )    
  
    
    --players 
    for i, p in pairs(getPlayersInArena(arena)) do 
            if getElementData(p, "state") == "Alive" then 
                if p ~= theTarget and getPedOccupiedVehicle(p) ~= theTarget then 
                    local x, y, z = getElementPosition(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, xp,yp) 
                            local rotation2 = findRotation(x,y,xp,yp) 
                            local , yd = getPointFromDistanceRotation(startwidth+(width/2), startheight+(height/2), distance/4, 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 
  
    --checkpoints 
    for i, p in pairs(getElementsByType("marker")) do 
            if getElementData(p, "type") == "checkpoint" and getElementDimension(p) == getElementDimension(localPlayer) then 
             
                if getMarkerSize(p) > 0.1 then  
                 
                    local x, y, z = getElementPosition(p) 
                    blipr, blipg, blipb = getMarkerColor(p) 
                    local distance = getDistanceBetweenPoints2D(x, y, xp,yp) 
                    local rotation2 = findRotation(x,y,xp,yp) 
                    local , yd = getPointFromDistanceRotation(startwidth+(width/2), startheight+(height/2), distance/4, 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 
                     
                    if getElementData(p, "id") == getElementData(localPlayer, "checkpointname") then 
                        dxDrawRectangle ( -6, yd-6, 12, 12, tocolor ( 0, 0, 0, 255 ) )     
                        dxDrawRectangle (-5, yd-5, 10, 10, tocolor (blipr, blipg, blipb, 255 ) )   
                    else 
                        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  
    end 
     
  
    if theTarget then 
  
        local health = getElementHealth(theTarget) 
         
        if getElementType(theTarget) == "player" then 
            health = health*10 
        end 
  
        health = math.max(health - 250, 0)/750 
        local p = -510*(health^2) 
        local r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0) 
         
        local nitro 
         
        if getElementType(theTarget) == "vehicle" then 
            nitro = getVehicleNitroLevel(theTarget) 
        end 
             
        if not nitro then nitro = 0 end 
  
        --health 
        dxDrawRectangle(startwidth+edgeVertical, startheight+height+edgeVertical, width/2-edgeVertical*2+edgeVertical/2, edgeHorizontal-edgeVertical*2, tocolor(0,0,0,255) ) 
        dxDrawRectangle(startwidth+edgeVertical+2, startheight+height+edgeVertical+2, width/2-edgeVertical*2+edgeVertical/2-4, edgeHorizontal-edgeVertical*2-4, tocolor(r,g,0,0.5*255) )                 
        dxDrawRectangle(startwidth+edgeVertical+2, startheight+height+edgeVertical+2, health*(width/2-edgeVertical*2+edgeVertical/2-4), edgeHorizontal-edgeVertical*2-4, tocolor(r,g,0,255) ) 
         
        --nitro 
        dxDrawRectangle(startwidth+width/2+edgeVertical/2, startheight+height+edgeVertical, width/2-edgeVertical*2+edgeVertical/2, edgeHorizontal-edgeVertical*2, tocolor(0,0,0,255) ) 
        dxDrawRectangle(startwidth+width/2+edgeVertical/2+2, startheight+height+edgeVertical+2, width/2-edgeVertical*2+edgeVertical/2-4, edgeHorizontal-edgeVertical*2-4, tocolor(0,150,220,0.5*255) )               
        dxDrawRectangle(startwidth+width/2+edgeVertical/2+2, startheight+height+edgeVertical+2, nitro*(width/2-edgeVertical*2+edgeVertical/2-4), edgeHorizontal-edgeVertical*2-4, tocolor(0,50,255,255) ) 
     
    end 
     
  
    local xr,yr,zr = getElementRotation(theTarget) 
    dxDrawImage ( startwidth+(width/2)-blipsize/2, startheight+(height/2)-blipsize/2, blipsize, blipsize, "img/blip.png", -zr+rotation, 0, 0, tocolor ( 255, 255, 255, 255 ), false )   
     
     
     
end 
addEventHandler("onClientRender", root, drawRadar) 
  
  
function getPlayersInArena(arena) 
  
local playerTable = {} 
  
for i, p in ipairs(getElementsByType("player")) do 
  
    if getElementType(p) == "player" and getElementData(p, "Arena") == arena then 
  
        table.insert(playerTable, p) 
     
    end 
     
end 
  
return playerTable 
  
end 
  
  
  
function toggleRadar() 
  
if showRadar == true then 
    showRadar = false 
elseif showRadar == false then 
    showRadar = true 
end 
  
end 
addCommandHandler("showradar", toggleRadar) 
  

Link to comment
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 
  
local screenx, screeny = guiGetScreenSize() 
local sW, sH =  (screenx/1280), (screeny/960) 
local edgeHorizontal = 25.6*sW 
local edgeVertical = 3*sW 
local width = 320*sW 
local height = 192*sH 
local startwidth = 25.6*sW 
local startheight = 720*sH 
local blipsize = 16 
local blipr, blipg, blipb 
local totalsize = 1600 
local theTarget 
local t 
local showRadar = true 
local myRenderTarget1 = dxCreateRenderTarget( width, height, true ) 
  
function drawRadar() 
  
    if getPedOccupiedVehicle(localPlayer) ~= false then  
        theTarget = getPedOccupiedVehicle(localPlayer) 
    elseif getCameraTarget(localPlayer) ~= false then  
        theTarget = getCameraTarget(localPlayer) 
    else 
        return 
    end 
     
    --background 
    dxDrawRectangle ( startwidth, startheight, width, height, tocolor ( 0, 155, 255, 50 ) ) 
     
    local arena = getElementData(localPlayer, "Arena") 
  
    dxDrawRectangle ( startwidth, startheight, width, edgeVertical, tocolor ( 0, 0, 0, 255 ) ) 
    dxDrawRectangle ( startwidth, startheight, edgeVertical, height, tocolor ( 0, 0, 0, 255 ) ) 
    dxDrawRectangle ( startwidth, startheight+height, width, edgeHorizontal, tocolor ( 0, 0, 0, 255 ) )  
    dxDrawRectangle ( startwidth+width-edgeVertical, startheight, edgeVertical, height, tocolor ( 0, 0, 0, 255 ) ) 
  
    local rotation = getCameraRotation()     
     
  
    local xp, yp, zp = getElementPosition(theTarget) 
    widthmap = (totalsize/2)+((totalsize/2)/2998)*xp 
    heightmap = (totalsize/2)-((totalsize/2)/2998)*yp 
     
    dxSetRenderTarget( myRenderTarget1, true )  
        dxDrawImage( -widthmap+(width/2), -heightmap+(height/2), totalsize, totalsize, "img/map.png", rotation, ((totalsize/2)/2998)*xp, -((totalsize/2)/2998)*yp, tocolor ( 255, 255, 255, 255 )) 
    dxSetRenderTarget()  
     
    dxDrawImage ( startwidth+edgeVertical, startheight+edgeVertical, width-edgeVertical*2, height-edgeVertical, myRenderTarget1, 0, 0, 0, tocolor ( 255, 255, 255, 255 ), false )    
  
    
    --players 
                if p ~= theTarget and getPedOccupiedVehicle(p) ~= theTarget then 
                    local x, y, z = getElementPosition(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, xp,yp) 
                            local rotation2 = findRotation(x,y,xp,yp) 
                            local , yd = getPointFromDistanceRotation(startwidth+(width/2), startheight+(height/2), distance/4, 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 
  
    --checkpoints 
    for i, p in pairs(getElementsByType("marker")) do 
            if getElementData(p, "type") == "checkpoint" and getElementDimension(p) == getElementDimension(localPlayer) then 
             
                if getMarkerSize(p) > 0.1 then  
                 
                    local x, y, z = getElementPosition(p) 
                    blipr, blipg, blipb = getMarkerColor(p) 
                    local distance = getDistanceBetweenPoints2D(x, y, xp,yp) 
                    local rotation2 = findRotation(x,y,xp,yp) 
                    local , yd = getPointFromDistanceRotation(startwidth+(width/2), startheight+(height/2), distance/4, 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 
                     
                    if getElementData(p, "id") == getElementData(localPlayer, "checkpointname") then 
                        dxDrawRectangle ( -6, yd-6, 12, 12, tocolor ( 0, 0, 0, 255 ) )     
                        dxDrawRectangle (-5, yd-5, 10, 10, tocolor (blipr, blipg, blipb, 255 ) )   
                    else 
                        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  
    end 
     
  
    if theTarget then 
  
        local health = getElementHealth(theTarget) 
         
        if getElementType(theTarget) == "player" then 
            health = health*10 
        end 
  
        health = math.max(health - 250, 0)/750 
        local p = -510*(health^2) 
        local r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0) 
         
        local nitro 
         
        if getElementType(theTarget) == "vehicle" then 
            nitro = getVehicleNitroLevel(theTarget) 
        end 
             
        if not nitro then nitro = 0 end 
  
        --health 
        dxDrawRectangle(startwidth+edgeVertical, startheight+height+edgeVertical, width/2-edgeVertical*2+edgeVertical/2, edgeHorizontal-edgeVertical*2, tocolor(0,0,0,255) ) 
        dxDrawRectangle(startwidth+edgeVertical+2, startheight+height+edgeVertical+2, width/2-edgeVertical*2+edgeVertical/2-4, edgeHorizontal-edgeVertical*2-4, tocolor(r,g,0,0.5*255) )                 
        dxDrawRectangle(startwidth+edgeVertical+2, startheight+height+edgeVertical+2, health*(width/2-edgeVertical*2+edgeVertical/2-4), edgeHorizontal-edgeVertical*2-4, tocolor(r,g,0,255) ) 
         
        --nitro 
        dxDrawRectangle(startwidth+width/2+edgeVertical/2, startheight+height+edgeVertical, width/2-edgeVertical*2+edgeVertical/2, edgeHorizontal-edgeVertical*2, tocolor(0,0,0,255) ) 
        dxDrawRectangle(startwidth+width/2+edgeVertical/2+2, startheight+height+edgeVertical+2, width/2-edgeVertical*2+edgeVertical/2-4, edgeHorizontal-edgeVertical*2-4, tocolor(0,150,220,0.5*255) )               
        dxDrawRectangle(startwidth+width/2+edgeVertical/2+2, startheight+height+edgeVertical+2, nitro*(width/2-edgeVertical*2+edgeVertical/2-4), edgeHorizontal-edgeVertical*2-4, tocolor(0,50,255,255) ) 
     
    end 
     
  
    local xr,yr,zr = getElementRotation(theTarget) 
    dxDrawImage ( startwidth+(width/2)-blipsize/2, startheight+(height/2)-blipsize/2, blipsize, blipsize, "img/blip.png", -zr+rotation, 0, 0, tocolor ( 255, 255, 255, 255 ), false )   
     
     
     
end 
addEventHandler("onClientRender", root, drawRadar) 
  
  
function getPlayersInArena(arena) 
  
local playerTable = {} 
  
for i, p in ipairs(getElementsByType("player")) do 
  
    if getElementType(p) == "player" and getElementData(p, "Arena") == arena then 
  
        table.insert(playerTable, p) 
     
    end 
     
end 
  
return playerTable 
  
end 
  
  
  
function toggleRadar() 
  
if showRadar == true then 
    showRadar = false 
elseif showRadar == false then 
    showRadar = true 
end 
  
end 
addCommandHandler("showradar", toggleRadar) 
  

Link to comment
  
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 
  
local screenx, screeny = guiGetScreenSize() 
local sW, sH =  (screenx/1280), (screeny/960) 
local edgeHorizontal = 25.6*sW 
local edgeVertical = 3*sW 
local width = 320*sW 
local height = 192*sH 
local startwidth = 25.6*sW 
local startheight = 720*sH 
local blipsize = 16 
local blipr, blipg, blipb 
local totalsize = 1600 
local theTarget 
local t 
local showRadar = true 
local myRenderTarget1 = dxCreateRenderTarget( width, height, true ) 
  
function drawRadar() 
  
    if getPedOccupiedVehicle(localPlayer) ~= false then 
        theTarget = getPedOccupiedVehicle(localPlayer) 
    elseif getCameraTarget(localPlayer) ~= false then 
        theTarget = getCameraTarget(localPlayer) 
    else 
        return 
    end 
    
    --background 
    dxDrawRectangle ( startwidth, startheight, width, height, tocolor ( 0, 155, 255, 50 ) ) 
    
    local arena = getElementData(localPlayer, "Arena") 
  
    dxDrawRectangle ( startwidth, startheight, width, edgeVertical, tocolor ( 0, 0, 0, 255 ) ) 
    dxDrawRectangle ( startwidth, startheight, edgeVertical, height, tocolor ( 0, 0, 0, 255 ) ) 
    dxDrawRectangle ( startwidth, startheight+height, width, edgeHorizontal, tocolor ( 0, 0, 0, 255 ) )  
    dxDrawRectangle ( startwidth+width-edgeVertical, startheight, edgeVertical, height, tocolor ( 0, 0, 0, 255 ) ) 
  
    local rotation = getCameraRotation()    
    
  
    local xp, yp, zp = getElementPosition(theTarget) 
    widthmap = (totalsize/2)+((totalsize/2)/2998)*xp 
    heightmap = (totalsize/2)-((totalsize/2)/2998)*yp 
    
    dxSetRenderTarget( myRenderTarget1, true ) 
        dxDrawImage( -widthmap+(width/2), -heightmap+(height/2), totalsize, totalsize, "img/map.png", rotation, ((totalsize/2)/2998)*xp, -((totalsize/2)/2998)*yp, tocolor ( 255, 255, 255, 255 )) 
    dxSetRenderTarget() 
    
    dxDrawImage ( startwidth+edgeVertical, startheight+edgeVertical, width-edgeVertical*2, height-edgeVertical, myRenderTarget1, 0, 0, 0, tocolor ( 255, 255, 255, 255 ), false )    
  
    
    --players 
                for i, p in pairs(getElementsByType("player")) do 
            if getElementData(p, "state") == "Alive" then 
                if p ~= theTarget and getPedOccupiedVehicle(p) ~= theTarget then 
                    local x, y, z = getElementPosition(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, xp,yp) 
                            local rotation2 = findRotation(x,y,xp,yp) 
                            local , yd = getPointFromDistanceRotation(startwidth+(width/2), startheight+(height/2), distance/4, 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 
  
    --checkpoints 
    for i, p in pairs(getElementsByType("marker")) do 
            if getElementData(p, "type") == "checkpoint" and getElementDimension(p) == getElementDimension(localPlayer) then 
            
                if getMarkerSize(p) > 0.1 then 
                
                    local x, y, z = getElementPosition(p) 
                    blipr, blipg, blipb = getMarkerColor(p) 
                    local distance = getDistanceBetweenPoints2D(x, y, xp,yp) 
                    local rotation2 = findRotation(x,y,xp,yp) 
                    local , yd = getPointFromDistanceRotation(startwidth+(width/2), startheight+(height/2), distance/4, 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 
                    
                    if getElementData(p, "id") == getElementData(localPlayer, "checkpointname") then 
                        dxDrawRectangle ( -6, yd-6, 12, 12, tocolor ( 0, 0, 0, 255 ) )    
                        dxDrawRectangle (-5, yd-5, 10, 10, tocolor (blipr, blipg, blipb, 255 ) )  
                    else 
                        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 
    end 
    
  
    if theTarget then 
  
        local health = getElementHealth(theTarget) 
        
        if getElementType(theTarget) == "player" then 
            health = health*10 
        end 
  
        health = math.max(health - 250, 0)/750 
        local p = -510*(health^2) 
        local r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0) 
        
        local nitro 
        
        if getElementType(theTarget) == "vehicle" then 
            nitro = getVehicleNitroLevel(theTarget) 
        end 
            
        if not nitro then nitro = 0 end 
  
        --health 
        dxDrawRectangle(startwidth+edgeVertical, startheight+height+edgeVertical, width/2-edgeVertical*2+edgeVertical/2, edgeHorizontal-edgeVertical*2, tocolor(0,0,0,255) ) 
        dxDrawRectangle(startwidth+edgeVertical+2, startheight+height+edgeVertical+2, width/2-edgeVertical*2+edgeVertical/2-4, edgeHorizontal-edgeVertical*2-4, tocolor(r,g,0,0.5*255) )                
        dxDrawRectangle(startwidth+edgeVertical+2, startheight+height+edgeVertical+2, health*(width/2-edgeVertical*2+edgeVertical/2-4), edgeHorizontal-edgeVertical*2-4, tocolor(r,g,0,255) ) 
        
        --nitro 
        dxDrawRectangle(startwidth+width/2+edgeVertical/2, startheight+height+edgeVertical, width/2-edgeVertical*2+edgeVertical/2, edgeHorizontal-edgeVertical*2, tocolor(0,0,0,255) ) 
        dxDrawRectangle(startwidth+width/2+edgeVertical/2+2, startheight+height+edgeVertical+2, width/2-edgeVertical*2+edgeVertical/2-4, edgeHorizontal-edgeVertical*2-4, tocolor(0,150,220,0.5*255) )              
        dxDrawRectangle(startwidth+width/2+edgeVertical/2+2, startheight+height+edgeVertical+2, nitro*(width/2-edgeVertical*2+edgeVertical/2-4), edgeHorizontal-edgeVertical*2-4, tocolor(0,50,255,255) ) 
    
    end 
    
  
    local xr,yr,zr = getElementRotation(theTarget) 
    dxDrawImage ( startwidth+(width/2)-blipsize/2, startheight+(height/2)-blipsize/2, blipsize, blipsize, "img/blip.png", -zr+rotation, 0, 0, tocolor ( 255, 255, 255, 255 ), false )   
    
    
    
end 
addEventHandler("onClientRender", root, drawRadar) 
  
  
function getPlayersInArena(arena) 
  
local playerTable = {} 
  
for i, p in ipairs(getElementsByType("player")) do 
  
    if getElementType(p) == "player" and getElementData(p, "Arena") == arena then 
  
        table.insert(playerTable, p) 
    
    end 
    
end 
  
return playerTable 
  
end 
  
  
  
function toggleRadar() 
  
if showRadar == true then 
    showRadar = false 
elseif showRadar == false then 
    showRadar = true 
end 
  
end 
addCommandHandler("showradar", toggleRadar) 
  
  

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...