Tutorial by: RealUser_


Requirements:

-Skript
-SkQuery

What you will make:

A simple jail skript, with the commands:
/jail - to jail a player;
/unjail - to unjail a player;
/jails - to see how meany jails a player has, and
/clearjails - to clear the amount of jails a player has had.

So, first off, we need to make the jail command. Lets do that:
command /jail
Now lets add the command perams:
command /jail &lt;offline player> <text> <timespan>
Now we have created the command, lets add a permission. I will use jails.jail

command /jail &lt;offline player> <text> <timespan>
    permission: jails.jail

Now we have the permission, lets get on to the trigger:

command /jail &lt;offline player> <text> <timespan>:
    permission: jails.jail
        trigger:
                add 1 to {jails::%uuid of arg-1%}
        set {jailresason::%uuid of arg-1%} to arg-2
        set {jailtime::%uuid of arg-1%} to arg-3
        execute console command "teleport %arg-1% 104 89 50"
        send "&0[&c&lJails&0] &4%arg-1% was jailed for %arg-2% for %{jailtime::%uuid of arg-1%}%" to all players where [input has permission "jails.jail"]
        wait {jailtime::%uuid of arg-1%}
        execute console command "/unjail %arg-1%"

Adding 1 to the {jails:%uuid of arg-1%} will add 1 to the variable so we can use this in our /jails [user] command later. This command will output the amount of jails a user has had.
Setting the jail reason to arg-2 is self explanatory.
Setting the jailtime to arg-3 is too.
Next, its going to teleport the jailed player to the co ords of the jail. In my case 104 89 50 are the co ords of my jail.
Then, it is going to wait until the players jailtime is 0, then it will free the player by executing the console command /unjail %arg-1%
We dont have an unjail command yet, so lets do that now.

command /unjail &lt;offline player>:
    permission: jails.unjail
        trigger:
        delete {jailreason::%uuid of arg-1%}
        delete {jailtime::%uuid of arg-1%}
        execute command "tp %arg-1% 104 89 45"

So, we are making the command unjail, with the permission node jails.unjail.
The trigger is pretty simple. We are deleting the jail reason, as we no longer need it as the player has been unjailed. We are also deleting the jail time because we dont need that now either.
Then we are teleporting the player to the co ords of spawn, in my case 104 89 45.
Now lets add the /jails command so we can see how meany jails a player has:

command /jails &lt;offline player>:
    permission: jails.jailamount
    trigger:
        send "&0[&c&lJails&0] &6Jails of &4%arg-1%&6: %{jails::%uuid of arg-1%}%"

So we are making the command jails with the permission node jails.jailamount.
In the trigger, we are sending a message to the command executor, saying the amount of jails a player has.
Now lets add a way to clear that amount:

command /clearjails &lt;offline player>:
    permission: jails.clearjailsamount
    trigger:
        set {jails::%uuid of arg-1%} to 0
        send "&0[&c&lJails&0]&2 Cleared %arg-1%'s jails!" to executor
        send "&0[&c&lJails&0]&2 Your jails were cleared" to arg-1

So we are making the command clearjails with the permission node jails.clearjailamount.
In the trigger, we are setting the jails of the player to 0, then sending a message to the executor saying the players jails have been cleared. We are also sending a message to the person we are clearing the jails of, saying their jails have been cleared.
This is what your skript should look like (you probably edited the co ords of your spawn and jail):

command /jail &lt;offline player> <text> <timespan>:
    permission: jails.jail
    trigger:
        add 1 to {jails::%uuid of arg-1%}
        set {jailresason::%uuid of arg-1%} to arg-2
        set {jailtime::%uuid of arg-1%} to arg-3
        execute console command "teleport %arg-1% 104 89 50"
        send "&0[&c&lJails&0] &4%arg-1% was jailed for %arg-2% for %{jailtime::%uuid of arg-1%}%" to all players where [input has permission "jails.jail"]
        wait {jailtime::%uuid of arg-1%}
        execute console command "/unjail %arg-1%"

command /unjail &lt;offline player>:
    permission: jails.unjail
    trigger:
        delete {jailreason::%uuid of arg-1%}
        delete {jailtime::%uuid of arg-1%}
        execute command "tp %arg-1% 104 89 45"
command /jails &lt;offline player>:
    permission: jails.jailamount
    trigger:
        send "&0[&c&lJails&0] &6Jails of &4%arg-1%&6: %{jails::%uuid of arg-1%}%"

command /clearjails &lt;offline player>:
    permission: jails.clearjailsamount
    trigger:
        set {jails::%uuid of arg-1%} to 0
        send "&0[&c&lJails&0]&2 Cleared %arg-1%'s jails!" to executor
        send "&0[&c&lJails&0]&2 Your jails were cleared" to arg-1

I hope this helped you make a jail skript.


Did you find RealUser_'s tutorial helpful?


You must be logged in to comment