lua/lua/gmod_integration/client/cl_net.lua
2023-09-27 02:24:00 +02:00

32 lines
584 B
Lua

//
// Network
//
/*
Upload
0 - Say I'm ready
Receive
1 - Sync Chat
*/
// Send
function gmInte.SendNet(id, args, func)
net.Start("gmIntegration")
net.WriteUInt(id, 8)
net.WriteString(util.TableToJSON(args || {}))
if (func) then func() end
net.SendToServer()
end
// Receive
local netFunc = {
[1] = function(data)
gmInte.discordSyncChatPly(data)
end
}
net.Receive("gmIntegration", function()
local id = net.ReadUInt(8)
local args = util.JSONToTable(net.ReadString())
if (netFunc[id]) then netFunc[id](args) end
end)