7. Send your first Global Message {{ currentPage ? currentPage.title : "" }}

Receive Global Messages

1. Create a new Widget, which contains a dark background (Border) and a Text Widget as child (Set Size to fit and center it). Spawn it on the top center of the Screen.

You can view it inside the SP8_WBP_HUD Example Widget which can be found inside RPG_Essentials / Example / Widgets.

2. Now we need to add following Variables.

  • isGlobalMessageRunning [Bool]: Check if currently a Global Message is shown.

  • NextGlobalMessage [Text Array]: If already a Global Message is shown, save the message here to show it after.

3. Now onStart we can do following:

  • Set the Text Widget to empty (We do not want to display Text at the beginning).

    • Of course you can hide the background as well if you want and only show if a Message was received.

  • Bind the Event GlobalMessageReceived from the Chat Component to a new Event.

  • Inside this new Event you need to check if a Message is already running (with the Variable isGlobalMessageRunning)

    • If yes, add the Message to the NextGlobalMessage Array.

    • If no, show the Global Message with a new Event (Easier to show it to you guys)

  • Inside the new Event you need to do following:

    • Set the IsGlobalMessageRunning Variable to true.

    • Set the Text Widget to the Message. (If you are hiding the Border, you need to make it visible now)

    • Now we need a Delay. Set the Duration to the seconds you want to show a Global Message.

    • Check if there are any Messages waiting to be shown (NextGlobalMessage Array).

      • If no, you can just remove the Text and set isGlobalMessageRunning to false.

      • If yes, you need to get the first Index and call the same Function again. Also you need to remove the first Index.

Now if the Player receives a Global Message, it should be printed inside the Border.

After 10 Seconds it should be removed or if a new Message was already written, the Text will change to the new Message.

Send Global Messages

In this Tutorial we will send a Global Message with the Command:

/global <Message>

1. First we create a new Command, which is replicated to the Client.

2. With PlayerTemplate: Go to your Function SP8_Override_CommandEntered.

Without PlayerTemplate: Go to your Interface Function SP8_CommandEntered.

Add to the switch the Command global, like we did in the Use Commands Tutorial and do following inside there:

  • First we need to check if the Length of the Input is longer then 0.

    • /global <Input Index 0 and higher = Message>

  • Inside the Input Array should be only the Message, which we need to change to the Message Text.

    • First we need to call on it the Join String Array to make it to a String and set as Seperator a Space.

    • Then we need to convert it to a text.

  • Now we can call SendGlobalMessage on the Chat Component and of course make our Message Structure.

  • At the end we can call Succeded.

Now you should be able to send a Global Message to all Players.

Customize the Message

If you need other Variables, which should be send to other Players on send as well, you can edit the Structure SP8_S_GlobalMessage inside the Directory RPG_Essentials / Chat / Structures.

You can add whatever you want. Just do not delete the Message Variable.

{{{ content }}}