Chapter 2: Join Messages

Of course, Skript doesn't just allow us to do Hello World commands, we can do much more. In this chapter, we're going to do something which is actually useful, join and leave messages.

In This Chapter

We will customize the join and leave messages of our server to something other than the bland old vanilla yellow join and leave messages. I also noticed that the last chapter was way too long and detailed, so I've decided I'll skip over the obvious stuff and only explain things that may put up a challenge for new scripters.

Part 1: So... What Are Events Again?

Events in Skript are called when something happens in the server. This could be a player dying, a player taking damage, a mob spawning, a command being ran, or even just the script loading up. Almost all events return values. For example, in the death event, there are 2 expressions you can use to access these values, victim and attacker. Similarly, the command event also returns a few values, this time being command, full command, and sender.

In this chapter, we're going to be using the Player Join Event and Player Quit Event specifically. We can use the following expressions in these events: player, join message, leave message.

An expression is just a fancy way of saying 'something which returns something'. We can also change the values of some expressions! For example, in the Death Event, we cannot change the value of victim or attacker. However, in the Player Join Event, we CAN change the value of join message.

Part 2: Creating An Event

To create our Player Join Event, we simply type on followed by the event name. But we do not include 'Event'. For the Player Join Event we can simply use on player join and just like the command in the previous episode, we will have to insert a semicolon at the end of creating our event. Our code should now look something like this.

join_leave.sk
on player join:

Part 3: Changing The Join And Leave Messages

Again, just like in the previous chapter, we will put our next line of code after a tab, because whatever comes after the semicolon is now part of our event. So, let's change the message broadcasted. We're simply going to set the value of join message to our custom message. We can even include color codes! In my case, I'll set it to something simple, but you can change it to whatever you like! So, our next line will look something like set join message to "&7A player &6JOINED". We can now create a new Player Quit Event and just copy the code from the Player Join Event to this one, but change set join message to ... to set quit message to ... and of course change the text too. And that's it! We've just created custom join and quit messages. Our code will now look something like this:

join_leave.sk
on player join:
    set join message to "&7A player &6JOINED"

on quit:
    set quit message to "&7A player &cQUIT"

Warning Lots of reminders and warnings ahead!

Last updated