SkriptTips and Techniques

Introduction to Skript - The Basics

1c71c7

1c7

3 min read
Introduction to Skript - The Basics

In this blog post, we'll cover the basics of Skript.

First off, what is Skript?

In order for your server to be successful, Skript is a vital tool you should be utilising. Skript is a Minecraft plugin that allows you to modify different aspects of your server. You can 'code' plugins in plain English, without needing previous programming experience. Skript is an event-driven language, meaning code is run when certain events are triggered, such as on player jump: or on player world change:.


The Benefits

The main reason that Skript is so popular is that no programming knowledge is needed. Every line that you write will be in plain English, meaning it is simple to understand and learn.

Furthermore, Skript has a massive support network. Not only is there a dedicated #skript support channel on the Minefort discord, there are dedicated websites, YouTube channels and Discord servers that have been created to offer free support. There is also extensive documentation, so that you can easily find the correct syntax for your code.

Lastly, Skript is quick to implement. All you need is the server that Minefort provides, the Skript plugin, and you're good to go. Just run /sk reload (file), and your script will be updated on your server. Simple.


Installing Skript & Creating Scripts

You can download Skript from the official GitHub page here. Drag the jar file into your servers plugin directory via FTP. Once you have done this, you'll need to restart your server. Once this has been done, you can start creating scripts.

In order to create a script, you need to use FTP to navigate through plugins > Skript > scripts. Once you are here, create a new file ending with the suffix .sk, for example myscript.sk. Now you need to enter this file using a text editor of your choice, however I suggest using Visual Studio Code.


Coding your script

In this blog post, we'll create a simple welcome message that is broadcasted to your server when a player joins. The first line will be the event. This is the line that will run whenever the event is triggered. In our case, the event is on join:. Then we go to the next line, and indent.

Indentation is a very important part of Skript. Each time there is a colon, the next line down needs to be indented one more than the last. You can simply tab to indent, or use spaces, but within the file, the same indentation must be used throughout.

On our second line, once we have indented, we can use the broadcast effect. This does what it says it does, it broadcasts a message to the entire server once our event has been triggered (when a player joins). We can now add our text to the effect. Within the text, we can use an expression. In our case, we can use %player%, which will be replaced with whatever the players name is. There are tons of expressions, such as %world%, %item%, and much more. Please note, you only need to surround the expression in % when using it within a string. Our text will announce "Welcome %player% to the server!".

Once we have done all this, our simple two lines of code will look like this:

on join:
	broadcast "Welcome %player% to the server!"

On your server, you will need to run the command /sk reload (filename).


Core Concepts

In order for your knowledge of Skript to grow, you'll need to be familar with the core concepts.

Events are called when certain actions happen, such as if a player jumps or takes damage, or even when the world does something independant of entity interaction.

Conditionals are pieces of code that can check to see if a certain condition is met before the rest of the code is ran.

Loops are used to repeat a section of code more than once. While loops run the code aslong as  a specificed condition is positive.

Variables are the most important aspect of Skript. Variables allow you to store information, which allows us to retrieve the information at a later time. Variables can be overridden, meaning we can use an expression within a function, such as %player's uuid%, to link the variable to each player.

Something wrong with this article? Reach out to me, @Adxm#9504, and we'll get it fixed!

Create your Minecraft server with Minefort.com

Elevate your Minecraft experience to new heights with Minefort - the most advanced and user-friendly server manager on the market, featuring a customizable control panel, a wide range of plugins and mods, and top-notch support from our team of experts!

Get started for free, no credit card required. 🎉