Jump to content

[Help] Setting a bind to keep dxDrawText on the screen


Recommended Posts

addEventHandler("onClientRender", root, 
    function() 
        local screenx, screeny, worldx, worldy, worldz = getCursorPosition() 
        if (isCursorShowing() ) then 
            if (screenx >= 924 and screenx <= 977) and (screeny >= 375 and screeny <=390) then 
                redMessage = dxDrawText("Message", 924, 375, 977, 390, tocolor(255, 0, 0, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
            else 
                dxDrawText("Message", 924, 375, 977, 390, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
            end 
        else 
            dxDrawText("Message", 924, 375, 977, 390, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
        end 
        addEventHandler("onClientGUIClick", redMessage, clickOnMessage) 
    end 
) 

So this is the command I have. It's nowhere near perfect, but I just want to know how to set a bind that would toggle the function on and off. Thanks.

Link to comment

Okay try this:

function drawStuff() 
        dxDrawText("Message", 924, 375, 977, 390, tocolor(255, 0, 0, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
  
end 
  
  
local show = false 
addCommandHandler( "yourcommand", 
    function( ) 
        showMssg( not show ) 
    end 
) 
  
function showMssg( state ) 
    if state then 
        showCursor ( true ) 
        addEventHandler( "onClientRender", root, drawStuff ) 
    else 
        showCursor ( false ) 
        removeEventHandler( "onClientRender", root, drawStuff ) 
    end 
    show = state 
end 
showMssg( show ) 

Hope it help'd you can add what ever you want within the drawStuff function.

Edited by Guest
Link to comment
local show = false 
  
function drawStuff ( ) 
    dxDrawText("Message", 924, 375, 977, 390, tocolor(255, 0, 0, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
end 
  
function showMsg ( ) 
    show = ( not show ) 
    if ( show ) then 
        addEventHandler( "onClientRender", root, drawStat ) 
    else 
        removeEventHandler( "onClientRender", root, drawStat ) 
    end 
    showCursor ( show ) 
end 
bindKey ( "M", "down", showMsg ) 

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