I have only posted this tutorial here and http://tutorials.rsps-hosts.com/smf/
If you see it anywhere else it is leeched
Description: Make a jail that you can't teleport out of and if you try to noclip you get teleported back into jail.
The mini-map is disabled while you are in jail aswell
This is for MOD+ command but can easily be changed to admin+ by changing a few 1's to 2's..[/i]
Difficulty: Probably 2-3/10.
Assumed Knowledge: Where to add a command, boolean or void...
Tested Server: any server
Files/Classes Modified: client.java and if you want to add the npcs that talk you need to modify autospawn.cfg and NPCHandler.java
Procedure
So here we go...
First add these commands into client.java
Code:
if (command.startsWith("jail") && (playerRights >= 1)) {
try {
String name = command.substring(5);
client c = (client) PlayerHandler.players[PlayerHandler.getPlayerID(name)];
//creates a new client object and fills in its needed paramaters
c.teleportToX = 3123;
c.teleportToY = 3242;
c.teleblock = true;
c.sendMessage("You have been sent to jail for breaking the rules!");
c.sendMessage("Maybe someone will release you shortly...");
c.teleblock = true;
updateRequired = true;
appearanceUpdateRequired = true;
sendMessage("Player succesfully jailed");
PlayerHandler.messageToAll =("[SUCESS]: "+command.substring(5)+" has been jailed for breaking the rules");
} catch (Exception e) {
sendMessage("Try entering a name you want to send to jail");
}
}
else if (command.startsWith("unjail") && (playerRights >= 1)) {
try {
String name = command.substring(7);
client c = (client) PlayerHandler.players[PlayerHandler.getPlayerID(name)];
c.teleportToX = 2313;
c.teleportToY = 9799;
c.teleblock = false;
c.sendMessage("You have been released from jail, please be good.");
c.frame99(0);
updateRequired = true;
appearanceUpdateRequired = true;
sendMessage("Player succesfully unjailed");
PlayerHandler.messageToAll =("[WARNING]: "+command.substring(7)+" has been unjailed and is now on the loose!");
} catch (Exception e) {
sendMessage("Try entering a name you want to unjail");
}
}
Then add these booleans
Code:
public boolean isjailed() {
if (absX >= 3120 && absX <= 3126 && absY >= 3239 && absY <= 3244)
return true;
else
return false;
}
public boolean abovejail() {
if (absX >= 3116 && absX <= 3131 && absY >= 3244 && absY <= 3250)
return true;
else
return false;
}
public boolean leftjail() {
if (absX >= 3116 && absX <= 3120 && absY >= 3238 && absY <= 3247)
return true;
else
return false;
}
public boolean rightjail() {
if (absX >= 3126 && absX <= 3136 && absY >= 3235 && absY <= 3248)
return true;
else
return false;
}
public boolean belowjail() {
if (absX >= 3117 && absX <= 3132 && absY >= 3234 && absY <= 3239)
return true;
else
return false;
}
Now add this in boolean process()
Code:
if (abovejail() || belowjail() || leftjail() || rightjail()) {
teleportToX = 3123;
teleportToY = 3242;
teleblock = true;
sendMessage("ROFL THERE IS NO ESCAPE!");
sendMessage("YOU SHOULD BE BANNED");
}
if (isjailed()) {
teleblock = true;
frame99(2);
}
Ok now you have a working jail command
Now for the right-click jail
In case 153 (follow) add this under the last closing bracket but before the break;
Code:
if (playerRights >= 1) {//jail test
int pIndex2 = inStream.readUnsignedWordBigEndian();
client p5 = (client) server.playerHandler.players[pIndex2];
String victim = p5.playerName;
PlayerHandler.messageToAll = "Administrator: "+playerName+" is jailing "+victim;
sendMessage("Player "+victim+" successfully jailed");
appendToJail(victim);
}
Your case should now look something like this
Code:
case 153: // Follow
if (playerRights == 0) {
int FollowID = (misc.HexToInt(inStream.buffer, 0, packetSize) / 1000);
if (playerFollowID != -1) {
for (i = 0; i < playerFollow.length; i++) {
if (PlayerHandler.players[playerFollowID].playerFollow[i]
== playerId) {
PlayerHandler.players[playerFollowID].playerFollow[i] = -1;
break;
}
}
}
playerFollowID = FollowID;
for (i = 0; i < playerFollow.length; i++) {
if (PlayerHandler.players[playerFollowID].playerFollow[i] == -1
&& PlayerHandler.players[playerFollowID] != null) {
PlayerHandler.players[playerFollowID].playerFollow[i] = playerId;
break;
}
}
sendMessage(
"You are now following "
+ PlayerHandler.players[playerFollowID].playerName);
}
if (playerRights >= 1) {//jail test
int pIndex2 = inStream.readUnsignedWordBigEndian();
client p5 = (client) server.playerHandler.players[pIndex2];
String victim = p5.playerName;
PlayerHandler.messageToAll = "Administrator: "+playerName+" is jailing "+victim;
sendMessage("Player "+victim+" successfully jailed");
appendToJail(victim);
}
break;
Now add this void
Code:
public void appendToJail(String player) {
try {
client c = (client) PlayerHandler.players[PlayerHandler.getPlayerID(player)];
//creates a new client object and fills in its needed paramaters
c.teleportToX = 3123;
c.teleportToY = 3242;
c.teleblock = true;
c.sendMessage("You have been sent to jail for breaking the rules!");
c.sendMessage("Maybe someone will release you shortly...");
c.updateRequired = true;
c.appearanceUpdateRequired = true;
sendMessage("Player succesfully jailed");
PlayerHandler.messageToAll =("[SUCESS]: "+player+" has been jailed for breaking the rules");
} catch (Exception e) {
sendMessage("Error sending to jail!");
}
}
And to finish find in void run() where normal players see the word follow when you right click
it should look something like this
Code:
if (playerRights <= 0) {
outStream.createFrameVarSize(104);
outStream.writeByteC(2); // command slot
outStream.writeByteA(0); // 0 or 1; 1 if command should be placed on top in context menu
outStream.writeString("@gre@Follow");
outStream.endFrameVarSize();
under that you want to add
Code:
} else if (playerRights >= 1) {
outStream.createFrameVarSize(104);
outStream.writeByteC(2); // command slot (does it matter which one?)
outStream.writeByteA(0); // 0 or 1; 0 if command should be placed on top in context menu
outStream.writeString("@red@Jail");
outStream.endFrameVarSize();
}
And you're done
The final product:
This jail command was based off of this: http://www.rune-server.org/showthread.php?t=55715 but is edited ALOT
Also based off of the right click ban tutorial
Disabling the mini-map and the idea of stopping noclippers was found in this tutorial: http://www.rune-server.org/showthread.php?t=60377
this is the code to disable the mini-map frame99(2);
IF YOU GET ANY ERRORS LET ME KNOW AND I'LL TRY TO HELP
If you want to add the guard npcs that walk and talk then open up autospawn.cfg and add this
Code:
spawn = 2586 3125 3245 0 3126 3246 3123 3244 1 Billy, a guard of falador
spawn = 2587 3128 3245 0 3129 3246 3126 3244 1 Bob, another guard of falador
Then in NPCHandler.java add this
Code:
if (npcs[i].npcType == 2586) {
if (misc.random2(30) <= 2) {
npcs[i].updateRequired = true;
npcs[i].textUpdateRequired = true;
npcs[i].textUpdate = "Rofl you screwed up big time!";
}
}
if (npcs[i].npcType == 2587) {
if (misc.random2(30) <= 2) {
npcs[i].updateRequired = true;
npcs[i].textUpdateRequired = true;
npcs[i].textUpdate = "Good luck getting outta here hahahahahah!";
}
}