New NWVars?

What changed with the new NWVars?

what do i replace the old ones with?

does this cause crashing and invisible view models?

Thanks :relaxed:

They’re perfectly fine if you use them as intended.

Nothing changed for Lua devs except for the limit, which is now a global 4096 ( global means you can have 4096 different NWVar keys across all entities ).

Make sure to use proper functions for proper types, ie SetNWInt for integers ( 1, 2, 3, etc ), SetNWFloat for floating point values ( 0.25, 1.45, etc ), SetNWBool for booleans ( true, false ) and SetNWString for strings ( “hi”, “bye”, etc )

Whats still causing all these servers to crash? Did anything change other then NWVars that could be messing with servers? Is another update needed or if it on the server owner’s end?

It is a problem with the game and you’ll need to wait for an update that fixes these crashes.

I’ve been getting these random crashes too (over 155 times since the update) and also assumed they had something to do with the new NWVars. It’s just an issue with gmod though?
Wow, that’s actually kind of relieving because I had no idea how to fix it or if I even could. Still this is the first thread I’ve seen talking about the update causing the crashes. Is there another thread that talks about the issue?

Next update v2 ik developer discussion

So, you’re saying I should also ease up if the server has been crashing randomly since the last update whenever I spawn a new entity? I’m using a script that gives each entity its own NWVar.

It’s a prop protection script. I’m giving each entity a networked string:


NewEntity:SetNWString("string identifier", "string goes here")

I need them networked to properly give the client a notification he’s using an entity that doesn’t belong to him. Is this a wrong use of NWVars? What happens after I spawn over 4096 entities? What should I do differently if at all?

If I understood you correctly you set the NWString to send a notification? If thats the case you should switch to the net library for messages instead.

A rather more practical use for SetNWString would be a name for the entity as an example and not really messages.

No, sorry, was being unclear. It’s a matter of client predictions. Didn’t want the tool tracer to show clientside for a player trying to tool an entity that’s not his, so the ‘ownership’ value had to be networked, that’s all.

Ok so why do you use strings instead of entities? If im not wrong sending an entity means it would internally send the id of it which is probably less traffic and easier to handle also.

Ugh I am not sure. I wanted every entity to have an ‘owner ID’ string, so I don’t know where I should be sending an entity.

You can try and replace all of the NWVar functions with custom functions.
I have done this and our server hasn’t crashed since then (26 hours so far)
Here’s the script: http://puu.sh/gJtP6/c60cc1306e.txt
Just put it in your server’s lua/autorun folder and you should be fine.
(There are a few glitches with it sometimes but it’s better than the server crashing every 5 minutes)

Thanks, but given that facepunch are aware of the issue and said they’ll fix, I’d rather not mess with it. My server/gamemode/whatever is still in development so there’s really no rush. I was just wondering what the 4096 global limit meant and what was causing the crashes in the first place.

It looks like the limit is just because the names of each var are stored in a stringtable. That’d mean that the 4096 limit is a limit of how many different names you can use for nwvars, not how many different nwvars you can have.
It has the same reasoning as the CSLua file limit and has the benefit of updates of nwvars being networked with an integer index rather than a string index.

Thanks for releasing this! I’ll test it as soon as I can. That being said, the code for this looks like it’s meant to run shared considering you AddCSLua’d it. Did you mean lua/autorun?

Yeah that is what I mean, thanks for pointing that out :smile:

Hey, I haven’t crashed while using this! BUT, it messes up custom checks. I am not able to purchase donator stuff, even when i’m in the donator group.

You can try this version as well http://puu.sh/gJtP6/c60cc1306e.txt.
It just added SetNetworked* and GetNetworked* as well since some scripts are apparently still using that.
If that doesn’t solve the issue feel free to add me on steam so we can fix the problem.
There are also a few glitches regarding entities that are out of the PVS of the player but I might fix that tomorrow.