Jump to content

[Ayuda] HUD


Recommended Posts

Hola :P El otro día encontré un hud en la comunidad, me gusto y me puse a editarlo, entonces se me ocurrió hacer el radar cuadrado, como en el GTA 5, y me quedo asi:

1004898_538036316243465_1883815731_n.jpg

Mi pregunta esta vez era si se puede hacer que el radar se muestre adentro de ese cuadrado, no se si sea posible por eso recurro aqui :D

Así que, es posible o tendré que llegar hasta ahí nomas? Y si es posible me dicen mas o menos que funciones se utilizan para eso? :)

Este es mi hud (por si las dudas xD)

FPSLimit = 60 
FPSMax = 1 
player = getLocalPlayer() 
local sWidth, sHeight = guiGetScreenSize() --Resolucion d la pantalla. 
  
function HudXD () 
     
g_Player = getLocalPlayer() -- Variable de getLocalPlayer() 
AmmoImClip = getPedAmmoInClip(g_Player) 
money = getPlayerMoney(g_Player) 
vida = getElementHealth(g_Player) 
totalammo = getPedTotalAmmo(g_Player)-getPedAmmoInClip(g_Player) 
armor = getPedArmor(g_Player) 
lineaBalasInClip = 80 * ( AmmoImClip / 120 )  
lineaarmor = 140 * ( armor / 100 ) 
VidaBar = 140 * ( vida / 100 ) 
local hour, minits = getTime() 
local zone = getZoneName (getElementPosition(getLocalPlayer())) 
    --   
     dxDrawRectangle(sWidth-775,sHeight-50, 145, 13.5, tocolor ( 0, 0, 0, 80 ), false) -- Armor Bar 
      
  
     dxDrawRectangle(sWidth-773,sHeight-49,lineaarmor,10.5,tocolor(0,170,255,200) ,false) --Armor 
      
     dxDrawText("$ " ..money, sWidth-150, sHeight-590, sWidth, sHeight, tocolor(200, 200, 200, 255), 0.8, "bankgothic")--Dinero Text 
     dxDrawText(tostring(math.floor(armor+0.1)), sWidth-620, sHeight-53, sWidth, sHeight, tocolor(200, 200, 200, 255), 0.6, "bankgothic") -- Amor Text 
  
     dxDrawRectangle(sWidth-160,sHeight-50,lineaBalasInClip,5.5,tocolor(255,152,0,250) ,false) 
     dxDrawText(totalammo, sWidth-90, sHeight-30, sWidth, sHeight, tocolor(200, 200, 200, 255), 0.5, "bankgothic") 
     dxDrawText(AmmoImClip, sWidth-90, sHeight-55, sWidth, sHeight, tocolor(200, 200, 200, 255), 0.5, "bankgothic") -- Bullets Text 
                  
     dxDrawRectangle(sWidth-775,sHeight-26.5, 145, 13.5, tocolor ( 0, 0, 0, 80 ), false)-- Health Bar 
      
     dxDrawRectangle(sWidth-773,sHeight-25,VidaBar,10.5,tocolor(0,180,0,250) ,false) -- Health 
      
     dxDrawText(zone, (43/1024)*sWidth, (495/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), (0.7/1366)*sWidth,(0.7/768)*sHeight,"bankgothic","left","top",false,false,false,true) --Lugar 
      
     dxDrawText(tostring(math.floor(vida+0.1)), sWidth-620, sHeight-30, sWidth, sHeight, tocolor(200, 200, 200, 255), 0.6, "bankgothic") -- Health Text 
      
    local weaponID = getPedWeapon (g_Player); -- Get weapon ID 
    dxDrawImage(sWidth-100,sHeight-100,90.2,48.100,"icons/".. tostring( weaponID ) .. ".png",0.0,0.0,0.0,tocolor(255,255,255,200),false) 
      
    --Gets the vehicle & checks if is the ped in a vehicle (for evade the debug spam with bad arguments when someone is on foot) 
    vehicle = getPedOccupiedVehicle(getLocalPlayer()) 
    if ( vehicle ) then --checking 
        -- Gets some vehicle elements (gear, speed in MPH and KMH and health) 
        speedx, speedy, speedz = getElementVelocity ( vehicle  ) 
        actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)  
        kmh = math.floor(actualspeed*180) -- Kilometers per hour 
        mph = math.floor(actualspeed * 111.847) -- Milles per hour 
        mps = math.floor (actualspeed) -- Metres per second 
         
        dxDrawText("KM/H: "..kmh, (780/1024)*sWidth, (725/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (0, 0, 0, 255), (0.85/1366)*sWidth,(0.85/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
end  
      
end 
addEventHandler("onClientRender",root,HudXD) 
addEventHandler("onPlayerSpawn", resourceRoot,HudXD) 
  
--Esto desactiva el HUD original 
function hideall(player) 
    showPlayerHudComponent ( "ammo", false ) 
    showPlayerHudComponent ( "area_name", false ) 
    showPlayerHudComponent ( "armour", false ) 
    showPlayerHudComponent ( "breath", false ) 
    showPlayerHudComponent ( "clock", false ) 
    showPlayerHudComponent ( "health", false ) 
    showPlayerHudComponent ( "money", false ) 
    showPlayerHudComponent ( "vehicle_name", false ) 
    showPlayerHudComponent ( "weapon", false ) 
end 
addEventHandler ( "onClientResourceStart", getRootElement(), hideall ) 
  
function showall(player) 
    showPlayerHudComponent ( "ammo", true ) 
    showPlayerHudComponent ( "area_name", true ) 
    showPlayerHudComponent ( "armour", true ) 
    showPlayerHudComponent ( "breath", true ) 
    showPlayerHudComponent ( "clock", true ) 
    showPlayerHudComponent ( "health", true ) 
    showPlayerHudComponent ( "money", true ) 
    showPlayerHudComponent ( "vehicle_name", true ) 
    showPlayerHudComponent ( "weapon", true ) 
end 
addEventHandler ( "onClientResourceStop", resourceRoot, showall ) 
  
function onClientResourceStart ( resource ) 
    if ( guiFPSLabel == nil ) then 
        FPSLimit = 255 / FPSLimit 
        FPSCalc = 0 
        FPSTime = getTickCount() + 1000 
        addEventHandler ( "onClientRender", getRootElement (), onClientRender ) 
    end 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), onClientResourceStart ) 
  
function onClientRender ( ) 
    if getElementData(player, "state.hud") == "disabled" then 
    return 
    end 
    if getElementData(localPlayer, "hud.ping") then 
    dxDrawText("PING: "..getElementData(localPlayer, "hud.ping"), (930/1024)*sWidth, (610/768)*sHeight, (130/1024)*sWidth, (130/768)*sHeight, tocolor (255, 255, 255, 255), (0.6/1366)*sWidth,(0.6/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
    end 
    if ( getTickCount() < FPSTime ) then 
        FPSCalc = FPSCalc + 1 
    else 
        if ( FPSCalc > FPSMax ) then FPSLimit = 255 / FPSCalc FPSMax = FPSCalc end 
        setElementData(player, "FPS", FPSCalc) 
        FPSCalc = 0 
        FPSTime = getTickCount() + 1000 
    end 
dxDrawText("FPS: "..getElementData(getLocalPlayer(), "FPS"), (930/1024)*sWidth, (590/768)*sHeight, (130/1024)*sWidth, (130/768)*sHeight, tocolor (255, 255, 255, 255), (0.6/1366)*sWidth,(0.6/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
end 
  
function refreshHUDPing() 
setElementData(localPlayer, "hud.ping", getPlayerPing(localPlayer)) 
end 
setTimer(refreshHUDPing, 1000, 0) 

local sx,sy = guiGetScreenSize() 
local posx = sy * 0.05 
local posy = sy * 0.680 
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() 
  
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 
  
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) 
  
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) 
    dxDrawRectangle(26, 402, 145, 146, tocolor(0, 0, 0, 150), false) 
    dxDrawRectangle(27, 403, 143, 144, tocolor(255, 255, 255, 100), false) 
    dxDrawImage(posx,posy,height,height, "img/north.png", north) 
    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 
        --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 
             
            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 = "img/blip.png" 
            if (ez - pz) >= 5 then 
                img = "img/blipup.png" 
            elseif (ez - pz) <= -5 then 
                img = "img/blipdown.png" 
            end 
            if not huntersonly and tonumber(getElementModel(veh)) == 425 then 
                r, g, b, a = 255, 0, 0, 200 
            end 
            dxDrawImage(blipx, blipy, blipsize, blipsize, img, north-rot+45, 0, 0, tocolor(r,g,b,a)) 
        end 
    end 
    dxDrawImage(centerleft - lpsize/2, centertop - lpsize/2, lpsize,lpsize, "img/local.png", north-pr) 
    if getPedOccupiedVehicle(lp) then 
        local vtype = getVehicleType(getPedOccupiedVehicle(lp)) 
        if vtype == "Plane" or vtype == "Helicopter" then 
            local vh = 1 - math.min(1,math.max(0,pz/810)) 
            dxDrawRectangle( posx/3, posy, posx/3, height, tocolor(0,0,0,130)) 
            dxDrawLine( posx/4, posy + vh*height, posx*0.75, posy + vh*height, tocolor(255,255,255,255)) 
        end 
    end 
end 
) 

Gracias de antemano :)

Link to comment
Mmm nose cuales funciones se necesitan pero puede ser no se si sirva: guíense del script de el HUD De Gta IV Y En una parte del script debe estar el radar ... y lo copian y pegan las posiciones.

Estuve viendo ese hud y es difícil (para mi) pero creo que lo que hace es crear una imagen del mapa de San Andreas y lo va pasando por donde va el usuario, pero no entendí mucho :/ No se bien como es :cry:

Link to comment
Mmm nose cuales funciones se necesitan pero puede ser no se si sirva: guíense del script de el HUD De Gta IV Y En una parte del script debe estar el radar ... y lo copian y pegan las posiciones.

Estuve viendo ese hud y es difícil (para mi) pero creo que lo que hace es crear una imagen del mapa de San Andreas y lo va pasando por donde va el usuario, pero no entendí mucho :/ No se bien como es :cry:

Pasame el link de descarga y veré que puedo hacer

Link to comment
Mmm nose cuales funciones se necesitan pero puede ser no se si sirva: guíense del script de el HUD De Gta IV Y En una parte del script debe estar el radar ... y lo copian y pegan las posiciones.

Estuve viendo ese hud y es difícil (para mi) pero creo que lo que hace es crear una imagen del mapa de San Andreas y lo va pasando por donde va el usuario, pero no entendí mucho :/ No se bien como es :cry:

Pasame el link de descarga y veré que puedo hacer

Este es

Link to comment
  • Administrators
Lo que tienes que hacer es mostrar el radar original y reemplazar el borde del radar a nada (? por medio de shardes.

Aquí te ayudaran a resolver las dudas que tengas, no puedo ayudarte por ahora, suerte :)

+1 ..Si encuentras la solucion, hasmela saber..Gracias

Link to comment
  • Recently Browsing   0 members

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