Jump to content

[HELP] Text


Hugos

Recommended Posts

I created the field using guiCreateStaticImage, need to attach function onClientGUIClick to when the button is pressed (guiCreateStaticImage), it was possible to write the text which would be displayed on the screen (in the field). Perhaps with the help dxDrawText? Help me, please!

Link to comment
  • Moderators

Show us your code. If you still don't understand the basics of scripting I suggest you downloading a custom editbox resource instead of trying to make something that isn't within your reach.

Link to comment
function fedit()
	edit1 = guiCreateStaticImage(608, 544, 150, 40, "gfx/edit.png", false)
	addEventHandler("onClientGUIClick", edit1, fedit1, false)
end
addEventHandler("onClientResourceStart", getRootElement(), fedit)

function fedit (button)
    if button == "left" then
    
    end
end

User clicked "guiCreateStaticImage" >>> user typing text >>> displayed on top "guiCreateStaticImage".

P.S: edit.png - rectangle (input field)

Link to comment

What about guiCreateLabel to write a text? But then you need to fix the position of it

guiCreateLabel( x, y, width, height, text, relative, parent)

so you can write it without using a window:

guiCreateLabel( x, y, width, heigh, "The text you want to write here..", relative )  

Don't write a parent so it can be shown, if you want to remove it you can write

guiSetVisible( labelname, false) 

example:

local label
function fedit()
	edit1 = guiCreateStaticImage(608, 544, 150, 40, "gfx/edit.png", false)
	addEventHandler("onClientGUIClick", edit1, fedit1, false)
end
addEventHandler("onClientResourceStart", getRootElement(), fedit)

function fedit (button)
    if button == "left" then
        label = guiCreateLabel( 608, 544, 200, 30, "Text", false)
        guiSetVisible( label, true)
    end
end

function removeLabel()
    guiSetVisible( label, false)
end
--What ever you need to addEventHandler or addCommandHandler or call the function ' removeLabel() '

 

I suggest guiCreateLabel because dxDrawText needs onClientRender and the event handler onClientRender reduce players FPS...

Link to comment
5 hours ago, R.I.P Logic said:

What about guiCreateLabel to write a text? But then you need to fix the position of it

guiCreateLabel( x, y, width, height, text, relative, parent)

so you can write it without using a window:

guiCreateLabel( x, y, width, heigh, "The text you want to write here..", relative )  

Don't write a parent so it can be shown, if you want to remove it you can write

guiSetVisible( labelname, false) 

example:


local label
function fedit()
	edit1 = guiCreateStaticImage(608, 544, 150, 40, "gfx/edit.png", false)
	addEventHandler("onClientGUIClick", edit1, fedit1, false)
end
addEventHandler("onClientResourceStart", getRootElement(), fedit)

function fedit (button)
    if button == "left" then
        label = guiCreateLabel( 608, 544, 200, 30, "Text", false)
        guiSetVisible( label, true)
    end
end

function removeLabel()
    guiSetVisible( label, false)
end
--What ever you need to addEventHandler or addCommandHandler or call the function ' removeLabel() '

 

I suggest guiCreateLabel because dxDrawText needs onClientRender and the event handler onClientRender reduce players FPS...

function's name at line 4 dosen't match with the name at 8

 

Link to comment
9 hours ago, #x1AhMeD-09 said:

function's name at line 4 dosen't match with the name at 8

 

My bad

local label
function fedit()
	edit1 = guiCreateStaticImage(608, 544, 150, 40, "gfx/edit.png", false)
	addEventHandler("onClientGUIClick", edit1, fedit1, false)
end
addEventHandler("onClientResourceStart", getRootElement(), fedit)

function fedit1 (button)
    if button == "left" then
        label = guiCreateLabel( 608, 544, 200, 30, "Text", false)
        guiSetVisible( label, true)
    end
end

function removeLabel()
    guiSetVisible( label, false)
end
--What ever you need to addEventHandler or addCommandHandler or call the function ' removeLabel() '

 

Edited by R.I.P Logic
  • Like 1
Link to comment
7 hours ago, R.I.P Logic said:

My bad


local label
function fedit()
	edit1 = guiCreateStaticImage(608, 544, 150, 40, "gfx/edit.png", false)
	addEventHandler("onClientGUIClick", edit1, fedit1, false)
end
addEventHandler("onClientResourceStart", getRootElement(), fedit)

function fedit1 (button)
    if button == "left" then
        label = guiCreateLabel( 608, 544, 200, 30, "Text", false)
        guiSetVisible( label, true)
    end
end

function removeLabel()
    guiSetVisible( label, false)
end
--What ever you need to addEventHandler or addCommandHandler or call the function ' removeLabel() '

 

I don't need to print the text. Let's say this field is for login. The player clicks on the field and enters the login, it is displayed on top of the field.
 

There is a "onClientCharacter"function. Don't know how to do the whole text, not per character.
 

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