[Tut] How to make a NPC player command

Joined
Jul 16, 2008
Messages
411
Reaction score
0
There have been some people asking me lately. So here it is.

Code:
                } else if (splitted[0].equals("@[COLOR="Red"]COMMANDNAME[/COLOR]")) {
                        NPCScriptManager npc = NPCScriptManager.getInstance();
                        npc.start(c, [COLOR="Red"]NPC ID[/COLOR]);


For example:

Code:
                } else if (splitted[0].equals("@[COLOR="Red"]spinel[/COLOR]")) {
                        NPCScriptManager npc = NPCScriptManager.getInstance();
                        npc.start(c, [COLOR="Red"]9000020[/COLOR]);

Congratz! You have made a command that will open a NPC!

Note: The text in red is the text you have to edit
 
Re: [Guide] How to make a NPC command

It might have been a better idea to put the title as "NPC Player command" because the title makes it seem like this is a guide to making an NPC.
 
Code:
                } else if (splitted[0].equals("@spinel")) {
                        NPCScriptManager npc = NPCScriptManager.getInstance();
                        npc.start(c, 9000020);

Instead of that why not do

Code:
                 } else if (splitted[0].equalsIgnoreCase("@opennpc")) {
                         NPCScriptManager.getInstance().start(c, splitted[1]);
                 }

This way, you won't have to make more than 1 command for all the NPC's you want to open and you can just use this one.

Example: !opennpc 9000020
This will open spinel I think?
 
Back