lua/lua/gmod_integration/client/cl_net.lua

32 lines
584 B
Lua
Raw Normal View History

2023-09-25 09:11:51 +00:00
//
// 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 || {}))
2023-09-25 09:38:49 +00:00
if (func) then func() end
2023-09-25 09:11:51 +00:00
net.SendToServer()
end
// Receive
local netFunc = {
2023-09-27 00:24:00 +00:00
[1] = function(data)
gmInte.discordSyncChatPly(data)
2023-09-25 09:11:51 +00:00
end
}
net.Receive("gmIntegration", function()
local id = net.ReadUInt(8)
local args = util.JSONToTable(net.ReadString())
2023-09-25 09:38:49 +00:00
if (netFunc[id]) then netFunc[id](args) end
2023-09-25 09:11:51 +00:00
end)