Jump to content

Help-Hud


Best-Killer1

Recommended Posts

Posted

Are we supposed to figure out what's wrong with the screenshot? It looks fine to me.

Is this related to your other topic?

Posted

Post your code then. I checked it from the other topic, you're adding the handler as soon as the script starts.

Use onPlayerLogin server-side to trigger a client event, add the on render handler in that event.

Posted

this code

local newFont = dxCreateFont( "font/font.ttf", 15 )

local newFont2 = dxCreateFont( "font/font.ttf", 9 )

local newFont3 = dxCreateFont( "font/font.ttf", 24 )

local LOCAL_PLAYER = getLocalPlayer()

pos = getElementPosition(LOCAL_PLAYER)

showPlayerHudComponent("radar",true)

showPlayerHudComponent ("weapon", false )

showPlayerHudComponent ( "ammo", false )

showPlayerHudComponent ("vehicle_name", false )

function dxtest()

local playerX, playerY, playerZ = getElementPosition( LOCAL_PLAYER ) -- Get player's coordinates.

local playerZoneName = getZoneName( playerX, playerY, playerZ )

local health = string.format("%03d", (getElementHealth(LOCAL_PLAYER)))

local armor = math.floor (getPedArmor(LOCAL_PLAYER))

local stat = getPedStat(LOCAL_PLAYER,24)

local time = getRealTime()

local hr,mins = getTime()

local time3 = hr..":"..(((mins <10) and "0"..mins) or mins)

local hours = time.hour

local minutes = time.minute

local sWidth,sHeight = guiGetScreenSize()

dxDrawImage((740/1024)*sWidth, (8/768)*sHeight, (283/1024)*sWidth, (120/768)*sHeight, "outras/background.png",0,0,0,tocolor(0,0,0,255))

dxDrawImage((868/1024)*sWidth, (60/768)*sHeight, (148/1024)*sWidth, (38/768)*sHeight, "outras/background.png",0,0,0,tocolor(255,255,255,255))

dxDrawImage((873/1024)*sWidth, (63/768)*sHeight, (22/1024)*sWidth, (33/768)*sHeight, "outras/$.png",0,0,0,tocolor(255,255,255,255))

dxDrawImage((765/1024)*sWidth, (25/768)*sHeight, (85/1024)*sWidth, (85/768)*sHeight, "img/"..getPedWeapon(getLocalPlayer())..".png")

local moneycount = getPlayerMoney(getLocalPlayer())

local money = ' ' ..moneycount -- Money

dxDrawText(tostring (money),(886/1024)*sWidth, (63/768)*sHeight, (310/1024)*sWidth, (60/768)*sHeight, tocolor(255,255,255,255), (sWidth/1024)*1.10, newFont,"left","top",false,false,false)

dxDrawText("SAEG:RPG",(910/1024)*sWidth, (98/768)*sHeight, (310/1024)*sWidth, (135/768)*sHeight, tocolor(0,102,0,255), (sWidth/1000)*1.25, newFont2,"left","top",false,false,false)

--dxDrawText("000",(900/1024)*sWidth, (13/768)*sHeight, (310/1024)*sWidth, (60/768)*sHeight, tocolor(255,255,255,150), (sWidth/1024)*0.90, newFont3,"left","top",false,false,false)

dxDrawText(tostring (armor).." %",(875/1024)*sWidth, (24/768)*sHeight, (310/1024)*sWidth, (60/768)*sHeight, tocolor(255,255,255,255), (sWidth/1024)*0.40, newFont3,"left","top",false,false,false)

dxDrawImage((845.7/1024)*sWidth, (24/768)*sHeight, (30/1024)*sWidth, (20/768)*sHeight, "outras/armor.png")

dxDrawText(tostring (health).." %",(950/1024)*sWidth, (19/768)*sHeight, (310/1024)*sWidth, (60/768)*sHeight, tocolor(255,255,255,255), (sWidth/1024)*0.60, newFont3,"left","top",false,false,false)

dxDrawImage((920.7/1024)*sWidth, (19/768)*sHeight, (30/1024)*sWidth, (30/768)*sHeight, "outras/HP.png")

--dxDrawText(tostring (armor).." %",(906/1024)*sWidth, (73/768)*sHeight, (310/1024)*sWidth, (60/768)*sHeight, tocolor(255,255,255,255), (sWidth/1024)*0.90, "pricedown","left","top",false,false,false)

--dxDrawText(time3,(875/1024)*sWidth, (30/768)*sHeight, (310/1024)*sWidth, (60/768)*sHeight, tocolor(255,255,0,255), (sWidth/1024)*1.20, "pricedown","left","top",false,false,false)

--dxDrawText("r$: "..money,(800/1024)*sWidth, (140/768)*sHeight, (310/1024)*sWidth, (60/768)*sHeight, tocolor(34,178,170,255), (sWidth/1024)*1.10, "pricedown","left","top",false,false,false)

end

addEventHandler("onClientRender",getRootElement(), dxtest)

root = getResourceRootElement()

function changeit()

showPlayerHudComponent("money",false)

showPlayerHudComponent("area_name",false)

showPlayerHudComponent("health",false)

showPlayerHudComponent("clock",false)

showPlayerHudComponent("armour",false)

showPlayerHudComponent("oxygen",false)

end

addEventHandler("onClientResourceStart",root, changeit)

function inCar()

triggerEvent("onEnter",getLocalPlayer(),inCar)

end

addEventHandler("onClientVehicleEnter",getRootElement(),inCar)

function outOfCar()

removeEventHandler("onEnter",getLocalPlayer(),outOfCar)

end

addEventHandler("onClientVehicleExit",getRootElement(),outOfCar)

function carHealth()

local sWidth,sHeight = guiGetScreenSize()

if isPedInVehicle(getLocalPlayer()) then

vehicle = getPedOccupiedVehicle(getLocalPlayer())

health = math.ceil(getElementHealth(vehicle) / 10)

speedx, speedy, speedz = getElementVelocity ( vehicle)

actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)

kmh = math.ceil(actualspeed * 180)

end

end

addEvent("onEnter",true)

addEventHandler("onEnter",getRootElement(),carHealth)

addEventHandler("onClientRender",getRootElement(),carHealth)

function drawWeaponImageOnChange( prevSlot, newSlot )

if getElementData(getLocalPlayer(), "loggedin") == 1 then

local weapon = getPedWeapon(getLocalPlayer(), newSlot)

local ammoInClip = getPedAmmoInClip(getLocalPlayer())

local ammo = getPedTotalAmmo(getLocalPlayer()) - ammoInClip

if (newSlot ~= 0 and newSlot ~= 1 and newSlot ~= 10 and newSlot ~= 11 and newSlot ~= 12) then

if not isElement(weaponAmmo) then

weaponAmmo = guiCreateLabel(screenX - 180, screenYStart + 86, 100, 100, tostring(ammo) .." - ".. tostring(ammoInClip), false)

guiSetFont(weaponAmmo, "default-bold-small")

else

guiSetText(weaponAmmo, tostring(ammo) .." - ".. tostring(ammoInClip))

end

else

if isElement(weaponAmmo) then

destroyElement(weaponAmmo)

end

end

end

end

addEventHandler("onClientPlayerWeaponSwitch", getLocalPlayer(), drawWeaponImageOnChange)

if fileExists("client.lua") then fileDelete("client.lua") end

Posted

Did you try what I told you to?

Use onPlayerLogin server-side to trigger a client event, add the on render handler in that event
Posted (edited)
Post your updated code.

This The New Code (Radar Fixed but the hud still showing)

local newFont = dxCreateFont( "font/font.ttf", 15 ) 
local newFont2 = dxCreateFont( "font/font.ttf", 9 ) 
local newFont3 = dxCreateFont( "font/font.ttf", 24 ) 
  
local LOCAL_PLAYER = getLocalPlayer() 
pos = getElementPosition(LOCAL_PLAYER) 
showPlayerHudComponent("radar",true) 
showPlayerHudComponent ("weapon", false ) 
showPlayerHudComponent ( "ammo", false ) 
showPlayerHudComponent ("vehicle_name", false ) 
addEventHandler ( "onPlayerJoin", getRootElement(), hudChanger ) 
  
  
function dxtest() 
local playerX, playerY, playerZ = getElementPosition( LOCAL_PLAYER )  -- Get player's coordinates. 
           
    local playerZoneName =  getZoneName( playerX, playerY, playerZ )  
    local health = string.format("%03d", (getElementHealth(LOCAL_PLAYER))) 
    local armor = math.floor (getPedArmor(LOCAL_PLAYER)) 
     
  
  
  
  
  
    local stat = getPedStat(LOCAL_PLAYER,24) 
    local time = getRealTime() 
    local hr,mins = getTime() 
    local time3 = hr..":"..(((mins <10) and "0"..mins) or mins) 
    local hours = time.hour 
    local minutes = time.minute 
    local sWidth,sHeight = guiGetScreenSize() 
  
  
    dxDrawImage((740/1024)*sWidth, (8/768)*sHeight, (283/1024)*sWidth, (120/768)*sHeight, "outras/background.png",0,0,0,tocolor(0,0,0,255)) 
    dxDrawImage((868/1024)*sWidth, (60/768)*sHeight, (148/1024)*sWidth, (38/768)*sHeight, "outras/background.png",0,0,0,tocolor(255,255,255,255)) 
    dxDrawImage((873/1024)*sWidth, (63/768)*sHeight, (22/1024)*sWidth, (33/768)*sHeight, "outras/$.png",0,0,0,tocolor(255,255,255,255)) 
    dxDrawImage((765/1024)*sWidth, (25/768)*sHeight, (85/1024)*sWidth, (85/768)*sHeight, "img/"..getPedWeapon(getLocalPlayer())..".png") 
  
  
  
  
    local moneycount = getPlayerMoney(getLocalPlayer()) 
    local money = ' ' ..moneycount -- Money 
    dxDrawText(tostring (money),(886/1024)*sWidth, (63/768)*sHeight, (310/1024)*sWidth, (60/768)*sHeight, tocolor(255,255,255,255), (sWidth/1024)*1.10, newFont,"left","top",false,false,false)  
  
  
  
  
  
  
  
  
    dxDrawText("SAEG:RPG",(910/1024)*sWidth, (98/768)*sHeight, (310/1024)*sWidth, (135/768)*sHeight, tocolor(0,102,0,255), (sWidth/1000)*1.25, newFont2,"left","top",false,false,false)  
    --dxDrawText("000",(900/1024)*sWidth, (13/768)*sHeight, (310/1024)*sWidth, (60/768)*sHeight, tocolor(255,255,255,150), (sWidth/1024)*0.90, newFont3,"left","top",false,false,false) 
  
  
    dxDrawText(tostring (armor).." %",(875/1024)*sWidth, (24/768)*sHeight, (310/1024)*sWidth, (60/768)*sHeight, tocolor(255,255,255,255), (sWidth/1024)*0.40, newFont3,"left","top",false,false,false) 
    dxDrawImage((845.7/1024)*sWidth, (24/768)*sHeight, (30/1024)*sWidth, (20/768)*sHeight, "outras/armor.png") 
  
  
    dxDrawText(tostring (health).." %",(950/1024)*sWidth, (19/768)*sHeight, (310/1024)*sWidth, (60/768)*sHeight, tocolor(255,255,255,255), (sWidth/1024)*0.60, newFont3,"left","top",false,false,false) 
    dxDrawImage((920.7/1024)*sWidth, (19/768)*sHeight, (30/1024)*sWidth, (30/768)*sHeight, "outras/HP.png") 
  
  
     
     
     
--dxDrawText(tostring (armor).." %",(906/1024)*sWidth, (73/768)*sHeight, (310/1024)*sWidth, (60/768)*sHeight, tocolor(255,255,255,255), (sWidth/1024)*0.90, "pricedown","left","top",false,false,false) 
  
  
     
    --dxDrawText(time3,(875/1024)*sWidth, (30/768)*sHeight, (310/1024)*sWidth, (60/768)*sHeight, tocolor(255,255,0,255), (sWidth/1024)*1.20, "pricedown","left","top",false,false,false) 
  
  
     
     
    --dxDrawText("r$: "..money,(800/1024)*sWidth, (140/768)*sHeight, (310/1024)*sWidth, (60/768)*sHeight, tocolor(34,178,170,255), (sWidth/1024)*1.10, "pricedown","left","top",false,false,false)  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
end 
addEventHandler("onClientHUDRender",getRootElement(), dxtest) 
  
  
  
  
  
root = getResourceRootElement() 
function changeit() 
showPlayerHudComponent("money",false) 
showPlayerHudComponent("area_name",false) 
showPlayerHudComponent("health",false) 
showPlayerHudComponent("clock",false) 
showPlayerHudComponent("armour",false) 
showPlayerHudComponent("oxygen",false) 
end 
addEventHandler("onClientResourceStart",root, changeit) 
  
  
  
  
function inCar() 
triggerEvent("onEnter",getLocalPlayer(),inCar) 
end 
addEventHandler("onClientVehicleEnter",getRootElement(),inCar) 
  
function outOfCar() 
removeEventHandler("onEnter",getLocalPlayer(),outOfCar) 
end 
addEventHandler("onClientVehicleExit",getRootElement(),outOfCar) 
  
function carHealth() 
local sWidth,sHeight = guiGetScreenSize() 
if isPedInVehicle(getLocalPlayer()) then 
vehicle = getPedOccupiedVehicle(getLocalPlayer()) 
health = math.ceil(getElementHealth(vehicle) / 10) 
speedx, speedy, speedz = getElementVelocity ( vehicle) 
actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)  
kmh = math.ceil(actualspeed * 180) 
  
end 
end 
addEvent("onEnter",false) 
addEventHandler("onEnter",getRootElement(),carHealth) 
addEventHandler("onClientHUDRender",getRootElement(),carHealth) 
function drawWeaponImageOnChange( prevSlot, newSlot ) 
    if getElementData(getLocalPlayer(), "loggedin") == 1 then 
        
        local weapon = getPedWeapon(getLocalPlayer(), newSlot) 
            
        
        local ammoInClip = getPedAmmoInClip(getLocalPlayer()) 
        local ammo = getPedTotalAmmo(getLocalPlayer()) - ammoInClip 
        
        if (newSlot ~= 0 and newSlot ~= 1 and newSlot ~= 10 and newSlot ~= 11 and newSlot ~= 12) then 
            
            if not isElement(weaponAmmo) then 
                weaponAmmo = guiCreateLabel(screenX - 180, screenYStart + 86, 100, 100, tostring(ammo) .." - ".. tostring(ammoInClip), false) 
                guiSetFont(weaponAmmo, "default-bold-small") 
            else 
                guiSetText(weaponAmmo, tostring(ammo) .." - ".. tostring(ammoInClip)) 
            end  
        else 
            if isElement(weaponAmmo) then 
                destroyElement(weaponAmmo) 
            end  
        end  
    end  
end 
addEventHandler("onClientPlayerWeaponSwitch", getLocalPlayer(), drawWeaponImageOnChange)    
  
  
  
  
  
  
  
if fileExists("client.lua") then fileDelete("client.lua") end 

Edited by Guest
Posted

Server:

addEventHandler('onPlayerLogin', root, function() 
 triggerClientEvent(source, 'showHud', resourceRoot) 
end) 

Client:

addEvent('showHud', true) 
addEventHandler('showHud', root, function() 
 addEventHandler("onClientHUDRender",getRootElement(), dxtest) 
end) 

Remove line 94 from the rest of the code.

Posted
Server:
addEventHandler('onPlayerLogin', root, function() 
 triggerClientEvent(source, 'showHud', resourceRoot) 
end) 

Client:

addEvent('showHud', true) 
addEventHandler('showHud', root, function() 
 addEventHandler("onClientHUDRender",getRootElement(), dxtest) 
end) 

Remove line 94 from the rest of the code.

pfff same problem :(:'(:| Thanx Everyone JR10 pls try to see anyway for fix it please :'(

Posted

What's the problem exactly here? The code should solve the hud showing on join.

If it doesn't, post any errors or warnings in /debugscript 3

Posted
What's the problem exactly here? The code should solve the hud showing on join.

If it doesn't, post any errors or warnings in /debugscript 3

the hud showing boffer logined :/ this is the problem

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