[Tutorial] Disable commands in maps

Newbie Spellweaver
Joined
Feb 27, 2011
Messages
11
Reaction score
1
This tutorial shows you how to block commands ...
If I want to block @spinel in FM (910000000)
PHP:
else if (splitted[0].equals("@spinel")) {
                NPCScriptManager npc = NPCScriptManager.getInstance();
                npc.start(c, 9000020);
            }
This is the original code.
So ... add
PHP:
if (player.getMapId() == 910000000){
below
PHP:
else if (splitted[0].equals("@spinel")) {
ok now below
PHP:
if (player.getMapId() == 910000000){
add in
PHP:
player.dropMessage("You cannot use this command in this map");
okay.. again, below
PHP:
player.dropMessage("You cannot use this command in this map");
add in
PHP:
} else {
So the finished code is...
PHP:
else if (splitted[0].equals("@spinel")) { 
if (player.getMapId() == 910000000){
player.dropMessage("You cannot use this command in this map");
} else {
                NPCScriptManager npc = NPCScriptManager.getInstance(); 
                npc.start(c, 9000020); 
            }
This is like Ehab's but his code is
PHP:
else if (splitted[0].equals("@spinel")) {
if (player.getMapId() == 910000000){
                NPCScriptManager npc = NPCScriptManager.getInstance();
                npc.start(c, 9000020);
} else {
mc.dropMessage("You cannot use this command in this map");
}
            }
Ehab's one only allows @spinel in FM Map, but not in other maps.
So I tried to reverse his code and it worked! ..

Credits to Ehab 90%
Credits to Me for reversing his code :D 10%

please dont flame this is my first tutorial and Im new to coding. (:
And remember to compile or it won't work~
-
Questions I think people would ask
-
Q: Where do I put this code?
A: In Playercommands.java

Q: I got errors compiling (npc start)
A: If your source doesn't use
PHP:
npc.start(c, 9000020);
, you can try
PHP:
NPCScriptManager.getInstance().start(c, 9000020, null, null);
 
Last edited:
Good work for your first release. But maybe next time don't release something that has already been released by someone else and/or is already often used in most sources.

Yep this was released by Ehab but his effects were disabling commands everywhere except the mapid which is placed there, (910000000) . just wanted to help others..
 
I like the fact that people experiment with new things. That's the easiest and enjoyable way of learning (in my opinion)
 
Back