NPC Commands: Difference between revisions
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
This is available within Citizens via the "/npc command" command. For details, refer to <code>/npc help command</code>. | This is available within Citizens via the "/npc command" command. For details, refer to <code>/npc help command</code>. | ||
== Adding Click Commands == | |||
By default, "/npc command" will run commands as the server. Use "-p" to run as the player who clicked instead. | By default, "/npc command" will run commands as the server. Use "-p" to run as the player who clicked instead. | ||
Line 12: | Line 14: | ||
For example: Use <code>/npc command add kick <p></code> to make an NPC automatically kick the player when clicked. | For example: Use <code>/npc command add kick <p></code> to make an NPC automatically kick the player when clicked. | ||
=== Other Placeholders === | |||
Note as well that if you have PlaceholderAPI installed, you can use PAPI placeholders within commands. | Note as well that if you have PlaceholderAPI installed, you can use PAPI placeholders within commands. | ||
=== Permissions === | === Requiring Permissions === | ||
By default, anybody can click the NPC to cause a command to execute, without any permission requirement. | By default, anybody can click the NPC to cause a command to execute, without any permission requirement. | ||
Line 31: | Line 35: | ||
On Bungee servers, this supports the Bungee <code>server</code> command, like <code>/npc command add -p server MyServerName</code>. | On Bungee servers, this supports the Bungee <code>server</code> command, like <code>/npc command add -p server MyServerName</code>. | ||
=== Other Options == | == Removing Commands == | ||
To remove a command, first type just <code>/npc command</code> to see the list of currently attached commands with ID numbers. | |||
If you have for example a command with ID 0, you can then type <code>/npc command remove 0</code>. | |||
== Other Options == | |||
Other ways you can control <code>/npc command</code> include: | |||
* <code>/npc command permissions x.y.z</code> to attach temporary permissions to the player (generally don't use this, instead use <code>-o</code>) | |||
* <code>/npc command sequential</code> to make commands execute sequentially (in order) each time the player clicks the NPC (if you attach multiple commands). | |||
* <code>/npc command add -l somethinghere</code> to make the command require a left click (punch/attack). Note that this may not work if PvP is disabled. | |||
* <code>/npc command add -r somethinghere</code> to make the command require a right click (or: not allow left clicks). | |||
* <code>/npc command add --n 5 somethinghere</code> to make a command only usable a certain number of times per player (in this example, 5 usages). | |||
* <code>/npc command add --cooldown 10 somethinghere</code> to make the command only usable once per certain time period (in this example, 10 seconds). | |||
* <code>/npc command add --delay 40 somethinghere</code> to make the command have a delay before it activates (in this example, 40 ticks, aka 2 seconds). | |||
There | There maybe be more options available for <code>/npc command</code> not yet explained here, so type <code>/npc help command</code> in-game to see any such options. | ||
== Additional Support == | == Additional Support == | ||
If confused, join the [https://discord.gg/Q6pZGSR Citizens+Denizen shared Discord] to ask for help! | If confused, join the [https://discord.gg/Q6pZGSR Citizens+Denizen shared Discord] to ask for help! |
Revision as of 19:34, 25 September 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
.
Adding Click Commands
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.
Other Placeholders
Note as well that if you have PlaceholderAPI installed, you can use PAPI placeholders within commands.
Requiring 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
.
Removing Commands
To remove a command, first type just /npc command
to see the list of currently attached commands with ID numbers.
If you have for example a command with ID 0, you can then type /npc command remove 0
.
Other Options
Other ways you can control /npc command
include:
/npc command permissions x.y.z
to attach temporary permissions to the player (generally don't use this, instead use-o
)/npc command sequential
to make commands execute sequentially (in order) each time the player clicks the NPC (if you attach multiple commands)./npc command add -l somethinghere
to make the command require a left click (punch/attack). Note that this may not work if PvP is disabled./npc command add -r somethinghere
to make the command require a right click (or: not allow left clicks)./npc command add --n 5 somethinghere
to make a command only usable a certain number of times per player (in this example, 5 usages)./npc command add --cooldown 10 somethinghere
to make the command only usable once per certain time period (in this example, 10 seconds)./npc command add --delay 40 somethinghere
to make the command have a delay before it activates (in this example, 40 ticks, aka 2 seconds).
There maybe be more options available for /npc command
not yet explained here, so type /npc help command
in-game to see any such options.
Additional Support
If confused, join the Citizens+Denizen shared Discord to ask for help!