Jump to content

Question of show text


Hugos

Recommended Posts

You must set a variable with this function: The user enters the characters on the keyboard and they are shown with one line on the screen
How can this be done?
(A variable is a string of text)
 

Edited by Hugos
Link to comment
local text = ""

addEventHandler( "onClientCharacter", root, function ( character )
	text = text .. character
end )



addEventHandler("onClientRender", root,
    function()
        dxDrawText(text, 398, 71, 817, 192, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false)
    end
)

 

Link to comment
  • Moderators
18 hours ago, Hugos said:

Is it possible to delete the last character when clicking on "backspace"?
 

local text = ""

addEventHandler( "onClientCharacter", root, function ( character )
	if character == "backspace" then
		text = text:sub( 1, -2 )
	else
		text = text .. character
	end
end )

 

Link to comment
8 hours ago, salh said:

local text = ""

addEventHandler( "onClientCharacter", root, function ( character )
	text = text .. character
end )



addEventHandler("onClientRender", root,
    function()
        dxDrawText(text, 398, 71, 817, 192, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false)
    end
)

 

 Thank!

Edited by Hugos
Link to comment
34 minutes ago, DNL291 said:

local text = ""

addEventHandler( "onClientCharacter", root, function ( character )
	if character == "backspace" then
		text = text:sub( 1, -2 )
	else
		text = text .. character
	end
end )

 

I don't know why, but "backspace" doesn't work. (For example, if you change the character to y, q, d, f or s -  works)

Link to comment

use this:


id = guiCreateEdit(414, 226, 353, 90, "", false)
guiSetAlpha(id, 0.00)

addEventHandler("onClientRender", root,
    function()
        dxDrawRectangle(412, 223, 365, 98, tocolor(7, 39, 0, 121), false)
        dxDrawText(guiGetText(id), 411, 224, 777, 316, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false)
    end
)

 

Link to comment
40 minutes ago, salh said:

use this:



id = guiCreateEdit(414, 226, 353, 90, "", false)
guiSetAlpha(id, 0.00)

addEventHandler("onClientRender", root,
    function()
        dxDrawRectangle(412, 223, 365, 98, tocolor(7, 39, 0, 121), false)
        dxDrawText(guiGetText(id), 411, 224, 777, 316, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false)
    end
)

 

It not suitable)

Link to comment
  • Moderators
12 hours ago, Hugos said:

I don't know why, but "backspace" doesn't work. (For example, if you change the character to y, q, d, f or s -  works)

"backspace" only works for the "onClientKey" event, my bad.

In this case, add this event for the "backspace" key and it should work.

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