SlashCo Wiki

DTVar Networking

DTVar Networking

DTVars

DT = Datatable

A DTVar is a value that is networked using the Entity:SetDT function.
The Datatable offers great speed and reliability often networking values faster than net messages though at the cost of being limited and hard coded into the game build.
Garry's Mod offers 32 slots for Floats, Bools, Ints, Entities, Vectors and Angle but for strings only 4 slots are available.

Our DTVar System for Players

We got our own wrapper for creating DTVars with Set/Get functions as Garry's Mod default NetworkVar function sucks.

Inside the sh_player.lua we got the function SetupSlashCoNetworkVar(type, index, name) which we use to create our DTVars for players.
An example of this is this:

Example

SetupSlashCoNetworkVar("Int", 0, "Experience") SetupSlashCoNetworkVar("Int", 1, "Points") -- Now we got these functions created which have their values always networked Player:SetExperience(number value) local value = Player:GetExperience(number fallback = 0) Player:SetPoints(number value) local value = Player:GetPoints(number fallback = 0)