JC-MP

Scripting => Releases => Topic started by: DaAlpha on December 21, 2015, 08:54:59 pm

Title: [Release] Basic Nametags
Post by: DaAlpha on December 21, 2015, 08:54:59 pm
Basic Nametags

Description
This module adds nametags above other players' heads. It also adds minimap markers for other players both nearby and across the entire map. A player can chose to only be shown to nearby players on the minimap in exchange for only being able to see other players when they are nearby.

Usage
The nametags and minimap blips will automatically be displayed. Type /minimap into the chat to opt out from other players being able to see your minimap blip on the global map and yourself being able to see global minimap blips of other players.

Pictures
At medium distance
(https://alphie.de/temp/jc2mp-nametags-medium-distance.png)

Different health bar colors at different health levels
(https://alphie.de/temp/jc2mp-nametags-health1.png)(https://alphie.de/temp/jc2mp-nametags-health2.png)(https://alphie.de/temp/jc2mp-nametags-health3.png)

Minimap blip
(https://alphie.de/temp/jc2mp-nametags-minimap.png)

Minimum healthbar width cap
(https://alphie.de/temp/jc2mp-nametags-turret.png)

Administrator Notes

GitHub Download (https://github.com/DaAlpha/BasicNametags)
Title: Re: [Release] Basic Nametags
Post by: Darwood37 on December 21, 2015, 11:31:43 pm
I actually find Philpax nametag script to be very effective. It is not really that complicated. It has a lot of functions because it takes the work away from the Render function and does not calculate everything in the iteration. You will see the difference if you have a lot of players on your server.
Title: Re: [Release] Basic Nametags
Post by: DaAlpha on December 22, 2015, 12:30:02 am
Well yeah, instead of one iteration it iterates over the players to put them into a table, then iterates over that table several times to sort it and then iterates over it to draw every player, each iteration dragging across up to 5 function calls in a row. I do not really see how that actually improves anything, especially the performance. I mean you do know that when calling a function from another one, the initial function only continues once the other function has been fully executed, right? Otherwise it would be outside of the Render event so that you could not draw anything using Render functions.

Also, the difference to what exactly? What other nametag script are you comparing it to?
Title: Re: [Release] Basic Nametags
Post by: Gaveroid on December 22, 2015, 01:23:34 am
Also, the difference to what exactly? What other nametag script are you comparing it to?

I actually find Philpax nametag script to be very effective.
Title: Re: [Release] Basic Nametags
Post by: Darwood37 on December 22, 2015, 01:23:56 am
It only iterates twice, in the render function. How many nametags scripts has Philpax wrote ;D
Title: Re: [Release] Basic Nametags
Post by: DaAlpha on December 22, 2015, 01:28:07 am
I meant what to compare Philpax' script with. Because you could not have been able to reliably tell a difference to mine in this short amount of time.

Also: You do know that, when sorting after distance, the script has to iterate over the table, right?
Title: Re: [Release] Basic Nametags
Post by: Darwood37 on December 22, 2015, 11:34:24 am
I meant what to compare Philpax' script with. Because you could not have been able to reliably tell a difference to mine in this short amount of time.

Why not?

If your script works for you and does what you want, great. I just disagree on your comment about Philpax name script being complicated, that is all.
Title: Re: [Release] Basic Nametags
Post by: DaAlpha on December 22, 2015, 01:11:34 pm
Because within those few hours between the release of my script and your reply, you could not have ran valid comparison tests between the two scripts, especially at higher player counts. I am just making sure there are no unproven assumptions about the performance of my script around.

Also, I just disagree with the reasons why you disagree on my comment and making comparisons without any evidence. That is all.
Title: Re: [Release] Basic Nametags
Post by: SinisterRectus on December 22, 2015, 02:54:25 pm
Why do you draw the mini-map position of every non-streamed player?
Title: Re: [Release] Basic Nametags
Post by: DaAlpha on December 22, 2015, 02:56:18 pm
Why wouldn't I?
Title: Re: [Release] Basic Nametags
Post by: SinisterRectus on December 22, 2015, 03:05:59 pm
You're advertising better efficiency, and strongly defending it, yet you're using network traffic to draw theoretically dozens to hundreds of dots that are not always useful.
Title: Re: [Release] Basic Nametags
Post by: DaAlpha on December 22, 2015, 03:36:03 pm
Following that argumentation, I should also leave out healthbars because they are additional operations that are not always useful. Or fading. Or scaling. Or shadowing. I think you get my point.

Efficiency is not nessecarily about cutting features, it is about achieving its goal as efficient as possible. In my opinion, global minimap blips have become a standard for freeroam servers (to which this script is mainly addressed) and unless a server is running on a DSL connection (although even that works up to decent player counts), they are no issue whatsoever.

You could also code an entire faction script efficiently. The script itself would most likely have a noticeable performance impact on both server and client side but the point is that it could be way worse due to inefficient coding that achieves the same or a very similar goal.
Title: Re: [Release] Basic Nametags
Post by: LordNoob on December 22, 2015, 04:01:21 pm
You should at least create a toggle for global blips. I know it's something that I'd probably disable.

Why? Even if we're talking about a freeroam server, in fact especially if we are, people aren't going to travel across the map to an unstreamed player to kill them.
Title: Re: [Release] Basic Nametags
Post by: DaAlpha on December 22, 2015, 04:43:20 pm
Fair enough, done. /minimap now disables non-streamed blips for the player and disables the player's blip for others.
Title: Re: [Release] Basic Nametags
Post by: SinisterRectus on December 22, 2015, 06:18:32 pm
Very nice then.
Title: Re: [Release] Basic Nametags
Post by: JasonMRC on December 22, 2015, 08:43:35 pm
Just want to chime in on the topic of 'those useless unstreamed player dots'.

Players regularly come onto servers and ask, "Where is everyone?" The dots of unstreamed players allow them to see what direction to go or where to teleport towards to find players.

Why? Even if we're talking about a freeroam server, in fact especially if we are, people aren't going to travel across the map to an unstreamed player to kill them.
You'd be surprised.

Good explanation of efficiency, DaAlpha.

A consideration: Rather than network sending the positions in a table which must then be received, have you considered simply setting a network player value of "Position"? Then iterate through all Client:GetPlayers(). If IsValid(player, true) then they are streamed and operate as such, else use GetValue("Position") as their position(be sure to check that the value isn't nil because those who first join the server would have a nil value until the server sets it). You also would not need to sync their color this way as player color is one of the variables that is always accurate on players, even unstreamed ones.

I sync player positions and I've found this to be a wonderful benefit. I can accurately get any player's position from any script on any side of the network. Positions are updated every ~5 seconds, depending on server load.

In Client autorun I put this:
Code: [Select]
local oldPlayerGetPos = Player.GetPosition
Player.GetPosition = function(self)
if IsValid(self, true) then
return oldPlayerGetPos(self)
else
return self:GetValue("Position") or oldPlayerGetPos(self)
end
end
It replaces the original GetPosition with a check for streamed. If streamed, used the old function. If not streamed use the synced data or return the old function if the value hasn't been set yet.
Title: Re: [Release] Basic Nametags
Post by: SinisterRectus on December 22, 2015, 09:08:46 pm
I never said the non-streamed dots were useless. This is advertised as a less complicated version of the original Nametags script, but they are not in the original Nametags script, so I asked why. It's a fine feature and DaAlpha did a nice job, but I don't think it's fair to say this is less complicated. I think that's a matter of opinion.
Title: Re: [Release] Basic Nametags
Post by: LordNoob on December 22, 2015, 09:55:40 pm
Fair enough, done. /minimap now disables non-streamed blips for the player and disables the player's blip for others.

Good compromise. It could also be helpful for people to not have so much clutter on their minimap, especially if they're planning an event around an area.
Title: Re: [Release] Basic Nametags
Post by: Darwood37 on December 22, 2015, 10:49:41 pm
Because within those few hours between the release of my script and your reply, you could not have ran valid comparison tests between the two scripts, especially at higher player counts. I am just making sure there are no unproven assumptions about the performance of my script around.

Also, I just disagree with the reasons why you disagree on my comment and making comparisons without any evidence. That is all.

I can just look at the script and see what it does, any person who knows lua and jcmp can very quickly see how it is going to perform.

Comparisons without any evidence, yeah right!
Title: Re: [Release] Basic Nametags
Post by: Gaveroid on December 22, 2015, 11:04:08 pm
I never said the non-streamed dots were useless. This is advertised as a less complicated version of the original Nametags script, but they are not in the original Nametags script, so I asked why. It's a fine feature and DaAlpha did a nice job, but I don't think it's fair to say this is less complicated. I think that's a matter of opinion.

Am I the only one that felt there was no need for another nametag script? I mean there's many more things that DaAlpha could be practicing his skills on, literally zero people have voiced any real issues with that script.

Plus, Philpax's script is as simple as can be, there's no way to simplify it. There's no fluff, it's just a nametag and health bar. It's minimalistic, it looks good, performs well... now that DaAlpha is adding all of these features it's not really a simpler version now is it?

DaAlpha, I can perfectly see if your point is to make a more feature-filled script, like maybe with some profile pictures and maybe a bigger health bar with numbers or really anything like that, but you aren't doing a good job of simplifying the original script as A. you're making it more complicated in the end and B. there is zero simplifying to do as it's already extremely basic (not that basic is a bad thing).

(http://2.bp.blogspot.com/_j-KSLLZC6fs/TOwwhyCdy9I/AAAAAAAAFpA/YtQWpdbex9U/s1600/facepalm_picard_riker.jpg)
Title: Re: [Release] Basic Nametags
Post by: Darwood37 on December 22, 2015, 11:09:16 pm
I never said the non-streamed dots were useless. This is advertised as a less complicated version of the original Nametags script, but they are not in the original Nametags script, so I asked why. It's a fine feature and DaAlpha did a nice job, but I don't think it's fair to say this is less complicated. I think that's a matter of opinion.

Bing!!!!!!
Title: Re: [Release] Basic Nametags
Post by: DaAlpha on December 22, 2015, 11:46:24 pm
@Jason

I like that idea of syncing via player values. Did you notice a network load/performance change when switching to this method? Because considering it is not one table being sent and instead n amount of player network values being set in rapid succession, I could imagine the network overhead increasing there. Of course, the additional functionality of that method would make up for it.

Also, I am a huge fan of that workaround for overwriting API functions by caching the original one, I already found an application for it on the server. I would leave it up to the server owners/coders themselves to implement that however since it does not really offer anything for servers that do not customize their scripts or write own ones.


@Sinister

In case this was not quite clear: this script is not meant as a clean version of Philpax' script. Otherwise there would not be such a big difference in features, considering his script also has vehicle tags and a setting GUI. Instead, my script is intended to be a competitor due to his monopoly when it comes to released nametag scripts.


@LordNoob

What exactly do you have in mind there? If you mean something like anti-overlapping, this would imo not be worth the extra resources.

It would need an algorithm that, whenever a dot is drawn, would have to check if there is enough distance to all previously in this frame drawn dots (square distance would work here). This would have a decent performance impact the higher the amount of players to draw gets. Plus, if there needed to be a system behind it so that it does not just skip random dots and instead prefers the ones closer to the player over the ones further away, it would also need to sort the non-streamed dots by distance as well, meaning even more distance calculation (although square 2D distance would be sufficient here as well).

So yeah, what I am saying is that I also had that idea before but found that the additional resources needed are out of proportion compared to the additional value that not many would even notice, I could imagine.


@Darwood

Well, obviously you can't see how it is going to perform, considering you have yet to give me any logical reason or actual evidence for your assumption.


@Gaveroid

Quite frankly, if you do not have anything to contribute asides from repeating what has already been said and brainless bashing, go mind your own business outside of this thread. Much appreciated.
Title: Re: [Release] Basic Nametags
Post by: Gaveroid on December 23, 2015, 12:39:26 am
Well somebody's butthurt. It's Christmas, just giving you some much needed feedback as it is the season of generosity. ;)

Do you guys there at Nologran have some kind of rule where all Gaveroid.com staff etc. must be abused in any social scenario? Every time any of us come in contact with one of you guys, we have the Fourth Reich abusing us in the end. No wonder your server has such a bad reputation.
Title: Re: [Release] Basic Nametags
Post by: JasonMRC on December 23, 2015, 12:42:24 am
Hey, hey, hey!
There's no need for bashing, everyone. We don't rate scripts based on if they are needed or how good they are. If we did, many of the scripts in this forum would be deleted because all of us here know they are not super good/really needed etc. That doesn't and should not stop someone from releasing something. Many of these scripts are just a few functions together or a slightly modified version of another release. We don't go debating the validity of those releases, do we?

By definition, this is a Basic Nametags script. It has basically coded player names, HP bar, and minimap dots. Philpax's also supports vehicles and does so with more functions(i.e., not as basic as this one. Can these features be done differently? Yes. Do servers do them differently? Yes. I'd guess most advanced/developed servers have their own tags/HP bars/minimap dots, etc, I know mine does. That doesn't invalidate DaAlpha's script.

For those learning LUA this is another teaching resource. It shows another way of producing roughly the same results as Philpax's script. I think we can all admit we've looked at other scripts to see how something is done at least once in our scripting careers.

So let's get back to the pertinent discussion at hand. Discuss features, bugs, etc. But don't bash or debate the validity of a script.

@Jason
I like that idea of syncing via player values. Did you notice a network load/performance change when switching to this method? Because considering it is not one table being sent and instead n amount of player network values being set in rapid succession, I could imagine the network overhead increasing there. Of course, the additional functionality of that method would make up for it.

Also, I am a huge fan of that workaround for overwriting API functions by caching the original one, I already found an application for it on the server. I would leave it up to the server owners/coders themselves to implement that however since it does not really offer anything for servers that do not customize their scripts or write own ones.
No, no noticeable network load. Of course I first added that function over a year ago.  ::) I've modified it recently to only update if values are different(it handles more than just positions, it syncs most of the commonly needed but natively unsynced values). There would have to be a few hundred players online for there to even be the chance of a performance issue(unless you have low bandwidth or extremely intensive scripts). The biggest thing when using NetworkValues is to check if it's changed and only set the new value if it's different.
Title: Re: [Release] Basic Nametags
Post by: Darwood37 on December 23, 2015, 12:58:48 am
Well, obviously you can't see how it is going to perform, considering you have yet to give me any logical reason or actual evidence for your assumption.

That is funny because i never assumed anything. All i did was offer some constructive criticism and comparisons. Not sure who's messages you were reading.

(https://m.popkey.co/045852/LqKvv_s-200x150.gif)
Title: Re: [Release] Basic Nametags
Post by: DaAlpha on December 23, 2015, 01:27:06 am
@Jason

Yup, definately seems like something to implement in this script. Will probably do that when I am back on Friday/Saturday.

One thing I am wondering about though is whether or not the check for a changed value actually works in this case, at least when comparing both Vector3s directly. As you have probably also experienced, even when standing completely still, the player's coordinates vary in the millimeter/micrometer range. If the comparison of two Vector3s considers changes this minor, which is what I think, then one would need to math.floor the coordinates and compare them manually.

I will probably also run a quick test there once I am back since I am quite curious now.
Title: Re: [Release] Basic Nametags
Post by: Philpax on December 23, 2015, 01:33:26 am
Hey now, I'd suggest we all relax; we're all friends here.

I'm happy about the existence of this script; the original nametags script has a fair bit of cruft that I never got around to removing (it was originally meant to handle a few other scenarios), so seeing someone produce a simpler, more elegant version pleases me.

I haven't tried out the script yet, but if it lives up to its name there's no reason to be concerned over it. Nice work!

EDIT: I just looked at the code. I approve of its simplicity; it does what it needs to do, and it does it well - nicely done! What you might want to do is update self.positions on the client with the streamed positions in the first loop - that way, you can render all of the blips in one go.
Title: Re: [Release] Basic Nametags
Post by: Darwood37 on December 23, 2015, 02:28:40 am
Hey now, I'd suggest we all relax; we're all friends here.

Sorry to spam this thread Philpax but I have to say this. We are not all friends and never will be. I am referring to DaAlpha and staff of NG and the Members and staff of Gaveroid's server. Speaking on behalf of Gaveroid's we have received nothing but verbal abuse, disrespect and a lack of community from the staff and owner of NG server. As you can tell by this thread. I try to be respectful and offer constructive criticism but in return i get accusations. I will never forgive them for the way they treated our staff members and how the owner of NG refused to acknowledge or deal with the situation. The community needs to know how they mistreat, abuse and have no respect for anyone but themselves. Until now i have kept this away from the JCMP forums, but when i get flak for no apparent reason I will retaliate.
Title: Re: [Release] Basic Nametags
Post by: keeri on December 23, 2015, 12:14:23 pm
The code seems fine to me, but the initial post could use some screenshots so people know how it looks, without having to install.
Title: Re: [Release] Basic Nametags
Post by: Philpax on December 23, 2015, 12:22:22 pm
Hey now, I'd suggest we all relax; we're all friends here.

Sorry to spam this thread Philpax but I have to say this. We are not all friends and never will be. I am referring to DaAlpha and staff of NG and the Members and staff of Gaveroid's server. Speaking on behalf of Gaveroid's we have received nothing but verbal abuse, disrespect and a lack of community from the staff and owner of NG server. As you can tell by this thread. I try to be respectful and offer constructive criticism but in return i get accusations. I will never forgive them for the way they treated our staff members and how the owner of NG refused to acknowledge or deal with the situation. The community needs to know how they mistreat, abuse and have no respect for anyone but themselves. Until now i have kept this away from the JCMP forums, but when i get flak for no apparent reason I will retaliate.

I'm sorry to hear about that; however, your later posts, as well as Gaveroid's post, served to inflame the conversation. I understand that the two communities involved here have an ongoing dispute, but this is not the place to bring it up.

I am respectfully requesting all parties remain civil within this thread; there is little to be gained by public confrontation in a thread about a script. Please keep it on-topic, or we will be forced to start punishing users, regardless of their affiliation, for instigating conflict.
Title: Re: [Release] Basic Nametags
Post by: adam1305_ on December 28, 2015, 12:42:34 pm
I have this script on my server, but I'm editing it so it uses GameRender for the tags and PostRender for the blips. The tags don't seem to be visible unless you are looking from underneath the player. If you understand what I just said, do you know a way around this?
Title: Re: [Release] Basic Nametags
Post by: DaAlpha on December 28, 2015, 03:01:53 pm
I am quite sure this is due to the behavior of GameRender in combination with 2D rendering. It seems to put 2D rendering behind literally anything but the horizon in the 3D world. GameRender was intended to be used with 3D rendering so you would have to code/modify a nametags script that draws in 3D in order to make this work.

However from my experience, this would not be worth it because you would have to use a Transform3 for every player on the screen in order to get the rotation of the nametag right. What I have experienced though is that Transform3s tend to be quite resource demanding when used in big amounts, so if you are in an area with lots of people, you would get decent framedrops.
Title: Re: [Release] Basic Nametags
Post by: adam1305_ on December 28, 2015, 09:28:24 pm
I am quite sure this is due to the behavior of GameRender in combination with 2D rendering. It seems to put 2D rendering behind literally anything but the horizon in the 3D world. GameRender was intended to be used with 3D rendering so you would have to code/modify a nametags script that draws in 3D in order to make this work.

However from my experience, this would not be worth it because you would have to use a Transform3 for every player on the screen in order to get the rotation of the nametag right. What I have experienced though is that Transform3s tend to be quite resource demanding when used in big amounts, so if you are in an area with lots of people, you would get decent framedrops.

Oh right. I guess I'll just leave it if its intensive. Thanks anyway, DaAlpha :)

-ThePanda
Title: Re: [Release] Basic Nametags
Post by: DaAlpha on December 31, 2015, 02:13:15 am
I just pushed the latest update to GitHub. Basically, I just switched from broadcasting a table to setting the position as network value.

I also did a photo shooting session with a friend to get a few screenshots in here (thanks to Fkids for the suggestion).

@Philpax

Thanks for the suggestion to put the minimap blip rendering all into one loop but I left it separated for now because I find it quite important to have blips for streamed players even if the global blips are disabled. This would have made this minimap draw merging more complicated than it should have been in the end so I just stuck with the way it was before.