Jump to content

How to write text on screen?


Recommended Posts

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

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

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

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
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
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 :D

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...