Jump to content

Meu hud fica aparecendo no painel de login


Recommended Posts

<trinx>
  <script src="client.lua" type="client"/>
  <script src="server.lua" type="server"/>
  
  <export function="setHudVisible" type="shared"/>
  
  <file src="jquery-1.11.3.min.js" cache="false"/>

  <file src="index.html" cache="false"/>
  <file src="app.js" cache="false"/>
  <file src="style.css" cache="false"/>

  <file src="heart.svg" cache="false"/>

  <file src = "images/logo.png" cache= "false"/>

  <file src="font/Aftika-Black.eot" cache="false" />
    <file src="font/Aftika-Black.ttf" cache="false" />
    <file src="font/Aftika-Black.woff" cache="false" />
    <file src="font/Aftika-Black.woff2" cache="false" />
    <file src="font/Aftika-Bold.eot" cache="false" />
    <file src="font/Aftika-Bold.ttf" cache="false" />
    <file src="font/Aftika-Bold.woff" cache="false" />
    <file src="font/Aftika-Bold.woff2" cache="false" />
    <file src="font/Aftika-ExtraBold.eot" cache="false" />
    <file src="font/Aftika-ExtraBold.ttf" cache="false" />
    <file src="font/Aftika-ExtraBold.woff" cache="false" />
    <file src="font/Aftika-ExtraBold.woff2" cache="false" />
    <file src="font/Aftika-ExtraLight.eot" cache="false" />
    <file src="font/Aftika-ExtraLight.ttf" cache="false" />
    <file src="font/Aftika-ExtraLight.woff" cache="false" />
    <file src="font/Aftika-ExtraLight.woff2" cache="false" />
    <file src="font/Aftika-Light.eot" cache="false" />
    <file src="font/Aftika-Light.ttf" cache="false" />
    <file src="font/Aftika-Light.woff" cache="false" />
    <file src="font/Aftika-Light.woff2" cache="false" />
    <file src="font/Aftika-Regular.eot" cache="false" />
    <file src="font/Aftika-Regular.ttf" cache="false" />
    <file src="font/Aftika-Regular.woff" cache="false" />
    <file src="font/Aftika-Regular.woff2" cache="false" />
    <file src="font/Aftika-SemiBold.eot" cache="false" />
    <file src="font/Aftika-SemiBold.ttf" cache="false" />
    <file src="font/Aftika-SemiBold.woff" cache="false" />
    <file src="font/Aftika-SemiBold.woff2" cache="false" />
    <file src="font/stylesheet.css" cache="false" />
  
</trinx>

Link to comment
4 hours ago, Lord Henry said:

Sem o código fica impossível adivinhar.

Nem seu arquivo meta.xml está certo.

server.lua :

-----Funçao Exports

addEventHandler( "onPlayerLogin", root, function()

    triggerClientEvent( source, "onRequestShowPlayerHUD", source, true )
end, true, "low" )

Client :

 

local sx, sy = guiGetScreenSize()
local link = "http://mta/"..getResourceName(getThisResource()).."/index.html"
local browser = createBrowser(sx, sy, true, true)

setDevelopmentMode(true, true)

local player = {}

function TrinxHUD()
   dxDrawImage(0, 0, sx, sy, browser)
end

function updateHud()
   local health = getElementHealth(localPlayer)
   local armour = getPedArmor(localPlayer)
   SendNUIMessage(browser, {hud = true, health = health, armour = armour})
end


addEventHandler("onClientBrowserCreated", browser, function()
   loadBrowserURL(source, link)
end)

addEventHandler( "onClientBrowserDocumentReady", browser, 
function (url)
   SendNUIMessage(browser, {hud = true})

   addEventHandler( "onClientRender", getRootElement(), TrinxHUD)
end)
function SendNUIMessage(browser, table)
    if isElement(browser) and type(table) == "table" then
        return executeBrowserJavascript(browser, 'window.postMessage('..toJSON(table)..'[0])')
    end
end

setTimer(function()
   updateHud()
end, 500, 0)


---- Funçao exportada 

function setPlayerDXHudVisible( bool )
    if bool == rendering then return end
    --
    if bool == true then
        
        addEventHandler("onClientRender", getRootElement(), HUD)
        rendering = bool
    elseif bool == false then
    
        removeEventHandler("onClientRender", getRootElement(), HUD)
        rendering = bool
    end
end
addEvent( "onRequestShowPlayerHUD", true )
addEventHandler( "onRequestShowPlayerHUD", root, setPlayerDXHudVisible )

function OnStop ()
    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()), OnStop)

function OnStart ()
    setPlayerHudComponentVisible("armour", false)
    setPlayerHudComponentVisible("wanted", false)
    setPlayerHudComponentVisible("weapon", false)
    setPlayerHudComponentVisible("money", false)
    setPlayerHudComponentVisible("health", false)
    setPlayerHudComponentVisible("clock", false)
    setPlayerHudComponentVisible("breath", false)
    setPlayerHudComponentVisible("ammo", false)
end
addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), OnStart )

local hudTable = 
{
"ammo",
"armour",
"clock",
"health",
"money",
"weapon",
"wanted",
"area_name",
"vehicle_name",
"breath",
"clock"
}

addEventHandler("onClientResourceStart", resourceRoot,
    function()
    for id, hudComponents in ipairs(hudTable) do
        showPlayerHudComponent(hudComponents, false)
    end
    end
)

addEventHandler("onClientResourceStop", resourceRoot,
    function()
    for id, hudComponents in ipairs(hudTable) do
        showPlayerHudComponent(hudComponents, true)
    end
    end
)

4 hours ago, Lord Henry said:

Sem o código fica impossível adivinhar.

Nem seu arquivo meta.xml está certo.

 

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