Jump to content

Alguém me ajuda urgente


Recommended Posts

Fiz esse código da hud mas não da erro nem nada, ela só não aparece in-game

 

local screenW, screenH = guiGetScreenSize()
local resW, resH = 1600,900
local x, y = (screenW/resW), (screenH/resH)
 
local components = { "area_name", "radio", "vehicle_name" }
 
function convertNumber ( number )  
    local formatted = number  
    while true do      
        formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1.%2')    
        if ( k==0 ) then      
            break  
        end  
    end  
    return formatted
end
 
function complexohud()
    local vida = math.floor(getElementHealth(getLocalPlayer()))
    local money = convertNumber(getPlayerMoney(getLocalPlayer()))
    local bank = convertNumber(getElementData(localPlayer, "TS:Bancobb") or "0")
    local fome = getElementData(getLocalPlayer(), "hunger") or 100
    local sede = getElementData(getLocalPlayer(), "sede") or 100
 
    dxDrawRectangle(x*356, y*-435, x*86, y*86, tocolor(214, 58, 86, 255), false)
    dxDrawRectangle(x*470, y*-436, x*86, y*86, tocolor(206, 107, 35, 255), false)
    dxDrawRectangle(x*584, y*-436, x*86, y*86, tocolor(89, 186, 207, 255), false)
    dxDrawRectangle(x*698, y*-436, x*86, y*86, tocolor(148, 216, 63, 255), false)
    dxDrawImage(x*379, y*-412, x*39, y*39, "files/heart.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawImage(x*493, y*-412, x*39, y*39, "files/escudo.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawImage(x*607, y*-412, x*39, y*39, "files/garrafa.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawImage(x*721, y*-412, x*39, y*39, "files/hamburguer.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
end
 
-- IGNORAR
 
function dxDrawRoundedRectangle(x, y, rx, ry, color, radius)
    rx = rx - radius * 2
    ry = ry - radius * 2
    x = x + radius
    y = y + radius
    if (rx >= 0) and (ry >= 0) then
        dxDrawRectangle(x, y, rx, ry, color)
        dxDrawRectangle(x, y - radius, rx, radius, color)
        dxDrawRectangle(x, y + ry, rx, radius, color)
        dxDrawRectangle(x - radius, y, radius, ry, color)
        dxDrawRectangle(x + rx, y, radius, ry, color)
        dxDrawCircle(x, y, radius, 180, 270, color, color, 7)
        dxDrawCircle(x + rx, y, radius, 270, 360, color, color, 7)
        dxDrawCircle(x + rx, y + ry, radius, 0, 90, color, color, 7)
        dxDrawCircle(x, y + ry, radius, 90, 180, color, color, 7)
    end
end
function setHud()
    addEventHandler("onClientRender", getRootElement(), complexohud)
    setPlayerHudComponentVisible("armour", false)
    setPlayerHudComponentVisible("wanted", false)
    setPlayerHudComponentVisible("weapon", false)
    setPlayerHudComponentVisible("money", false)
    setPlayerHudComponentVisible("health", false)
    setPlayerHudComponentVisible("clock", false)
    setPlayerHudComponentVisible("breath", false)
    setPlayerHudComponentVisible("ammo", false)
 
    for _, component in ipairs( components ) do
        setPlayerHudComponentVisible( component, false )
    end
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), setHud)
 
function removeHud()
    setPlayerHudComponentVisible("armour", true)
    setPlayerHudComponentVisible("wanted", true)
    setPlayerHudComponentVisible("weapon", true)
    setPlayerHudComponentVisible("money", true)
    setPlayerHudComponentVisible("health", true)
    setPlayerHudComponentVisible("clock", true)
    setPlayerHudComponentVisible("breath", true)
    setPlayerHudComponentVisible("ammo", true)
end
addEventHandler("onClientResourceStop", getResourceRootElement(getThisResource()), removeHud)
Link to comment
On 09/08/2022 at 15:48, filsk said:

