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

    |     
  • Feb. 5, 2023, 3:02 p.m. - skraptmast3r  

    e

    |     
  • April 14, 2023, 8:56 a.m. - eult  

    *It's outdated,
    The new way to create a staff chat can be found here
    *
    command /staffchat [[HTML_REMOVED]]: aliases: /sc permission: staff.chat trigger: if arg is set: send formatted "&a%player%: &f%arg%" to all players where [player input has permission "staff.chat"]

    |     
    April 14, 2023, 8:59 a.m. - eult  

    Honestly, I don't know why the comment ended up like this, but here's the code.
    it's in the examples:
    https://skripthub.net/docs/?id=2619

    |     
  • April 18, 2023, 7:33 p.m. - KWAKZ  

    else: and if arg-1 is not empty:
    is the same thing?
    so if you want to disable the sc you are forced to send a msg.

    you should have the else in the if arg-1 is not set and check if sc.%uuid of player% is true to disable it

    also if sc.%uuid of player% is not set and set it to true

    |     
  • June 13, 2023, 10:51 a.m. - sulphinx  

    Just use if input has permission, you can enable/disable permissions with luckperms.
    That would make it more performance efficient.

    The code you have right now is very ugly.

    |