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.
== Bungee's /Server ==
The Bungee "/server" command exists at the proxy level, not the Spigot server level. This means that it gets intercepted before the Spigot server ever sees it, and means that it cannot be ran from something on the server (like an NPC).
To work around this problem, we have provided a solution in [https://guide.denizenscript.com/guides/background/what-is-denizen.html Denizen]. To use this, first [https://ci.citizensnpcs.co/job/Denizen/ download Denizen here] and add it into your plugins folder. Then, [https://one.denizenscript.com/haste/67017 download the script from here] (via the "download the script" button at the top left) and save it into the folder path "plugins/Denizen/scripts". After you restart your server, you will have the "/sendplayer" command available.
With this, you can do for example <code>/npc command add sendplayer &lt;p&gt; myservernamehere</code> to send any player that clicks the NPC to the Bungee server "myservernamehere".


== Old Method ==
== Old Method ==


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


=== Prerequisite ===
=== Prerequisite ===
Line 25: Line 33:
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 [https://guide.denizenscript.com/guides/npcs/assignment-scripts.html guides page explaining how to do this here].
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 [https://guide.denizenscript.com/guides/npcs/assignment-scripts.html guides page explaining how to do this here].


=== Easier Option ===
=== 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 [https://forum.denizenscript.com/viewtopic.php?f=13&t=149 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).
If you'd rather not bother with scripting yourself and instead would prefer to use an in-game command, you can use a premade [https://forum.denizenscript.com/viewtopic.php?f=13&t=149 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 ==
== 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 10:57, 6 April 2020

NPC Click Commands

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

There is a limited version of this newly available in 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.

Bungee's /Server

The Bungee "/server" command exists at the proxy level, not the Spigot server level. This means that it gets intercepted before the Spigot server ever sees it, and means that it cannot be ran from something on the server (like an NPC).

To work around this problem, we have provided a solution in Denizen. To use this, first download Denizen here and add it into your plugins folder. Then, download the script from here (via the "download the script" button at the top left) and save it into the folder path "plugins/Denizen/scripts". After you restart your server, you will have the "/sendplayer" command available.

With this, you can do for example /npc command add sendplayer <p> myservernamehere to send any player that clicks the NPC to the Bungee server "myservernamehere".

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!