Skip to content

Part 3. Server side Settings

rvIceBreaker edited this page Dec 9, 2021 · 5 revisions

In this guide we'll cover how to publish and capture server-side settings from our Mod Controller.

There may be some caveats as well, so we'll cover those points as well.

Setting Markers

To start off we'll publish a new setting that will be server-side only.

  1. Create a new text variable in your mod controller, give it any name you want
  2. Open the GetModSettings function in your mod controller
  3. Add a Add Setting Single Line Text node
  4. Set the Name field, make note that we'll need it later
  5. Set the Label Text, Tooltip Text, and Hint Text as you feel is necessary
  6. Plug your new text variable into the Value pin of the Add Setting Single Line Text node
  7. Add a Setting Mark Server Side node, and link the Setting Object pins
  8. Add a Mod Append Setting node, and link the Mod Object and Setting Object pins as you had before

The key here is the Setting Mark Server Side node. This tags our setting as being server-side, which has some implications

  • Server-side settings are only visible to logged-in admins
  • Server-side settings are not transmitted in any way to non-admins, not even with default values
  • Players are validated server-side before changed settings are sent to mod controllers
  • Server-side settings do not get applied to the client-side mod controller automatically

At the time of writing, the only setting marker available is for marking a setting as being server-side. In the future, there may be additional markers used to modify how settings controls behave.

From here, we're now publishing a new text setting that will be displayed in a single-line editable text box. It will only be visible and editable by server admins, but it will be sent to the server-side mod controller, and you can decide what to do with it from there.

Capturing Server-side Settings

Capturing changes for server-side settings is similar to what we did in part 2, except now we use the Event Apply Mod Server Settings event in our mod controller

  1. Open your mod controller's Event graph
  2. Add/Create an Apply Mod Server Settings Event
  3. Add a Verify Caller node and link the Calling Object pin
  4. Add a Setting Read Text node
  5. Set the Setting Name field to the name of your setting defined earlier in GetModSettings
  6. Use the Value Set output to set the text variable you created in the mod controller previously

The Verify Caller node is very important! Read more about it here

Now you're capturing both client-side settings changes, and server-side settings changes.

You can build and test your mod, but this may be difficult to see in action.

Here is the setup to the above image

  • Client A and Client B are both admins (MakeMeAdmin)
  • Client A has modified "My Variable" and "My Text Setting"
  • Client B has not modified "My Variable" OR "My Text Setting"
  • Client A and Client B both closed and reopened the settings window after changes were made by Client A

And here is the explanation

  • "My Variable" is different between clients because it is client-side only; each client can change this setting independent of the server and other clients
  • "My Text Setting" is the same because it is server-side. Because the value is requested from the server when the window opens, the value is the same for both clients

note: there's a small 'gotcha' with the settings window; settings values do not update in real-time, thus the need to close and re-open the window on both clients.

When the Apply Mod Server Settings event fires on the server object, you can then replicate this back to the client object using standard replication in Unreal. This may be necessary to do if the client-side mod controller or another object needs to know the value of a server-side variable.

I recommend reading into replication and networking documentation for Unreal if you need to know more.

Conclusion

At the end of this guide you now have a mod controller that publishes both client-side and server-side settings that users can modify. You can capture the changes to those settings in both domains as well.

From here on, its up to you on how you employ this functionality or tie it in with your existing systems.

Your next steps may be to serialize the data passed to/from your mod controller to persist the data across sessions.

You can also look at the types of settings ModConfig provides too

Clone this wiki locally