der_puma Posted August 11, 2008 Share Posted August 11, 2008 How to write text on screen and how to change font and size? Link to comment
haybail Posted August 11, 2008 Share Posted August 11, 2008 normally you do it through lua. although there may have been a resource that does it for you, I can't find it. the code will look similar to this: -- We create a dummy gui label to get text of local dummyGUIElement = guiCreateLabel ( 0.45, 0.48, 0.10, 0.04, "Hello world", true ) guiSetFont ( dummyGUIElement, "sa-gothic" ) -- Output the font of the label to chat box outputChatBox ( "Font used in the GUI label: " .. guiGetFont ( dummyGuiElement ) ) http://development.mtasa.com/index.php?title=GuiSetFont and the functions you would need to use are listed here: http://development.mtasa.com/index.php? ... ext_labels there is a tut avaliable if you've never used lua before: http://development.mtasa.com/index.php? ... troduction it can be a little hard to understand first time but with help you can get it. and your set ! Link to comment
der_puma Posted August 11, 2008 Author Share Posted August 11, 2008 Thanks for your reply. I know other programming languages, so lua isn't hard to understand for me, the only thing is i can't figure out is how to set font size. Any further help? -e- And other thing i don't understand is what those floating numbers mean when i set an objective to relative. Link to comment
haybail Posted August 11, 2008 Share Posted August 11, 2008 i think u use guiSetSize like in this example: -- create the window (the container for our label) local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Information", true ) -- create the label local myLabel = guiCreateLabel ( 10, 10, 0, 0, "This is my text container", false, myWindow ) -- get the (absolute) text extent and font height, and use these to size the label guiSetSize ( myLabel, guiLabelGetTextExtent ( myLabel ), guiLabelGetFontHeight ( myLabel ), false ) guiSetSize ( myLabel, 0.5, 0.4, true ) http://development.mtasa.com/index.php? ... TextExtent Link to comment
der_puma Posted August 11, 2008 Author Share Posted August 11, 2008 It's a bit harder than i thought. Can you add more expained example because i don't understand. Font size doesn't change when i use this code. Link to comment
haybail Posted August 11, 2008 Share Posted August 11, 2008 I didn't use it before but if I had a computer i'd try this: local myLabel = guiCreateLabel ( 0.1, 0.1, 0.8, 0.8, "This is my text container", true ) guiSetSize ( myLabel, 0.5, 0.4, true ) that would make the text height half the screen. does anything happen, can you see the text originally? Link to comment
der_puma Posted August 11, 2008 Author Share Posted August 11, 2008 I see text, it's on top of chat. But it has normal size (8pt or 12pt i don't know). Link to comment
haybail Posted August 11, 2008 Share Posted August 11, 2008 it must be resizing the label and not the front. like I thought it would originally but the example threw me off you might be able to only use these, unless u make an outside image similar to this: http://development.mtasa.com/index.php?title=GUI_Fonts https://community.multitheftauto.com/index.php?p= ... ils&id=187 sorry Link to comment
der_puma Posted August 11, 2008 Author Share Posted August 11, 2008 Im making speedometer script for my server, so the text on label is kinda dynamic. Can't use picture. -e- Is it possible to change numbers to images? It would be cool because you could use your own font. Link to comment
haybail Posted August 11, 2008 Share Posted August 11, 2008 mmm I don't understand what you mean. Link to comment
der_puma Posted August 11, 2008 Author Share Posted August 11, 2008 Like, when car speed is 58 for example. Then script explodes speed number and writes 5 and 8 to variables. Link to comment
Ace_Gambit Posted August 11, 2008 Share Posted August 11, 2008 Im making speedometer script for my server, so the text on label is kinda dynamic. Can't use picture.-e- Is it possible to change numbers to images? It would be cool because you could use your own font. There's no standard function that converts text into images. The fonts provided are the only ones you can use. I did a resource with custom text as images but it proved a big performance hog due to the extreme loading time. If you are interested in text as images have a look at this. https://community.multitheftauto.com/index.php?p= ... ils&id=126 Link to comment
haybail Posted August 11, 2008 Share Posted August 11, 2008 Like, when car speed is 58 for example. Then script explodes speed number and writes 5 and 8 to variables. huh? u mean exports speed number? u could have all the numbers previously as custom, 1 - 10. and the script can call those and display them on screen via the variables. that could work. There's no standard function that converts text into images. The fonts provided are the only ones you can use. I did a resource with custom text as images but it proved a big performance hog due to the extreme loading time. If you are interested in text as images have a look at this.https://community.multitheftauto.com/index.php?p= ... ils&id=126 but yea, no it can't do that as itself. nice script. how long did it take to make? looks really impressive. edit: I should say, 1 - 9 Link to comment
Recommended Posts