Thread: [PI] Simple jail system.

Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1 [PI] Simple jail system. 
    Registered Member
    Join Date
    Aug 2014
    Posts
    101
    Thanks given
    8
    Thanks received
    1
    Rep Power
    0
    Okay, so today we will be adding a jail system for Project Insanity. If you get any errors or it doesn't work, feel free to post down below. Okay lets get started :

    Step 1

    Go to your '''Client.Java" Folder and search for :

    Code:
    public int lowMemoryVersion = 0;
    Under that add :
    Code:
    public int Jail = 0;
    Step 2 :
    Go to your Player.java folder, and search for :

    Code:
    lastNpcAttacked = 0
    Somewhere there add :
    Code:
    Jail = 0,

    Step 3 :

    Now to to your commands.java, and add these somewhere :

    Code:
    if(playerCommand.startsWith("jail") && c.playerRights >= 2) {
    				try {
    					String playerToBan = playerCommand.substring(5);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					    c2.teleportToX = 2094;
                            c2.teleportToY = 4427;
    			c2.Jail = 1;
    								c2.sendMessage("You have been jailed by "+c.playerName+"");
    								c.sendMessage("Successfully Jailed "+c2.playerName+".");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    			if(playerCommand.startsWith("unjail") && c.playerRights >= 2) {
    				try {
    					String playerToBan = playerCommand.substring(7);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					    c2.teleportToX = 3089;
                            c2.teleportToY = 3491;
    						c2.Jail = 0;
    								c2.sendMessage("You have been unjailed by "+c.playerName+"");
    								c.sendMessage("Successfully unjailed "+c2.playerName+".");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}

    Step 4 :
    Go to your PlayerAssistant.java and search for :
    Code:
    public void startTeleport(int x, int y, int height, String teleportType) {
    Under that add
    Code:
    if (c.Jail == 1) {
    		c.sendMessage("You Cannot teleport out of jail!");
    		return;
    	}
    Step 5 :
    Go to your Playersave.java and search for :
    Code:
    p.heightLevel = Integer.parseInt(token2);
    Under that add :

    Code:
    } else if (token.equals("character-Jail")) {
    						p.Jail = Integer.parseInt(token2);

    Step 6 :
    Now search for :
    Code:
    p.skullTimer = Integer.parseInt(token2);
    Under that add :

    Code:
    } else if (token.equals("Jail")) {
    						p.Jail = Integer.parseInt(token2);

    Step 7 :
    Search for :
    Code:
    .toString(p.skullTimer).length());
    Under that add :


    Code:
    characterfile.newLine();
    			characterfile.write("Jail = ", 0, 6);
    			characterfile.write(Integer.toString(p.Jail), 0, Integer
    					.toString(p.Jail).length());


    Now you are done! Congratulations.
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Dec 2012
    Posts
    2,999
    Thanks given
    894
    Thanks received
    921
    Rep Power
    2555
    Instead of using an Integer to determine if the player is jailed or not, use boolean
    Attached image
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Aug 2014
    Posts
    101
    Thanks given
    8
    Thanks received
    1
    Rep Power
    0
    Quote Originally Posted by Kaleem View Post
    Instead of using an Integer to determine if the player is jailed or not, use boolean
    Does it matter? It still works.
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Dec 2012
    Posts
    2,999
    Thanks given
    894
    Thanks received
    921
    Rep Power
    2555
    Quote Originally Posted by Jesse 1422 View Post
    Does it matter? It still works.
    Yes, it does matter. The attitude of "it works, let's use it" is a terrible one and the majority of rune-server have it, instead you should optimize your code to the best of your ability
    Attached image
    Reply With Quote  
     

  5. Thankful user:


  6. #5  
    Software Developer

    Tyrant's Avatar
    Join Date
    Jul 2013
    Age
    24
    Posts
    1,562
    Thanks given
    678
    Thanks received
    423
    Rep Power
    1060
    Quote Originally Posted by Jesse 1422 View Post
    Does it matter? It still works.
    Use [code ] [/code ] (No spaces on specs) instand of quote or whateverso.

    Beside that, doesn't mean that if it works its done in the correct way, it could be efficient sometimes and even wrong and could lead to bugs, glitches even dupes (depends on what).
    Reply With Quote  
     

  7. #6  
    Registered Member
    Join Date
    Aug 2014
    Posts
    101
    Thanks given
    8
    Thanks received
    1
    Rep Power
    0
    Quote Originally Posted by Kaleem View Post
    Yes, it does matter. The attitude of "it works, let's use it" is a terrible one and the majority of rune-server have it, instead you should optimize your code to the best of your ability
    .....? Can you even read the title? It says "simple jail system", So basically that means it doesn't need to be "100% professional", just normal tutorial.
    Reply With Quote  
     

  8. #7  
    Registered Member

    Join Date
    Dec 2012
    Posts
    2,999
    Thanks given
    894
    Thanks received
    921
    Rep Power
    2555
    Quote Originally Posted by Jesse 1422 View Post
    .....? Can you even read the title? It says "simple jail system", So basically that means it doesn't need to be "100% professional", just normal tutorial.
    Using a boolean in place of a integer when you should isn't professional, it's the basics of Java
    Attached image
    Reply With Quote  
     

  9. Thankful user:


  10. #8  
    ¯\_(ツ)_/¯


    Join Date
    Jul 2014
    Posts
    1,803
    Thanks given
    928
    Thanks received
    550
    Rep Power
    299
    use code tags.

    also why wouldn't you just make it so that if they're in the jail area they can't do anything...
    this is pretty pointless and made terribly.


    also use a Boolean.


    Boolean.parseBoolean.
    Reply With Quote  
     

  11. #9  
    Registered Member
    Join Date
    Aug 2014
    Posts
    101
    Thanks given
    8
    Thanks received
    1
    Rep Power
    0
    Quote Originally Posted by Berserk View Post
    use code tags.

    also why wouldn't you just make it so that if they're in the jail area they can't do anything...
    this is pretty pointless and made terribly.


    also use a Boolean.


    Boolean.parseBoolean.
    Obv If you want to add some things to your jail area, feel free to do so. I'm not going to do that because it would be pointless.
    Reply With Quote  
     

  12. #10  
    ¯\_(ツ)_/¯


    Join Date
    Jul 2014
    Posts
    1,803
    Thanks given
    928
    Thanks received
    550
    Rep Power
    299
    you didn't read my post correctly.

    I said, instead of having an integer for checking if the player is in jail, just make a Boolean like
    Code:
    public boolean playerIsInJail() {
    return (absX >= ### && absY >= ### && absX <= ### && absY <= ###);
    }
    and then you go to the places that check if the integer is set to where the player is in jail you add
    Code:
    if (playerIsInJail()) {
    return;
    }
    Reply With Quote  
     

  13. Thankful user:


Page 1 of 3 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. PI Simple Point System.
    By Griffon in forum Snippets
    Replies: 9
    Last Post: 02-25-2013, 04:36 PM
  2. [PI] Simple KillStreak System With Rewards
    By .Optimum in forum Snippets
    Replies: 20
    Last Post: 08-12-2012, 09:21 PM
  3. [PI] Simple Email System
    By Freezia in forum Snippets
    Replies: 46
    Last Post: 02-19-2012, 06:11 PM
  4. [PI] New jail system [TUTORIAL]
    By iPhisher™ in forum Tutorials
    Replies: 21
    Last Post: 07-30-2011, 10:27 AM
  5. PI my Jailing system
    By SeekScape in forum Help
    Replies: 0
    Last Post: 01-21-2011, 06:25 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •