I have come here seeking a shortcut to placing a function on every remote firing from the client. I am testing out a couple of exploit prevention ideas and are wondering if there is a way this is possible in some way?
The question is about the shortcut? or if you can handle all events fired calling one single function?
About the shorcut, I think you gotta do it manually, just Control+Shift+F and search for OnServerEvent word, and manually add a line into all listeners, a module function you created for the sanity check
I’m just wondering if there is a sort of shortcut to instead of putting a function in every event handler, that I can just handle them all at once, if that makes sense?
Not sure what you mean by ‘every remote firing from the client’, if you mean, the same remote on each client, then, yeah, it only takes one event handler on the server and it catches the same remote event but for all clients.
If you mean all the different remote events that a single client can fire, then yes, you can have a single function listen for all of them for all clients, however you must set a listener for each unique event per client on the server.
Each event listening when the client fires the event has its own function, inside that function manually you should add a module function to be called and which return true if the sanity check went correct. Obviously everything is server sided cause you mentioned its about exploiters security
You can’t connect to a remote that the client is just creating and firing that the server does not know about
Then again, if a client is doing that, its not getting to the server anyway.
But as you say multiple remotes at once.
For instance in my game Neverland Lagoon, I have one ‘MessageManager’ that recieves ALL the remotes firing from the clients.
Then when the server gets the message, it routes it to where it needs to go.
Each client has a script called ClientMessenger, and it looks in replicated storage for a RemoteEvent called MessageEvent
The server has a script called ServerMessenger and it looks in replicated storage for the same RemoteEvent called MessageEvent
Each time the client needs to talk to the server, it calls a function ToServer(,)
So then when the Server gets this message, it will see if the exists, and if so, will call that module and give it along with the player who’s client sent the message
Each tiem the server needs to talk to the client, its the reverse process… ToClient(,,) So the client of gets the message and checks if the exists and then sends it
So I basically use one RemoteEvent that both the client and server share, and just route messages depending on the data sent.
So pretty much you are sending and receiving a table where
table[1] == string of the module name
table[2] == table of data values that will be sent to the module
An exploiter could delete a local script no matter how you set it up.
To handle that, the server NEVER waits for a response from the client. Always assume the client has disconnected, or as you said, deleted a script so not able to respond.
NEVER let any of your game rely on a client working properly
Any messages your server sends to the client should be purely graphics, such as signaling things like gui, or responding to client requests (client sent message, they clicked a button, so we send a response back)
Any signals coming into the server from a client needs to be checked by the module on the server it was sent to, to validate if the data is correct, and if the client has permission to be sending that data to the server.