Network
Network communication and data streaming system for the Lilia framework.
Overview
lia.net.isCacheHit(name, args)
Purpose
Determine if a net payload with given args is still fresh in cache.
When Called
Before sending large net payloads to avoid duplicate work.
Parameters
Returns
boolean true if cached entry exists within TTL.
Example Usage
if not lia.net.isCacheHit("bigSync", {ply:SteamID64()}) then
lia.net.writeBigTable(ply, "liaBigSync", payload)
lia.net.addToCache("bigSync", {ply:SteamID64()})
end
lia.net.addToCache(name, args)
lia.net.readBigTable(netStr, callback)
Purpose
Receive chunked JSON-compressed tables and reconstruct them.
When Called
To register a receiver for big table streams (both realms).
Parameters
string netStr Net message name carrying the chunks.
function callback Function called when table is fully received. Client: function(tbl), Server: function(ply, tbl).
Example Usage
lia.net.readBigTable("liaDoorDataBulk", function(tbl)
if not tbl then return end
for doorID, data in pairs(tbl) do
lia.doors.updateCachedData(doorID, data)
end
end)
lia.net.writeBigTable(targets, netStr, tbl, chunkSize)
Purpose
Send a large table by compressing and chunking it across the net.
When Called
For big payloads (dialog sync, door data, keybinds) that exceed net limits.
Parameters
Player|table targets optional Single player, list of players, or nil to broadcast to humans.
string netStr Net message name to use.
table tbl Data to serialize.
number chunkSize optional Optional override for chunk size.
Example Usage
local payload = {doors = lia.doors.stored, ts = os.time()}
lia.net.writeBigTable(player.GetHumans(), "liaDoorDataBulk", payload, 2048)
lia.net.addToCache("doorBulk", {payload.ts})
lia.net.checkBadType(name, object)
Purpose
Validate netvar payloads to prevent functions being networked.
When Called
Internally before setting globals/locals.
Parameters
Returns
boolean|nil true if bad type detected.
Example Usage
if lia.net.checkBadType("example", someTable) then return end
lia.net.setNetVar(key, value, receiver)
Purpose
Set a global netvar and broadcast it (or send to specific receiver).
When Called
Whenever shared state changes (config sync, feature flags, etc.).
Parameters
string key Netvar identifier.
any value Value to set.
Player|table receiver optional Optional target(s); broadcasts when nil.
Example Usage
lia.net.setNetVar("eventActive", true)
lia.net.setNetVar("roundNumber", round, targetPlayers)