Jump to content

How to make a graphic for a bind?


Recommended Posts

1 hour ago, NieZnanyUserOk said:

clicking the key

I think you meant to say "pressing" the key. Take a look at the dxDrawRectangle family of functions. Inside of an onClientRender event handler you can draw a black-color entire screen rectangle by fetching the current screen dimensions using guiGetScreenSize. By using bindKey in combination with the "down" key state you can register a press-down handler for the "F2" key. Inside of the press down handler you set the condition to true that enables the dxDrawRectangle call.

  • Sad 1
Link to comment

Could you send lightly ready code? As I am new and I do not understand too much, please send only the beginning of the code

 

TrybInterakcji = false

local sx, sy = guiGetScreenSize()
local px, py = (sx/1920), (sy/1080)

function isMouseIn ( x, y, width, height )
	if ( not isCursorShowing( ) ) then
		return false
	end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end

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

function gui()
    dxDrawImage(0*px, 0*py, 1920*px, 1080*py, "screen.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawText("Test", 255*px, 268*py, 100*px, 40*py, tocolor(255, 255, 255), 1.0*px, font, "center", "top",false,false,false,true)
end

bindKey("F2", "down", function()
        TrybInterakcji = true
        addEventHandler("onClientRender", root, gui)
        showCursor(true)
	end
    end
end

Where is problem?

 

unknown.png

Link to comment
26 minutes ago, NieZnanyUserOk said:

Where is problem?

bindKey("F2", "down", function()
        TrybInterakcji = true
        addEventHandler("onClientRender", root, gui)
        showCursor(true)
	end
    end
end

is wrong. It has to be...

bindKey("F2", "down", function()
        TrybInterakcji = not TrybInterakcji
        if (TrybInterakcji) then
            addEventHandler("onClientRender", root, gui)
        else
            removeEventHandler("onClientRender", root, gui)
        end
        showCursor(TrybInterakcji)
    end
);

 

Edited by The_GTA
Link to comment
3 minutes ago, NieZnanyUserOk said:

Now no errors, but when I click the F2 button, then I only see the cursor and the graphics do not appear.

Sorry, I made a spelling mistake because I am not a native Polish speaker. Look at the line...

        if (TrybInterackcji) then

... and change it to...

        if (TrybInterakcji) then

Good luck!

Edited by The_GTA
  • Like 1
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...