Open PlatinMTA opened 3 years ago
It could come in handy for people that only want to change the distance of a nametag, to have a function in where they can change it without needing to create a nametag manager themselves.
Maybe we should try to get rid of the most common reasons for someone to consider using a custom nametags system (because as you said, it'll always be taxing on client peformance) and the first other thing i can think of in this context is: colorcode support.
If you want, create another issue about native support for colorcode in nicks, because next to rendering distance it's the Top 2 of reasons to sacrifise performance (as you can see, a close reproduction of nametags in Lua that only adds colorcode support, already takes a significant toll) or else i will do that soon
I wonder why fundamentally color coded text eats so much processing power. Can this be patched? Seems like a trivial task for a computer in 2021.
Look at how it's implemented. A color-coded text is broken down into multiple smaller texts. Also, because of sub-par implementation, theres lot of allocations as well (while there shouldn't be any, obviously). A way to solve this would be to break up the string as necessary, and put it into a hash table, with a limited number of entries.
A side note but could be included in the fix for this
Nametags should use IsLineOfSightClear
(and CWorldSA::IgnoreEntity
on the player vehicle) instead of ProcessLineOfSight
, should be faster
Is your feature request related to a problem? Please describe. Right now there is not a way to change the default distance of a nametag. If you want your nametags to be seen from closer (or further) you need to create your own resource for managing nametags.
This is not a big issue on it's own, until you start considering that rendering nametags on lua, specially fancy ones, can be quite performance heavy. dxDraw calls are kinda slow, and when you have +15 players on the screen it can start to go bad if you need a lot of information or if you didn't optimize your script enough.
It could come in handy for people that only want to change the distance of a nametag, to have a function in where they can change it without needing to create a nametag manager themselves.
The default nametags do also change they minimum requiered distance for rendering depending on a few factors. For example, if you are using an scope, they would render from further away.
setPlayerNametagDistanceFixed()
could negate this effect and only render nametags if they are closer than the distance defined.Describe the solution you'd like Add a function that can change the distance for seeing the nametag. By default it is 45.0f.
Describe alternatives you've considered There are none, unless you consider scripting a nametag resource as an alternative.