Network
SimpleAdmin uses a proprietary network module to handle all client/server communication. To increase efficiency, we made it so that it simulates using just a single remote event. While it appears like we're using a single event, it actually creates a new event with each key differentiation and is faster than using a single event. In the future, we plan to use a custom remote function implementation that is also faster and more flexible.
Primary Usage
BindEvent
-- <void> Network.BindEvent(<Table> self, <Table> data)
Network:BindEvent({
Test = function(plr, ...)
print(plr.Name .. " has fired a test!")
end
})
If this function is called on the server, it will bind an OnServerEvent
connection. In this example, we would call this event with Network:FireServer("Test")
.
BindFunction
-- <void> Network.BindFunction(<Table> self, <Table> data)
Network:BindFunction({
Test = function(plr, ...)
return "Hey there!"
end
})
If this function is called on the server, it will bind an OnClientInvoke
connection. In this example, we would call this event with Network:InvokeServer("Test")
.
FireServer
<void> Network.FireServer(<Table> self, <String> key, <Tuple> Args)
This will fire a RemoteEvent
with the specified key
and pass any extra arguments provided.
FireClient
<void> Network.FireClient(<Table> self, <Instance> plr, <String> key, <Tuple> Args)
This will fire a RemoteEvent
to plr
with the specified key
and pass any extra arguments provided.
InvokeServer
<variant> Network.InvokeServer(<Table> self, <String> key, <Tuple> Args)
This will invoke a RemoteFunction
with the specified key
and pass any extra arguments provided.
InvokeClient
<variant> Network.InvokeClient(<Table> self, <Instance> plr, <String> key, <Tuple> Args)
This will invoke a RemoteFunction
to plr
with the specified key
and pass any extra arguments provided.
Extras
FireAllClientsWithinDistance
<void> Network.FireAllClientsWithinDistance(<Table> self, <Instance> plr, <Int> distance, <String> key, <Tuple> args)
Calls Network.FireClient
on clients within distance
of plr
's character.
FireClients
<void> Network.FireClients(<Table> self, <Table> players, <String> key, <Tuple> args)
Calls Network.FireClient
on the clients specified in players
.
FireAllClients
<void> Network.FireAllClients(<Table> self, <String> key, <Tuple> args)
Calls Network.FireClient
on all clients in-game.
FireOtherClients
<void> Network.FireOtherClients(<Table> self, <Instance> plr, <String> key, <Tuple> args)
Calls Network.FireClient
on all clients except plr
.
Internals
CreateEvent
<Instance> Network.CreateEvent(<Table> self, <String> key)
Creates a RemoteEvent
with key
and adds it to the events directory. This function is called internally when you call an event that hasn't been created yet.
This function is used internally and should not be used in your scripts.
CreateFunction
<Instance> Network.CreateFunction(<Table> self, <String> key)
Creates a RemoteFunction
with key
and adds it to the functions directory. This function is called internally when you call a function that hasn't been created yet.
This function is used internally and should not be used in your scripts.
GetEvent
<Instance> Network.GetEvent(<Table> self, <String> key)
Retrieves the respective RemoteEvent
with corresponding key
. If the event is not present, CreateEvent
will be called and it's result will be returned.
This function is used internally and should not be used in your scripts.
GetFunction
<Instance> Network.GetFunction(<Table> self, <String> key)
Retrieves the respective RemoteFunction
with corresponding key
. If the function is not present, CreateFunction
will be called and it's result will be returned.
This function is used internally and should not be used in your scripts.
AwaitEvent
<Instance> Network.AwaitEvent(<Table> self, <String> RemoteName, <Function> Function)
Creates a ChildAdded
event and waits for RemoteName
to exist in it's respective directory. Once it's been added, an OnClientEvent
connection will be made with Function
.
This function is used internally and should not be used in your scripts.
AwaitFunction
<Instance> Network.AwaitFunction(<Table> self, <String> RemoteName, <Function> Function)
Creates a ChildAdded
event and waits for RemoteName
to exist in it's respective directory. Once it's been added, an OnClientInvoke
connection will be made with Function
.
This function is used internally and should not be used in your scripts.
Last updated
Was this helpful?