Info on top of players heads and make text go smaller with the length of it.
Hey, I'm currently working on my own HUD, and since its my very first lua code and facepunch forums are closed, i cant learn anywhere. I was wondering how do I draw the players info above their heads? I went into the darkrp base hud, tried to paste it, make sure that I have the same varuables, but nothing seems to show up. Also, I've seen on some huds that if the text is too long, it shows some letters and dots. for exapmle : if my name is zorexd its gonna show ZorexD but if it will be long, like ZorexDDoesn'tKnowHowToCode it'll show ZorexDDoesn'tKnow...
any help will be appreciated.
As for shortening strings use this: http://wiki.garrysmod.com/page/string/sub
Example:
Edit: as for drawing a HUD above a player's head there is an example on this wiki page: http://wiki.garrysmod.com/page/GM/PostPlayerDraw
Hey, thanks for the help. But thats not what I meant. What I meant is that as long as the text gets longer , the smaller the text gets so it can fit more text in less room, and if its too much letters, the next letters doesnt show up, but it shows 3 dots. You can see it on a lot of huds nowadays.
Ok... well the code I showed you would do that partially, however for what you want I suggest to keep it simple you just create a couple of fonts and then for each font use an if statement to check if the same length is greater than a certain length, if so change the font used to display the name.
String length: http://wiki.garrysmod.com/page/string/len
Create font: http://wiki.garrysmod.com/page/surface/CreateFont
Edit: or instead of checking the length use http://wiki.garrysmod.com/page/surface/GetTextSize
postplayerdraw is called before translucent hooks so don't use that
Threebow since u made a hud, don't u have that thing that makes the text go smaller with its length?
I've literally just told you how you can go about doing it yourself?
yeah, i know that way, i just think theres a simpler way to do that
It's you who's asking for help - "I just think there's a simpler way" - How can you know that there's another way, or simpler one, when you don't know such a basic operation?
Brickwall gave you the absolute simplest way of implementing that, you get the size of the text, and you scale it based on how big it is, you can clamp the value to minimum/maximum size using math.Clamp so you don't scale text that doesn't need to be scaled.
Hey guys, thank you so much for all the help! I got both of the things to work. I appreciate all of the help and sorry for being annoying and stupid.