Are NWString's NWInt's and etc still as laggy as they were a long time ago?

Previous to gmod 13, having several NWString’s and NWInt’s could lag a server - are they still as unreliable? If so what makes them so unreliable?

For example how many NWStrings do you think I could have per player before it’d be a performance issue? Assuming there is 30 players on the server.

I am not sure how many but as of now I have a decent 5 to 10 players on my server with 3 NWInt’s. so far i haven’t got an issue but i do my best to avoid them.

I’m pretty sure it only becomes an issue if they get changed frequently, but in general I’ve seen said to avoid using player.SetNW* (and _G.SetGlobal*) whenever possible.

I have so many of them used at so many places. What should I use instead of SetNetworked*?

User messages and Network Library

I’m guessing the net library is the most efficient.

Can’t the net library be changed? Like sending a player variable to the client or even a variable at all, because it’s ran clientside, therefor it can be changed clientside?

If you know the data type of the variable, you can send it over net.
If you want to send a player, do net.WriteEntity(ply), because players are just glorified entities.
If you want to send any other data type, refer to the gmod wiki. It has a list of all the different things you can send.

Once you receive the object on the client, you can assign it to a variable. If you send a player variable from the server, assign it to a variable on the client in the net.Receive function.

I don’t know how else to explain it without you rephrasing your question because it seems a bit vague.
Maybe it’s the Ireland.

DTVars are most efficient for entities

I know how to use the net library. The thing is I need this data to be broadcasted.

Like shadow said, I thought it would only be a issue if they are updated frequently. The specific reason I need to use these is because I need the data available on all clients. For example a Name value on every player, i need to be able to get every players name on every single client( to render it on players etc. ).

I was planning on making my own system using the net library, but i figured it would be too much of a hastle to store all of the variables, broadcast them to players that JIP( join in progress ), and delete them on every client when the player is gone.

For something like that should I resort to DTVars? The annoyance with DTVars is they aren’t very dynamic and i can’t create them on the fly like i could a NWString or something. But for static fields like a players name, would they be more efficient?

[editline]23rd May 2013[/editline]

wait can you even use DTVars on the player? SetupDataTables was nil in the player meta table

[editline]23rd May 2013[/editline]

Yeah it can be changed clientside if sv_allowcslua is 1 or they are bypassing. That doesn’t matter though if you make all your shit right it should only matter if it’s changed on the server.

AFAIK the only good reasons to use the SetNW* functions are when all the clients need to know the information, because the info is already networked to everyone anyways.

Pretty much your system works good with SetNW* and there is really no need for using the net library.

-snip nvm-

Use them in moderation, try not to change them every tick if you can.
They can be quite useful for things if used correctly.

Basically, my own rules on the NW lib are…

  1. Don’t have a load of them
  2. Don’t have them change super often
  3. Don’t put massive values in them

I usually use them for things i need across server and client, usually the value for them being rooted in MySQL (Things like if they’re a donor or not)

Just use them in the right areas and they will function perfectly.

DTVars are available for players, but it’s recommended you don’t use them for stuff you’re going to publicly release because the indexes of the variables could conflict if you have more than one addon installed that uses Player DTVars.

ply:DTVar( … )
ply:DTVar( … )

Nevermind, you don’t know what I mean. And being in a specific country doesn’t signify your actions.

This was extremely useful, thank you. Like normal entities, are they also restricted to 4 DTVars per type?


[editline]23rd May 2013[/editline]

Infact I’ve just thought, but theoretically you should be able to use DTVars on non-scripted entities (i.e. props, etc) with that same method. I haven’t tried this but I don’t see why not.

I could create a bunch of fake entities and store them on the player hehehe

You say don’t have a load of them but if you use it for things like if donor or not and you have let’s say a deathrun/surf server with 60 players it wastes performance.
As far as I remember you should avoid them because they are always re-send and don’t cache the results.
Things like in your example should only be sent once when the player spawns for example donator or not especially since people don’t buy donator multiple times/change their donator rank multiple times in every game.
A good way to do such would be net.

wait what? are you sure GetNW* is performance heavy? I’d imagine it just updates it on the client when SetNW* is used on the server. Does it not do that?

GetNW* is not heavy but having networked vars itself is. That’s as far as I remember the main reason why everyone used to say avoid NW vars.