NPC Commands: Difference between revisions

From Citizens Wiki

No edit summary
No edit summary
Line 12: Line 12:


For example: Use <code>/npc command add kick &lt;p&gt;</code> to make an NPC automatically kick the player when clicked.
For example: Use <code>/npc command add kick &lt;p&gt;</code> to make an NPC automatically kick the player when clicked.
=== Permissions ===
By default, anybody can click the NPC to cause a command to execute, without any permission requirement.
If <code>-p</code> is used, it will execute as-player, meaning any permissions check '''the command itself''' has will be required for the player.
If <code>-o</code> is used, it will execute as-op, meaning the player will be treated as if they were a server operator, and thus usually permissions won't be expected (unless you have a permissions plugin that doesn't respect op, or a protection plugin that disables op).
If you want to add your own additional permissions requirement, use <code>--permission my.perm.here</code> when adding the command.


=== Bungee ===
=== Bungee ===

Revision as of 17:58, 3 June 2020

NPC Click Commands

One of the common things Citizens users want is the ability to have NPCs run a command when right-clicked.

This is available within Citizens via the "/npc command" command. For details, refer to /npc help command.

By default, "/npc command" will run commands as the server. Use "-p" to run as the player who clicked instead.

For example: Use /npc command add -p help to make an NPC automatically execute "/help" as the player when clicked.

To auto-fill the player name, use "<p>". To autofill the NPC ID, use "<n>".

For example: Use /npc command add kick <p> to make an NPC automatically kick the player when clicked.

Permissions

By default, anybody can click the NPC to cause a command to execute, without any permission requirement.

If -p is used, it will execute as-player, meaning any permissions check the command itself has will be required for the player.

If -o is used, it will execute as-op, meaning the player will be treated as if they were a server operator, and thus usually permissions won't be expected (unless you have a permissions plugin that doesn't respect op, or a protection plugin that disables op).

If you want to add your own additional permissions requirement, use --permission my.perm.here when adding the command.

Bungee

On Bungee servers, this supports the Bungee server command, like /npc command add -p server MyServerName.

Old Method

The old method, which in some cases can still be the better method, is to use Denizen - information for that follows below.

Prerequisite

Denizen is a scripting engine that directly integrates Citizens to add more features and options to server owners. Learn about Denizen on the guides here and download Denizen on the Citizens Jenkins build server here.

How To Make a Click Command

The standard way to get click-commands set up in Denizen is to write an assignment script with a click action or trigger. There's a guides page explaining how to do this here.

Easier Denizen-Based Option

If you'd rather not bother with scripting yourself and instead would prefer to use an in-game command, you can use a premade script available here. Simply download the script linked in that forum post, save it into "plugins/Denizen/scripts" as a .dsc file, and then use "/ex reload" to load the script. At that point, you can select any NPC and use "/npccommand set [command]" (view the forum post linked previously for additional command usage information).

This is more or less equivalent to a slightly more advanced version of the "/npc command" option.

Additional Support

If confused, join the Citizens+Denizen shared Discord to ask for help!