Jump to content

client-server


Recommended Posts

First off, you must add an event using addEvent on the side (client or server) which you want to pass data to. Make sure to make the second parameter (after the name of the event) true, so it can be executed from the other end (client -> server & server -> client).

Every event must have a handler (ie a function that handles what happens when the event is triggered), so we add one in with addEventHandler. Usually tying it to the root element or resourceRoot element will suffice. Remember, it triggers down the element tree, so be careful with what element you tie it to.

From here, we just triggerClientEvent and triggerServerEvent.

triggerClientEvent is used to transfer data to a client. You can specify which client(s) you want it to trigger on and any other data you want to pass.

triggerServerEvent is used to transfer data to the server. There is a source parameter, which can be a little confusing, especially if the source is just the localPlayer. So for safety and ease of use, we can use client on the server if the source is the localPlayer and set the source parameter to 'resourceRoot'.

There is also triggerLatentClientEvent if you don't want to interrupt traffic. It works the same as triggerClientEvent.

Have a look at the event system for further explanation.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...