Jump to content

[HELP] Problem With Radar


Recommended Posts

In the radar this is what happends

p3toy.png

Both of those are supposed to be together in the middle meaning in the picture thats fked and happends to me right now. I want all stuff in same position and same area. please help fix

Client

local sx,sy = guiGetScreenSize() 
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 = 180 
  
local lp = getLocalPlayer() 
  
addEventHandler( "onClientResourceStart", getRootElement( ), 
    function ( startedRes ) 
        --outputChatBox( "#0099FFPress #FFFFFFF2 #0099FFto #FFFFFFdisable/enable #0099ffthe Radar Objects!",255,255,255,true) 
    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 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 
  
function getShadeObjectsInMyDistance () 
objectTable = {} 
    local target = getCameraTarget() 
    if target and getElementType(target) == "vehicle" then 
        lp1 = getVehicleOccupant(target) 
    else 
        lp1 = getLocalPlayer() 
    end 
    local px, py, pz = getElementPosition(lp1) 
    if not px then 
        return 
    end 
    for id, object in ipairs(getElementsByType("object")) do 
        local ex, ey, ez = getElementPosition(object) 
        local dist = getDistanceBetweenPoints2D(px,py,ex,ey) 
        if getElementModel(object) == 3458 or getElementModel(object) ==  8558 or getElementModel(object) ==  8838 or getElementModel(object) ==  18449 or getElementModel(object) ==  18450 or getElementModel(object) == 7657 then  
        if dist < 180 then  
            table.insert(objectTable,object) 
        end 
        end 
    end 
    return objectTable 
end 
  
local huntersonly = false 
  
setTimer( 
function() 
    huntersonly = true 
    for id, player in ipairs(getElementsByType("player")) do 
        if getElementData(player, "state") == "alive" then 
            if getPedOccupiedVehicle(player) and getElementModel(getPedOccupiedVehicle(player)) ~= 425 then 
                huntersonly = false 
            end 
        end 
    end 
    local target = getCameraTarget() 
    if target and getElementType(target) == "vehicle" then 
        lp = getVehicleOccupant(target) 
    else 
        lp = getLocalPlayer() 
    end 
end,1000,0) 
  
showObjects = false 
function disableObjects () 
showObjects = not showObjects 
if showObjects == false then  
end 
end 
  
rotationRotator = 0 
addEventHandler("onClientRender", getRootElement(),  
function() 
    showPlayerHudComponent("radar", false) 
    local px, py, pz = getElementPosition(lp) 
    local pr = getPedRotation(lp) 
    local cx,cy,_,tx,ty = getCameraMatrix() 
    local north = findRotation(cx,cy,tx,ty) 
    dxDrawImage(posx,posy,height,height, "radar/img/radar.png") 
    dxDrawImage(posx,posy,height,height, "radar/img/north.png", north) 
        --Health 
            --local vehicle = getPedOccupiedVehicle(lp) 
            --if vehicle then  
            --local healthColor = getElementHealth(vehicle)/4 
            --local healthHeight = healthColor/250 
            --local health = getElementHealth(vehicle) 
            --local health = math.max(health - 250, 0)/750 
            --local color = tocolor(255-healthColor,healthColor/1.5 ,0,255) 
            --if healthColor < 40 then  
            --local number = math.random(0,1) 
                --if number == 1 then  
                --  alpha = 255 
                --else  
                --  alpha = 0 
                --end 
                --color = tocolor(255-healthColor,healthColor/1.5 ,0,alpha) 
            --end 
            --dxDrawImage(posx-6,posy-4,height+8,height+8, "radar/img/healthbar.png",0,0,0,tocolor(255-healthColor,healthColor/1.5 ,0,255)) 
             
            --end 
    if showObjects == true then  
    for id, object in ipairs(getShadeObjectsInMyDistance()) do 
            local xx,yy,rot = getElementRotation(object) 
            local ex, ey, ez = getElementPosition(object) 
            local dist = getDistanceBetweenPoints2D(px,py,ex,ey) 
            if dist > range then 
                dist = tonumber(range) 
            end 
            local angle = 180-north + findRotation(px,py,ex,ey) 
            local cblipx, cblipy = getDistanceRotation(0, 0, height*(dist/range)/2, angle) 
            local blipsize2 =  blipsize-8.2 
            local blipx = centerleft+cblipx-blipsize/2 
            local blipy = centertop+cblipy-blipsize2 
            local yoff = 0 
            local r,g,b,a = 255,255,255,255 
            local img = "" 
            local x1 = 7 
            local x2 = 14 
            local y1 = 0 
            local y2 = 0 
            if getElementModel(object) == 8558 then 
                img = "" 
            elseif getElementModel(object) == 3458 then 
                img = "" 
            elseif getElementModel(object) == 18449 or getElementModel(object) == 18450 then 
                img = "" 
                blipsize2 =  blipsize-2 
                blipy = centertop+cblipy-blipsize2 
                x1 = 15 
                x2 = 30 
            elseif getElementModel(object) == 8838 then 
                img = "" 
            elseif getElementModel(object) == 7657 then 
                img = ""     
                x1 = 5 
                x2 = 10 
                yy = 0 
            end 
            if yy == 90 then  
                x1 = -4 
                x2 = -8 
            end 
    end 
    end 
    for id, player in ipairs(getElementsByType("player")) do 
        local veh = getPedOccupiedVehicle(player) 
        if getElementData(player, "state") == "alive" and veh and player ~= lp then 
            local _,_,rot = getElementRotation(veh) 
            local ex, ey, ez = getElementPosition(veh) 
            local dist = getDistanceBetweenPoints2D(px,py,ex,ey) 
            if dist > range then 
                dist = tonumber(range) 
            end 
            local angle = 180-north + findRotation(px,py,ex,ey) 
            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,g,b,a = 255,255,255,255 
            if getPlayerTeam(player) then 
                r,g,b = getTeamColor( getPlayerTeam(player) ) 
            end 
            local img = "radar/img/blip.png" 
            if (ez - pz) >= 5 then 
                img = "radar/img/blipup.png" 
            elseif (ez - pz) <= -5 then 
                img = "radar/img/blipdown.png" 
            end 
            if tonumber(getElementModel(veh)) == 425 then 
                --r, g, b, a = 255, 0, 0, 200 
                img = "radar/img/hunter.png" 
            end 
            dxDrawImage(blipx, blipy, blipsize, blipsize, img, north-rot+45, 0, 0, tocolor(r,g,b,a)) 
            if img == "radar/img/hunter.png" then  
            rotationRotator = rotationRotator + 3 
            dxDrawImage(blipx, blipy, blipsize, blipsize, "radar/img/rotor.png", north-rot+45+rotationRotator, 0, 0) 
            end 
        end 
    end 
    dxDrawImage(centerleft - lpsize/2, centertop - lpsize/2, lpsize,lpsize, "radar/img/local.png", north-pr) 
end 
) 
  
  
  
  
addEventHandler("onClientRender", getRootElement(),  
function() 
local screenWidth, screenHeight = guiGetScreenSize() 
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...