Jump to content

[help] DxDrawText


Recommended Posts

I want that when my god-mode is activated A message appears on top of my head for members to know that I'm using god.

My Cliente.lua:

addEventHandler ( "onClientPlayerDamage",root, 
function () 
    if getElementData(source,"invincible") then 
        cancelEvent() 
    end 
end) 
  
addEventHandler("onClientPlayerStealthKill",localPlayer, 
function (targetPlayer) 
    if getElementData(targetPlayer,"invincible") then 
        cancelEvent() 
    end 
end) 
  
local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) 

I know I have to use more dxdrawtext already tested and failed.

What do I add could please!

Link to comment

If you're storing data in element in "invincible" key then check it in onClientRender then draw the text (dxDrawText is what you asked about and what you should use in onClientRender event).

addEventHandler( "onClientRender", root,  
    function( ) 
        for _, plr in pairs( getElementsByType( "player" ) ) do -- iterate through all players 
            if isElementOnScreen( plr ) and getElementData( plr, "invincible" ) then -- check if player is on screen, then draw the text or an image 
                -- dxDrawText or dxDrawImage 
                -- you'll need to use getScreenFromWorldPosition to get the screen position (X and Y coords) of the player (getElementPosition or getPedBonePosition) 
            end 
        end 
    end, 
) 
  

Link to comment

I could not please help

well tried and it did not:

addEventHandler ( "onClientPlayerDamage",root, 
function () 
    if getElementData(source,"invincible") then 
        cancelEvent() 
    end 
end) 
  
addEventHandler("onClientPlayerStealthKill",localPlayer, 
function (targetPlayer) 
    if getElementData(targetPlayer,"invincible") then 
        cancelEvent() 
    end 
end) 
  
addEventHandler( "onClientRender", root, 
    function( ) 
        for _, plr in pairs( getElementsByType( "player" ) ) do -- iterate through all players 
            if isElementOnScreen( plr ) and getElementData( plr, "invincible" ) then -- check if player is on screen, then draw the text or an image 
              dxDrawText( 'GODMODE On '..invincible, px, py + scY/38, px, py, tocolor( 255, 255, 255, 255 ), 1, 'default-bold', 'center', 'center', false, false ); 
            end 
        end 
    end, 
  
  

HEEEEELP add me, I'm still newbie

Link to comment

try this :

addEventHandler ( "onClientPlayerDamage",root, 
    function () 
        if getElementData(source,"invincible") then 
            cancelEvent() 
        end 
    end 
) 
  
addEventHandler("onClientPlayerStealthKill",localPlayer, 
    function (targetPlayer) 
        if getElementData(targetPlayer,"invincible") then 
            cancelEvent() 
        end 
    end 
) 
  
addEventHandler( 'onClientRender', root, 
    function( ) 
        for _, player in ipairs( getElementsByType( 'player') ) do 
            if isElementOnScreen( player ) and getElementData( player, 'invincible' ) then 
                local x, y, z = getElementPosition( player ); 
                local cx, cy, cz = getCameraMatrix( ); 
                if getDistanceBetweenPoints3D( cx, cy, cz, x, y, z ) <= 15 then 
                    local px, py = getScreenFromWorldPosition( x, y, z + 1.3, 0.06 ); 
                    if px then 
                        dxDrawText( 'GodMode : ' .. tostring( getElementData( player, "invincible" ) ), px, py, px, py, tocolor( 255, 255, 255, 255 ), 1, "arial-bold", "center", "center", false, false, false , true  ); 
                    end 
                end 
            end 
        end 
    end 
); 

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