#Tables that synchronize over the network

1 messages · Page 1 of 1 (latest)

golden rampart
#

v2.1 release https://github.com/Be1zebub/Small-GLua-Things/blob/master/nwtable.lua
new features:
more access to storage with .storage, :set(k, v), :get(k), :delete(k), :clean()
manual sync :sync(ply) (works automatically when a new player joins) - you can disable it with :NoSync()

CLIENT -> SERVER -> CLIENT's now processed correctly by additional autosync argument of :Read(REALM, read, opts, autosync)
example:

local laws = NWTable("Laws")
:Write(net.WriteString) -- write value (shared)
:Read(net.ReadString, true) -- read value (shared), autosync to all players when server receive value from client
:Cooldown(5) -- with 5 seconds cooldown for clients
:WriteKey(net.WriteUInt, 3) -- read/write 3 bits uint index
:ReadKey(net.ReadUInt, 3)
:Validate(function(ply, index, value) -- customcheck
    return ply:IsMayor() and index > 0 and index < 8 and value:len() <= 512
end)

if CLIENT then
    laws[1] = "Dont be an idiot" -- update in local storage, send to server storage with 5 seconds cooldown, server will autosync it to all players
end
GitHub

A lot of helpful glua things. Libs, Snippets, Examples & More! This is just a klondike for gmod developers! - Small-GLua-Things/nwtable.lua at master · Be1zebub/Small-GLua-Things