Now that we have talked about events, let's learn how we can register some custom commands, let's start off with sending a "Hello" text, here is how you register commands:
command /test: # The command name, you can specify it whatever you would like.
aliases: /test2 # Here you can define aliases which basically means you can execute this command with /test2 and /test, very handy and this is optional.
permission: test.usage # You can specify whatever permission you would like in here, so if the player has permission "test.usage" they can execute this command. This is optional
permission message: No Perms! # Right here this will send "No Perms!" in chat only for the player if they don't have the "test.usage" permission. This is also optional.
trigger: # You must add a trigger which basically means the code will trigger after this line.
send "Hello" to player # This is the line after trigger, it sends a "Hello" message only to the player in chat once they execute /test or /test2, you can do /test2 because we defined it.
Lets try a more useful command, like /broadcast which will send a message to everyone in the server.
command /broadcast [<text>]: # This is the command. [<text>] means an argument which you can do like: "/broadcast Hello!" instead of just /broadcast. We'll talk more about them later.
aliases: /bc # This is the aliases, so you can execute this command with /bc and /broadcast. (Warning: Essentials will override /bc if you have it installed).
permission: cmd.broadcast # This will register the permission to where only the player with the permission "cmd.broadcast" can use this command.
permission message: Sorry! But you don't have permission. # This will send the message in chat if they do not have the permission "cmd.broadcast".
trigger: # If your registering command it must have a trigger which will trigger the code after this line.
send "Broadcast: %arg-1%" to all players # Now this is where arguments come into place. This will send "Broadcast: (specified argument)" to everyone in the server.
You can use arguments in skript for many different things, like you see above, %arg-1% just means the first specified argument, you can specify more arguments like:
command /argument [<text>] [<number>]: # First Argument: [<text>], Second Argument [<number>] etc etc.
This will specify a text and a number argument which means you can specify a number in the second argument, so if you want to broadcast the second argument (the [<number>]) it will be %arg-2% which is the second argument as you can see. Don't get confused when you see them, you can specify arguments whatever you like. For example:
command /argument2 [<number>] [<string>]: # This will specify the [<number>] argument which is %arg-1% and the second argument is [<string>]. A string is just basically some text that you have written.
Back to our broadcast command:
command /broadcast [<text>]:
aliases: /bc
permission: cmd.broadcast
permission message: Sorry! but you don't have permission.
trigger:
send "Broadcast: %arg-1%" to all players
Once you write /broadcast Hello! it will send "Broadcast: Hello!" in chat. If we do not have the [<text>] we cannot do /broadcast Hello and will send an error that %arg-1% does not exist once you reload the skript.</text></text></string></number></string></number></number></number></text></number></text></text></text>