-
-
Notifications
You must be signed in to change notification settings - Fork 178
Tables: server.Remote
Remote handles all remote server-client communication.
This is a table containing functions that can be called via client.Remote.Get and will return something to the calling client.
This is a table containing functions that can be used by clients without needing encryption/various security checks. This contains functions mostly related to initial loading before keys are exchanged, or communication with non-adonis-client localscripts, as well as very basic rapid fire events like chat handling.
These are functions which can be ran by clients via client.Remote.Send They cannot return data and are purely "fire and forget."
Creates and returns a new session handler that can be used to facilitate temporary communication between the server and multiple users with special commands/event defined.
Clients can listen for session events as needed via service.Events.SessionData
Here's an example of NewSession in action in the form of a, at the time of writing this, work in process private chat command & GUI:
Server code:
local newSession = Remote.NewSession("PrivateChat");
local eventConnection = newSession.SessionEvent.Event:Connect(function(p, ...)
local args = {...};
local cmd = args[1];
if cmd == "SendMessage" then
if newSession.Users[p] then
table.insert(newSession.Users[p].Messages, args[2]);
end
newSession.SendToUsers("PlayerSentMessage", p, args[2]);
elseif cmd == "LeaveSession" then
newSession.Users[p] = nil;
newSession.SendToUsers("PlayerLeftSession", p);
elseif cmd == "EndSession" and p == plr then
newSession.End();
end
end)
for i,v in ipairs(service.GetPlayers(plr, args[1])) do
newSession.AddUser(v, {
Messages = {};
});
Remote.MakeGui(v, "PrivateChat", {
Owner = plr;
SessionKey = newSession.SessionKey;
})
-- testing stuff below
wait(2)
newSession.SendToUsers("PlayerSentMessage", plr, "this is a test message");
end
Client Code:
local sessionEvent = service.Events.SessionData:Connect(function(sessionKey, cmd, ...)
local vargs = {...};
print("we got session thing!");
if SessionKey == sessionKey then
print("SESSION KEY VALID")
if cmd == "PlayerSentChat" then
local p = vargs[1];
local message = vargs[2];
print("got chat: ".. p.Name, "Message: ".. message)
end
end
end)
Gets the session belonging to 'SessionKey'
(Raw fire) Sends data to the client belonging to 'Player' with any arguments passed. Does not handle command encryption before sending. This should not be used for normal server-client communication.
(Raw fire) Functionally similar to Remote.Fire except it uses the RemoteFunction and is thus able to return data from the client. This should not be used for normal server-client communication.
Encrypts 'Command' and sends it with 'Arguments' to client of 'Player' This should be used for normal communication.
Encrypts 'Command' and sends it with 'Arguments' to client of 'Player' Functionally similar to Remote.Send except it uses the RemoteFunction and is thus able to return data from the client. This should be used for normal communication.
Checks if the 'Player's client is hooked and ready for communication.
Runs Remote.Get(Player, "Ping") and returns the result.
Tells 'Player's client to create the specified GUI with the specified data provided.
Identical to Remote.MakeGui except this will yield and return any data returned by the GUI created. This is used in conjunction with UI elements like the YesNoPrompt.
Alternative method of calling Remote.MakeGuiGet
Removes the specified UI element belonging to 'GuiName' from 'Player'
Creates a new particle of 'Type' in 'Parent' locally for 'Player'
Removes particle from 'Parent' for 'Player'
Creates a new particle locally for 'Player' of 'ClassName' with 'Properties' in 'Parent'
Makes 'Object' local to 'Player'
Moves local object to new parent for 'Player'
Removes local from 'Player' in 'Parent' matching 'Object' or 'Match'
Sets game.Lighting[Property] to 'Value' for 'Player'
Triggers client event on 'Player' with 'Arguments'
Creates a new player event and can be triggered by the client.
Plays audio locally on 'Player'
Stops current playing local audio on 'Player'
Stops all playing audio (locally created by Adonis)
Runs 'LuaCode' on the player's client and gets the result if 'GetResult' is true.
Handles encryption.
Handles decryption.
Start | Guides | Tables |
---|---|---|
Home | Creating a theme | The "Service" Metatable |