• Why are NWVars considered bad?
    6 replies, posted
As the title says, why are networked variables (GetNWString etc) considered bad?
They aren't. Just make sure you don't SetNWString or any other networked variables too often. They can be costly to the CPU and network. The times where you wouldn't use SetNWString is if you need the client script to run code or know when the setting was placed. With those you should use umsg. With umsg the server can call functions on the client and send data that way. If you're wanting to send clients the amount of money a player has, SetNWInt or such would be good. They can glitch sometimes though. I remember having a problem where I wanted to display the driver's name on his car in races and in each race 12 cars would spawn and assign the names, but it just failed and didn't set the name probobly because it can't do 12 at a time or something? So I had to resort to umsg's.
Ok. I've just seen lots of people saying they were bad for things without giving any reasons, so I was wondering if there was a performance problem or something. And even with money, I might want to use usermessages - because the player might have the shop window open, in which case it needs to update itself.
One main issue with them is that they can cause Snapshot overflows if a player has too many of them updated at once. Say you paste a large contraption with 100 or so networked vars thanks to a bad prop protection, networked vars are PVS based so they update only when you can see them, they all update at once and overload something, causing the snapshot overflow.
Thanks, that's a much better reason (than "you can't call functions when they change")
They're very bad because they spam data when there's no need to send it.
Using NWVars are like smoking you can have one or two and you are not really going to start noticing but when you start having 20 a day or more your going to notice the slowdown
Sorry, you need to Log In to post a reply to this thread.