Hugos Posted June 3, 2019 Share Posted June 3, 2019 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
DNL291 Posted June 4, 2019 Share Posted June 4, 2019 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
salh Posted June 4, 2019 Share Posted June 4, 2019 on click the guiCreateStaticImage show text? Link to comment
Hugos Posted June 4, 2019 Author Share Posted June 4, 2019 (edited) 7 hours ago, salh said: нажмите на guiCreateStaticImage показать текст? - Edited June 4, 2019 by Hugos Link to comment
Hugos Posted June 4, 2019 Author Share Posted June 4, 2019 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
WiBox Posted June 4, 2019 Share Posted June 4, 2019 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
SycroX Posted June 5, 2019 Share Posted June 5, 2019 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
Scripting Moderators thisdp Posted June 5, 2019 Scripting Moderators Share Posted June 5, 2019 Don't worry too much about the performance, everything drops fps. DGS is alternative. Based on dx. https://wiki.multitheftauto.com/wiki/Resource:Dgs Link to comment
WiBox Posted June 5, 2019 Share Posted June 5, 2019 (edited) 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 June 5, 2019 by R.I.P Logic 1 Link to comment
Hugos Posted June 5, 2019 Author Share Posted June 5, 2019 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
WiBox Posted June 6, 2019 Share Posted June 6, 2019 Okay use addEventHandler( "onClientGUIClick", label, function, false) at the function write the login event, when he press on the text, the event will get trigger for whatever you desire Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now