Tutorial by: 1_x409


Ok, so your a server owner with some staff members, they then ask "Why isnt there a /staffchat?
Well today, I will show you how to make a simple, but effective staff chat. Lets get started with the command:

command /staffchat:

Let's now put in permissions and aliases:

command /staffchat:
    aliases: /sc
    permission: sk.sc
    permission message: "&c&lSorry but you do not have the correct permissions to do this command!"

So now, a player who has the permission, sk.sc, will be able to use the command, /staffchat and /sc
Lets now add an argument,
This argument will allow the player to type in their message:

command /staffchat [<text>]:
    aliases: /sc
    permission: sk.sc
    permission message: "&c&lSorry but you do not have the correct permissions to do this command!"

We have added the [<text>] argument, which allows the player to type in some text!
Ok so now what?
Well first we need to make a variable storing the [<text>] argument.
This is because when you go to send the message, it wont let you.
So lets add that variable.
Oh wait, you cant forget the trigger!

command /staffchat [<text>]:
    aliases: /sc
    permission: sk.sc
    permission message: "&c&lSorry but you do not have the correct permissions to do this command!"
    trigger:
        set {msg} to arg-1

We have now set the 1st argument to a variable called "msg"
If we wanted to use it, we would want to put it like this %{msg}%
we put the precentages to show skript that this is a variable and not text.
Lets add some "if" statements to make it toggleable.
Pretty much, if you type it in, it will be kept turned on until you disable it by doing the same command again:

command /staffchat [<text>]:
    aliases: /sc
    permission: sk.sc
    permission message: "&c&lSorry but you do not have the correct permissions to do this command!"
    trigger:
        set {msg} to arg-1
        if arg-1 is empty:
            send "&e&l[STAFF&6&lCHAT] &7&lEnabled Staff Chat" to player
            set {sc.%uuid of player%} to true
        else:
            send "&e&l[STAFF&6&lCHAT] &7&lDisabled Staff Chat" to player
            set {sc.%uuid of player%} to false

You see how we now have "if arg-1 is empty".
pretty much skript is looking to see if the player typed in anything or not.
If they didn't, it will enable staff chat and set another variable, {sc.%uuid of player%}. This variable stores the players uuid, which means even if they change names, they will be still in staff chat.
And then we have the "else"
Thats pretty much the easiest toggle method for skript.
Lets now add another "if" statement for if arg-1 is NOT empty:

command /staffchat [<text>]:
    aliases: /sc
    permission: sk.sc
    permission message: "&c&lSorry but you do not have the correct permissions to do this command!"
    trigger:
        set {msg} to arg-1
        if arg-1 is empty:
            send "&e&l[STAFF&6&lCHAT] &7&lEnabled Staff Chat" to player
            set {sc.%uuid of player%} to true
        else:
            send "&e&l[STAFF&6&lCHAT] &7&lDisabled Staff Chat" to player
            set {sc.%uuid of player%} to false
        if arg-1 is not empty:
            send "&e&l[STAFF&6&lCHAT] &a&l%player% &7&l>> %{msg}%" to all players where [input has permission "sk.sc"]

Okay, so this if statement is pretty confusing but pretty much whats happening is that, the variable we set earlier is now getting used to display the message.
So its sending [STAFFCHAT] 1_x409 >> %{msg}% to all players with the permission "sk.sc"
Lets now make it so that you can send the message when toggled using an "on chat:" event

command /staffchat [<text>]:
    aliases: /sc
    permission: sk.sc
    permission message: "&c&lSorry but you do not have the correct permissions to do this command!"
    trigger:
        set {msg} to arg-1
        if arg-1 is empty:
            send "&e&l[STAFF&6&lCHAT] &7&lEnabled Staff Chat" to player
            set {sc.%uuid of player%} to true
        else:
            send "&e&l[STAFF&6&lCHAT] &7&lDisabled Staff Chat" to player
            set {sc.%uuid of player%} to false
        if arg-1 is not empty:
            send "&e&l[STAFF&6&lCHAT] &a&l%player% &7&l>> %{msg}%" to all players where [input has permission "sk.sc"]
on chat:
    if {sc.%uuid of player%} is true:
        send "&e&l[STAFF&6&lCHAT] &a&l%player% &7&l>> %{msg}%" to all players where [input has permission "sk.sc"]

Its pretty much the same as the one up there. Its just checkng if {sc.%uuid of player%} is true.


Did you find 1_x409's tutorial helpful?


You must be logged in to comment

  • Sept. 29, 2022, 5:53 a.m. - skTank  

    The 'set {msg} to arg-1' is not needed as you can put '%arg-1%' but otherwise its fine.

    |     
    Sept. 29, 2022, 3:42 p.m. - 1_x409  

    Thanks for your nice opinion :D

    |