NPC Commands

From Citizens Wiki

Revision as of 11:03, 10 September 2020 by Mcmonkey (talk | contribs)

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.

Note as well that if you have PlaceholderAPI installed, you can use PAPI placeholders within commands.

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).

Generally, it's best to execute as-server (don't specify -p or -o to use the default as-server), which will not require any permissions. You will need to use <p> to fill in the playername wherever the command requires one.

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.

Other Options

There are several more options available for /npc command not explained here, so type /npc help command in-game to see them.

Additional Support

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