Strife-Scape
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Strife-Scape Forums
 
HomeLatest imagesSearchRegisterLog in
RATE THE SERVER AT http://runelocus.com/forums/showthread.php?p=228636#post228636 ..MORE PLAYERS THE BETTER!

 

 New Jail Coding!

Go down 
2 posters
AuthorMessage
i pked u i
Admin



Posts : 168
Points : 5789
Reputation : 17
Join date : 2009-05-12
Age : 33
Location : Germany FTW

New Jail Coding! Empty
PostSubject: New Jail Coding!   New Jail Coding! EmptyMon May 25, 2009 11:08 am

If needed change all
Code:
sendMessage
to
Code:
c.sM


Search in your client.java for...


Code:
command.equalsIgnoreCase


Directly one line above that, add this code to get to the jail.

Code:

    if (command.startsWith("funjail")) {
            if (teleblock == true) {
            sendMessage("A magical force stops you from teleporting.");
        } else {
            teleportToX = 2528;
            teleportToY = 3371;
            sendMessage("You teleport to jail, laugh at the detainee's!");
        }
    }

This will teleport you to the jail. So now the next step is adding the "Jail" command. This will enable you to jail whoever you want into a confined area.

Now the "Jail" command will go one line below the bracket or } in the "Funjail" command.

Add this...

Code:

    if (command.startsWith("jail") && command.length() > 5 && playerRights >= 1) {
            String name = command.substring(5);
            PlayerHandler.messageToAll = "Staff Member " + playerName + " is jailing "
                    + name;
        sendMessage("Succesfully jailed " + name);
            client c = (client) PlayerHandler.players[PlayerHandler.getPlayerID(name)];
              c.teleportToX = 2528;
              c.teleportToY = 3375;
            c.teleblock = true;
              c.sendMessage("You have been sent to jail by a Staff Member!");
              c.sendMessage("A Staff Member will get you out when they feel you are ready.");
            c.teleblock = true;
            updateRequired = true;
            appearanceUpdateRequired = true;
            BufferedWriter bw = null;

            try { 

                bw = new BufferedWriter(new FileWriter("JailLogs.txt", true));
                bw.write(
                        "[---" + name + " was jailed by " + playerName
                        + "---]");
                bw.newLine();
                bw.flush();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            } finally {
                if (bw != null) {
                    try {
                        bw.close();
                    } catch (IOException ioe2) {
                        sendMessage("Error jailing user.");
                    }
                }
            }
        }


You need to add into your files a text document called "JailLogs" or it won't work.

What that code will do is when you type ::jail username, it will send them into the cages. It will also add the log to the JailLogs.txt list. Shows you who has jailed whom.

Now we need to be able to reverse that command so that they are not stuck in the jail forever. Add this below the last bracket on the "jail" command.

Code:

      else if (command.startsWith("unjail") && command.length() > 7 && playerRights >= 1) {
            String name = command.substring(7);
            PlayerHandler.messageToAll = "Staff Member " + playerName + " is unjailing "
                    + name;
        sendMessage("Succesfully unjailed " + name);
            client c = (client) PlayerHandler.players[PlayerHandler.getPlayerID(name)];
              c.teleportToX = 3087;
              c.teleportToY = 3491;
            c.teleblock = false;
              c.sendMessage("That was your last warning, Next time you are banned.");
            updateRequired = true;
            appearanceUpdateRequired = true;
    }

Now that you have that in, we have all the commands needed for this tutorial! Step one is completed! Now moving on to the next step.


Step Two: Making Jail an Actual Jail

Alright, this part is pretty simple.

Search...

Code:

Process()


And inside that method, add this code in.

Code:

if ((IsInJail(absX, absY) == true)) {
        frame99(2);
        teleblock = true;
        }
if ((IsInJail(absX, absY) == false)) {
        frame99(0);
        }

Now we need to add a boolean. Search for...

Code:

public boolean IsInWilderness

Right above that, add this code.

Code:

public boolean IsInJail(int coordX, int coordY) {
    //if ((absY == 0) && (absY == 0) && (absX == 0) && (absX == 0)) {
        if ((absX >= 2523 && absX <= 2533 && absY >=3373  && absY <=3378)) {
            return true;

        } else {
            return false;
        }
    }

Now, we have the whole jail aspect complete, we just need to touch up on the surrounding areas. End of step 2.

Step Three: Making the Area NonWild

Your area is probably in the wilde, and you really do not want people the detainee. So here is what you need to add.

Search...
Code:

public boolean nonWild

You need to add this code below it.

Code:

|| (absX >= 2520 && absX <= 2535 && absY >= 3367 && absY <= 3379);

That will make the area a safe zone. (Note: Some servers use a nonWild pattern of North West to South East, while mine uses South West to North East. If this is the case, and your jail is still in wild, You will need to edit it to do so.) Done with Step Three!

Step Four: Making a right-click Jail

Search for

Code:

case 153:


Replace EVERYTHING in case 153 with this..

Code:

case 153: //Right-click jaling.
if (playerRights >= 2)
{
int pIndex2 = inStream.readUnsignedWordBigEndian();
client p5 = (client) server.playerHandler.players[pIndex2];
client c = (client) PlayerHandler.players[PlayerHandler.getPlayerID(p5.playerName)];
PlayerHandler.messageToAll = ""+playerName+" Jailed "+p5.playerName;
c.teleportToX = 2528;
c.teleportToY = 3374;
c.teleblock = true;
c.frame99(2);
c.savemoreinfo();
c.sendMessage("You have been thrown in jail for breaking the rules!");
p5.frame99(2);
}
break;

then, look for something like this

Code:

if (playerRights >= 0) {
outStream.createFrameVarSize(104);
outStream.writeByteC(3); // command slot (does it matter which one?)
outStream.writeByteA(1); // 0 or 1; 1 if command should be placed on top in context menu
outStream.writeString("@red@Attack");
outStream.endFrameVarSize();d
IsInWilderness = true;
}
just search

under it add this

Code:
if (playerRights >= 1) {
outStream.createFrameVarSize(104);
outStream.writeByteC(2);
outStream.writeByteA(0);
outStream.writeString("@whi@Jail");
outStream.endFrameVarSize();
}
Back to top Go down
call me dad
Mod
call me dad


Posts : 98
Points : 5686
Reputation : 26
Join date : 2009-05-10
Age : 30
Location : where ever

New Jail Coding! Empty
PostSubject: Re: New Jail Coding!   New Jail Coding! EmptyMon May 25, 2009 11:11 am

good work Smile
Back to top Go down
i pked u i
Admin



Posts : 168
Points : 5789
Reputation : 17
Join date : 2009-05-12
Age : 33
Location : Germany FTW

New Jail Coding! Empty
PostSubject: Re: New Jail Coding!   New Jail Coding! EmptyMon May 25, 2009 11:12 am

well 85% to delta
and 15% to me to change coords and crap Smile
Back to top Go down
Sponsored content





New Jail Coding! Empty
PostSubject: Re: New Jail Coding!   New Jail Coding! Empty

Back to top Go down
 
New Jail Coding!
Back to top 
Page 1 of 1
 Similar topics
-
» New Jail Coding?
» Coding for Server

Permissions in this forum:You cannot reply to topics in this forum
Strife-Scape :: Suggestions-
Jump to: