Jump to content

[HELP] dxText above player's head


HeK

Recommended Posts

Hello there forum,

I'd like to know how i could put some text above a player's head?

I'm working on a damage display script, and i'd like to have it displayed above the player that's getting shot.

local screenWidth, screenHeight = guiGetScreenSize ( ) 
  
kill = {} 
  
addEventHandler("onClientPedDamage",root, 
    function ( attaker, weapon) 
        local lostHealth = "-" .. math.ceil(getElementHealth(source)) 
        if ( attaker and attaker == localPlayer ) then 
            if ( kill[localPlayer] ) then 
                killTimer(displayTimer) 
            end 
            dxDrawText ( lostHealth, 700, screenHeight - 545, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.12, "default-small" ) 
            dxDrawText ( lostHealth, 700, screenHeight - 545, screenWidth, screenHeight, tocolor ( 0, 255, 0, 255 ), 1.1, "default-small" ) 
            displayTimer = setTimer(dxDrawText,5000,1) 
        end 
    end 
) 

Link to comment

local screenWidth, screenHeight = guiGetScreenSize ( ) 
setElementData(localPlayer,"EventHandler",false) 
  
addEventHandler("onClientPedDamage",root, 
    function ( attaker, weapon) 
         lostHealth = "-" .. math.ceil(getElementHealth(source)) 
        if ( attaker and attaker == localPlayer ) then 
        setTimer(function()  
        if getElementData(localPlayer,"EventHandler") == true then return setElementData(localPlayer,"EventHandler",false) and removeEventHandler("onClientRender",root,Draw)  end; 
        setElementData(localPlayer,"EventHandler",true) 
        addEventHandler("onClientRender",root,Draw)  
        end,5000,1) 
        end 
    end 
) 
  
function Draw() 
            dxDrawText ( lostHealth, 700, screenHeight - 545, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.12, "default-small" ) 
            dxDrawText ( lostHealth, 700, screenHeight - 545, screenWidth, screenHeight, tocolor ( 0, 255, 0, 255 ), 1.1, "default-small" ) 
end 
  
  
  

Try this will show the ped health after 5 sec!

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