Right now in GMod the entity’s custom variables are networked using an internal usermessage system. When you join the server it sends you a bunch of usermessages containing all the entity’s variables, then after that it sends updates every time the entity changes. This isn’t ideal, but it was the best I could do at the time, since the default network code wasn’t able to handle the amount of variables we needed on some things.
But this presents a problem when dealing with prediction, because the new networked vars might arrive early, or late, and be processed by the wrong tick etc. So networked vars don’t work well for that stuff.
So in the next update I’ve added DTVars, Data Table Vars. The base entity in GMod has a 24 extra variables on it, networked. This is kind of icky, but it’s the best way to do it. There’s 4 of each type available – int, float, vector, angle, ehandle, bool. On the ground level there’s functions for each type to get and set these variables – ent:SetDTBool( int, value ) – ent:GetDTBool( int ).
Higher up, in SENTs, to make things easier, things work like this (this funtion gets automatically called at the right times (in initialize and onrestore))
function ENT:SetupDataTables()
self:DTVar( "Int", 0, "Key" );
self:DTVar( "Bool", 0, "On" );
self:DTVar( "Vector", 0, "vecTrack" );
self:DTVar( "Entity", 0, "entTrack" );
self:DTVar( "Entity", 1, "Player" );
end
Then you can access them via -
self.dt.Key
self.dt.On
self.dt.vecTrack
- just like they were normal variables – except they will be automatically syced between client and server.
I’m recommending that if you can fit all your SENT/SWEP’s data in this variables, then use them. They’re the best option for networked variables. String data, or other variables should use the old method.
Good job, this will be useful ;)
At the minute in time, I have no idea what current errors that will fix (need to check up)but I have a few errors I wish it would. And then there’s those that are source based like Reliable snap shot. But then there are really stupid ones like lua_table overflow and net_channel….
It won’t fix any problems until people start to use it. Once they do it should be a lot smoother.
Pretty neat
Very cool, definitely going to use this in an RTS for selection, and detecting which team the unit is on. Thanks Garry :)
Is it not possible to have 24 general purpose variables which are typed when an entity is initialized?
@ Garry kk
I missed buffer overflow in netmessage. XD
I can’t really think of any other errors that give any information as to what error occured, there just appear to be random crashes for no apparent reason.
Impressive, GJ GARRY!
So ent:GetDTBool(“TestDT”) returns the same as ent.dt.TestDT?
And do you have to use ent:SetDTBool(“TestDT”,true) or can you also do ent.dt.TestDT = true?
No GetDTBool doesn’t take a string, it takes an int. Same with SetDTBool.
What. xD The posts smells funny
What does all that mean?
I love sucking fat dicks.
@ 16: Cool things. Seriously, of all the people – you should know that. But really, it’s about DTVars and generally improving the network performace of SENTs and the like. Simple as pie.
Will this fix the very common “lag” you get when you walk on some frozen props?
when is this beta going to be expected
i mean update
Will SetupDataTables be called prior to Initialize? More simply, can I assign values in the dt table in Initialize?
Also, how many bytes is the Int type?
4
Can we use these new systems for the player entities?
Like ply:DTVar(“Bool”, 1, “cloaking”)?
Yes
sorry to bother you Garry but i was just wondering if you could add support for the “+mat_queue_mode 2″ startup option. this is used for people who have more than one core on their computer. i dont know if this is already supported but it wont work on my quad core computer. hope you can help out thx anyway
Good job on the DTVar’s.
Garry,
will you be migrating all the networkvar work to this new system and deprecating luastringstable (eventually) or will Gmod remain a hybrid of luastrings and DTvars?
It’s got to remain a hybrid I think, there’s no way around it.
What about an engine update? is this luastringstable issue a basic source problem that will never be resolved (visible in other games too), or is it simply with the revision that gmod is on now? I dont ever recall seeing this error on Gmod 10, but mods were in their infancy back then so they weren't using as much lua as now.