I wrote my own net manager for easy data exchange between the client and the server, including the generation of HMAC for verifying client data.
The module creates an object of the NetworkManager class, which creates and defines Remotes for the server and client
Server API:
Code
-- Create a new network for server/client replication ๐
-- Types: 1 - event, 2 - function, 3 - bindable, 4 - event + function
local MyNewNet = NetworkManager.new("MyNewNet", 4)
MyNewNet.Ratelimit = 2
-- Modes:
-- - Protected | add a secure code to remotes โ
(more bytes)
-- - Fast (Server) | make event unreliable ๐ (may cause loosing events)
MyNewNet:SetMode("Fast")
MyNewNet:SetMode("Protected")
MyNewNet:BindToEvent(function(Player: Player, ...)
MyNewNet:Fire(Player, `Hello, {Player.DisplayName}!`)
end, "SomeEvent")
MyNewNet:BindToFunction(function(Player: Player, ...)
return `Hello, {Player.DisplayName}!`
end)
-- MyNewNet:UnBindFromEvent("SomeEvent")
-- MyNewNet:UnBindFromFunction()
MyNewNet:Fire(Player1, ...)
MyNewNet:FireAll(...)
MyNewNet:FireClients({Player1, Player2, ...}, ...)
MyNewNet:FireClientsExcept(Player1, ...)
MyNewNet:FireClientsExcept({Player1, Player2, ...}, ...)
MyNewNet:FireClientsInRadius(25, Vector3.zero, ...)
Client API:
Code
local MyNewNet = NetworkManager.new("MyNewNet", 4)
MyNewNet:BindToEvent(function(...) print(...) end)
MyNewNet:Fire("Hello world!")
print(MyNewNet:Invoke("Hello world!"))
FILE NetworkManager.rbxm (40,0 ะะ)
NET NAME AND TYPE MUST BE SAME ON SERVER AND CLIENT!