> For the complete documentation index, see [llms.txt](https://tenfont.gitbook.io/skript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tenfont.gitbook.io/skript/tutorial/section-1/chapter-2.md).

# 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`.&#x20;

{% hint style="warning" %}
Expressions used in events are usually called by the prefix `event-` so the player in the **Player Join Event** would be written as `event-player`. However, this is not always necessary.
{% endhint %}

{% hint style="info" %}
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`.
{% endhint %}

## 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.

{% code title="join\_leave.sk" %}

```
on player join:
```

{% endcode %}

## 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](https://www.digminecraft.com/lists/color_list_pc.php)! 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:

{% code title="join\_leave.sk" %}

```
on player join:
    set join message to "&7A player &6JOINED"

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

{% endcode %}

**Warning** Lots of reminders and warnings ahead!

{% hint style="danger" %}
To include an expression inside a string, simply placing the expression's name somewhere would not work. For example, writing `set join message to "&7player's name &6JOINED"` wouldn't work. It would just send "player's name" instead of actually sending the player's name. To fix this, we surround `player's name` with percent signs `%`.
{% endhint %}

{% hint style="danger" %}
Be careful of when you use percent signs! A lot of new scripters think that expressions are always surrounded by percent signs, but this is just not true. You would only surround an expression with percent signs if the expression is placed inside a text.
{% endhint %}

{% hint style="warning" %}
If you just want to use a percent sign in a text, and not to surround an expression, for example `broadcast "50%"` then all you would do is enter 2 percent signs instead of 1. So that would be `broadcast "50%%"`.&#x20;
{% endhint %}

{% hint style="warning" %}
To enter the next line, simply use the `n[ew]l[ine]` expression in your text. (Remember to surround it with percent signs, as I discussed in the paragraph above this one.) And if you've read the first chapter, you should know that the `ew` in `new` and the `ine` in `line` is optional. So you could ignore them and simply use `nl`.
{% endhint %}