Fiz esse código da hud mas não da erro nem nada, ela só não aparece in-game

 

local screenW, screenH = guiGetScreenSize()
local resW, resH = 1600,900
local x, y = (screenW/resW), (screenH/resH)
 
local components = { "area_name", "radio", "vehicle_name" }
 
function convertNumber ( number )  
    local formatted = number  
    while true do      
        formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1.%2')    
        if ( k==0 ) then      
            break  
        end  
    end  
    return formatted
end
 
function complexohud()
    local vida = math.floor(getElementHealth(getLocalPlayer()))
    local money = convertNumber(getPlayerMoney(getLocalPlayer()))
    local bank = convertNumber(getElementData(localPlayer, "TS:Bancobb") or "0")
    local fome = getElementData(getLocalPlayer(), "hunger") or 100
    local sede = getElementData(getLocalPlayer(), "sede") or 100
 
    dxDrawRectangle(x*356, y*-435, x*86, y*86, tocolor(214, 58, 86, 255), false)
    dxDrawRectangle(x*470, y*-436, x*86, y*86, tocolor(206, 107, 35, 255), false)
    dxDrawRectangle(x*584, y*-436, x*86, y*86, tocolor(89, 186, 207, 255), false)
    dxDrawRectangle(x*698, y*-436, x*86, y*86, tocolor(148, 216, 63, 255), false)
    dxDrawImage(x*379, y*-412, x*39, y*39, "files/heart.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawImage(x*493, y*-412, x*39, y*39, "files/escudo.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawImage(x*607, y*-412, x*39, y*39, "files/garrafa.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawImage(x*721, y*-412, x*39, y*39, "files/hamburguer.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
end
 
-- IGNORAR
 
function dxDrawRoundedRectangle(x, y, rx, ry, color, radius)
    rx = rx - radius * 2
    ry = ry - radius * 2
    x = x + radius
    y = y + radius
    if (rx >= 0) and (ry >= 0) then
        dxDrawRectangle(x, y, rx, ry, color)
        dxDrawRectangle(x, y - radius, rx, radius, color)
        dxDrawRectangle(x, y + ry, rx, radius, color)
        dxDrawRectangle(x - radius, y, radius, ry, color)
        dxDrawRectangle(x + rx, y, radius, ry, color)
        dxDrawCircle(x, y, radius, 180, 270, color, color, 7)
        dxDrawCircle(x + rx, y, radius, 270, 360, color, color, 7)
        dxDrawCircle(x + rx, y + ry, radius, 0, 90, color, color, 7)
        dxDrawCircle(x, y + ry, radius, 90, 180, color, color, 7)
    end
end
function setHud()
    addEventHandler("onClientRender", getRootElement(), complexohud)
    setPlayerHudComponentVisible("armour", false)
    setPlayerHudComponentVisible("wanted", false)
    setPlayerHudComponentVisible("weapon", false)
    setPlayerHudComponentVisible("money", false)
    setPlayerHudComponentVisible("health", false)
    setPlayerHudComponentVisible("clock", false)
    setPlayerHudComponentVisible("breath", false)
    setPlayerHudComponentVisible("ammo", false)
 
    for _, component in ipairs( components ) do
        setPlayerHudComponentVisible( component, false )
    end
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), setHud)
 
function removeHud()
    setPlayerHudComponentVisible("armour", true)
    setPlayerHudComponentVisible("wanted", true)
    setPlayerHudComponentVisible("weapon", true)
    setPlayerHudComponentVisible("money", true)
    setPlayerHudComponentVisible("health", true)
    setPlayerHudComponentVisible("clock", true)
    setPlayerHudComponentVisible("breath", true)
    setPlayerHudComponentVisible("ammo", true)
end
addEventHandler("onClientResourceStop", getResourceRootElement(getThisResource()), removeHud)

Não há nenhum evento acionando a hud, tente usar onClientRender

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