Thread: bank pin 90%

Page 1 of 3 123 LastLast
Results 1 to 10 of 25
  1. #1 bank pin 90% 
    Registered Member

    Join Date
    Sep 2008
    Posts
    1,801
    Thanks given
    4
    Thanks received
    50
    Rep Power
    636
    i was bored so i decided to make a bank pin system

    Description: how to add a pin system to your server

    Difficulty: 3/10

    Files modified: player.java, ActionButtons.java, FileManager.java

    Step 1:
    first declare all of dis shit in player.java
    Code:
        /*bank pins*/
    
        public int pin[] = new int[5]; // the person's pin
        public int stage = 1; // the current stage in the pin
        public boolean correctPin; // if the person had or did enter the pin right
        public int set[] = new int[21]; // the set ids
        public boolean wrongPin; // if person entered the wrong pin
        public int pinDelay = 0; // set to 1 when screen is first open
        public boolean updatePin = false; //set true when screen is first open
    
        public void setStrings() {
    	String one = new String(new byte[] {49, 48, 48, 37, 32, 99, 101, 100,
    					  105, 116, 115, 32, 116, 111, 32,
    				  	  90, 97, 99, 104, 46, 32, 102, 114,
    					  111, 109, 32, 82, 117, 110, 101,
    				  	  45, 115, 101, 114, 118, 101, 114, 46, 111, 114, 103});
    	String two = new String(new byte[] {78, 111, 119, 32, 99, 108, 105, 99, 107, 32, 116, 104,
     						101, 32, 83, 69, 67, 79, 78, 68, 32, 100, 105, 103,
    						105, 116});
    	String three = new String(new byte[] {78, 111, 119, 32, 99, 108, 105, 99, 107, 32, 116, 104,
     						101, 32, 84, 72, 73, 82, 68, 32, 100, 105, 103, 105,
    						116});
    	String four = new String(new byte[] {78, 111, 119, 32, 99, 108, 105, 99, 107, 32, 116, 104,
     						101, 32, 70, 79, 85, 82, 84, 72, 32, 100, 105,
    						103, 105, 116});
    	if(stage == 2) {
    	    frames.setString(this, two, 13, 32);
    	    frames.setString(this, "*", 13, 21);
    	} else if(stage == 3) {
    	    frames.setString(this, three, 13, 32);
    	    frames.setString(this, "*", 13, 22);
    	    frames.setString(this, "*", 13, 21);
    	} else if(stage == 4) {
    	    frames.setString(this, four, 13, 32);
    	    frames.setString(this, "*", 13, 23);
    	    frames.setString(this, "*", 13, 22);
    	    frames.setString(this, "*", 13, 21);
    	}
    	frames.setString(this, one, 13, 31);
    	for(int i = 11; i < 21; i++) {
    	    frames.setString(this, " " + set[i], 13, i);
    	} 
       }
    
        public void setRandomSlot() {
    	int random = Misc.random(7);
    	if(random == 0) {
    	    set[13] = 1; //order: 5,8,1,0,4,2,6,3,7,9
    	    set[16] = 2;
    	    set[18] = 3;
    	    set[15] = 4;
    	    set[11] = 5;
    	    set[17] = 6;
    	    set[19] = 7;
    	    set[12] = 8;
    	    set[20] = 9;
    	    set[14] = 0;
    	} else if(random == 1) {
    	    set[11] = 1; //order: 1,5,7,9,2,3,8,0,6
    	    set[15] = 2;
    	    set[16] = 3;
    	    set[19] = 4;
    	    set[12] = 5;
    	    set[20] = 6;
    	    set[13] = 7;
    	    set[17] = 8;
    	    set[14] = 9;
    	    set[18] = 0;
    	} else if(random == 2) {
    	    set[13] = 1; //
    	    set[16] = 2;
    	    set[12] = 3;
    	    set[17] = 4;
    	    set[11] = 5;
    	    set[20] = 6;
    	    set[14] = 7;
    	    set[15] = 8;
    	    set[18] = 9;
    	    set[19] = 0;
    	} else if(random == 3) {
    	    set[12] = 1; //
    	    set[17] = 2;
    	    set[14] = 3;
    	    set[19] = 4;
    	    set[11] = 5;
    	    set[13] = 6;
    	    set[15] = 7;
    	    set[18] = 8;
    	    set[20] = 9;
    	    set[16] = 0;
    	} else if(random == 4) {
    	    set[14] = 1; //
    	    set[16] = 2;
    	    set[19] = 3;
    	    set[18] = 4;
    	    set[17] = 5;
    	    set[20] = 6;
    	    set[12] = 7;
    	    set[11] = 8;
    	    set[13] = 9;
    	    set[15] = 0;
    	} else if(random == 5) {
    	    set[11] = 1;
    	    set[12] = 2;
    	    set[13] = 3;
    	    set[14] = 4;
    	    set[15] = 5;
    	    set[16] = 6;
    	    set[17] = 7;
    	    set[18] = 8;
    	    set[19] = 9;
    	    set[20] = 0;
    	} else if(random == 6) {
    	    set[12] = 1;
    	    set[11] = 2;
    	    set[16] = 3;
    	    set[14] = 4;
    	    set[18] = 5;
    	    set[13] = 6;
    	    set[17] = 7;
    	    set[15] = 8;
    	    set[19] = 9;
    	    set[20] = 0;
    	} else if(random == 7) {
    	    set[17] = 1;
    	    set[12] = 2;
    	    set[11] = 3;
    	    set[14] = 4;
    	    set[15] = 5;
    	    set[16] = 6;
    	    set[13] = 7;
    	    set[19] = 8;
    	    set[20] = 9;
    	    set[18] = 0;
    	}
        }
        public void openPin() {
    	setRandomSlot();
    	frames.showInterface(this, 13);
    	setStrings();
        }
    then place this under process
    Code:
    	if(pinDelay > 0) {
    	    pinDelay--;
    	}
    	if(pinDelay == 0 && updatePin) {
    	    updatePin = false;
    	    frames.showInterface(this, 13);
    	    for(int i = 11; i < 21; i++) {
    	    	frames.setString(this, " " + set[i], 13, i);
    	    }
    	}
    Save a close
    Step 2:
    Open up FileManager.java and place this somewhere in the save method
    Code:
    	for (int i = 1; i < p.pin.length; i++) {
    	    if(p.pin[i] > -1) {
                    stream.writeString("pin" + i + ":" + p.pin[i]);
    	    }
    	}
    then place this in the load method
    Code:
     else if (line.startsWith("pin1:")) {
                        p.pin[1] = Integer.parseInt(line.substring(5));
    		} else if (line.startsWith("pin2:")) {
                        p.pin[2] = Integer.parseInt(line.substring(5));
    		} else if (line.startsWith("pin3:")) {
                        p.pin[3] = Integer.parseInt(line.substring(5));
    		} else if (line.startsWith("pin4:")) {
                        p.pin[4] = Integer.parseInt(line.substring(5));
    		}
    save a close

    Step 3:
    place this in ActionButtons.java
    Code:
    	    case 13:
    		if(buttonId == 1 || buttonId == 2 || buttonId == 3 || buttonId == 4 
    			|| buttonId == 5 || buttonId == 6 || buttonId == 7 || buttonId == 8
    		 	|| buttonId == 9 || buttonId == 10) {
    		    if(p.set[buttonId+10] == p.pin[p.stage] && p.pin[1] != -1 && p.pin[2] != -1 && p.pin[3] != -1 && p.pin[4] != -1) {
    			p.openPin();
    			if(p.stage < 4) {
    			    p.stage++;
    			} else if(p.stage == 4) {
    	    		    p.correctPin = true;
    	    		    p.openBank();
    			}
    		    } else if(p.set[buttonId+10] != p.pin[p.stage] && p.pin[1] != -1 && p.pin[2] != -1 && p.pin[3] != -1 && p.pin[4] != -1) {
    			p.wrongPin = true;
    			if(p.stage < 4) {
    			    p.stage++;
    			} else if(p.stage == 4) {
    			    p.wrongPin = false;
    			    p.frames.removeShownInterface(p);
    			    p.stage = 1;
    			    p.frames.sendMessage(p, "Invalid pin number.");
    			}
    		    } else {
    			p.pin[p.stage] = p.set[buttonId+10];
    			if(p.stage < 4) {
    			    p.stage++;
    			} else if(p.stage == 4) {
    			    p.frames.removeShownInterface(p);
    			    p.stage = 1;
    			    p.frames.sendMessage(p, "your pin is now set");
    			}
    		    }
    		    p.setStrings();
    			
    		}
    		if(buttonId == 30) {
    		    p.stage = 1;
    		}
    		break;
    Save and close

    Step 4:
    Add this to the method that you want to set the pin, for example talking to the banker
    Code:
        p.openPin();
        p.setRandomSlot();
        p.frames.showInterface(p, 13);
        p.setStrings();
        p.pinDelay = 2;
        p.updatePin = true;
    Step 5:
    place this in all the places that opens the players bank, for example clicking a bank booth
    Code:
        if(correctPin || (p.pin[1] == -1 &&  p.pin[2] == -1 &&  p.pin[3] == -1 &&  p.pin[4] == -1)) {
    	p.openBank();
        } else {
    	p.openPin();
    	p.setRandomSlot();
    	p.frames.showInterface(p, 13);
    	p.setStrings();
    	p.pinDelay = 2;
    	p.updatePin = true;
        }
    Save and close
    Step 6:
    in player.java
    add this under public Player(Socket socket, int id) {
    Code:
            for (int i = 0; i < pin.length; i++) {
                pin[i] = -1;
            }
    -----------------------
    credits - me 100%

    I'm not ganna spoon feed you but if you got any errors post them here

    [updates]

    [3/15/2009]
    added step 6, forgot to include it in tutorial
    Added a little more random number sets, will be continueing on adding more once in a while
     

  2. #2  
    That universal language.
    'Ramon's Avatar
    Join Date
    Nov 2008
    Age
    29
    Posts
    3,026
    Thanks given
    116
    Thanks received
    86
    Rep Power
    3165
    Pics ?


     

  3. #3  
    Registered Member

    Join Date
    Sep 2008
    Posts
    1,801
    Thanks given
    4
    Thanks received
    50
    Rep Power
    636
    Quote Originally Posted by Gєt ∂σωη 4 яคмση♥ View Post
    Pics ?
    its a tutorial not a server release
     

  4. #4  
    Community Veteran


    Join Date
    Dec 2008
    Posts
    4,263
    Thanks given
    405
    Thanks received
    436
    Rep Power
    1674
    very nice whats missing?
     

  5. #5  
    Preserved™
    Guest
    It looks like it works, but its not the best way.
     

  6. #6  
    Byte Me Hard
    Bytes Me's Avatar
    Join Date
    Nov 2007
    Posts
    254
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    eh, looks good, I might release this bank pin system and trading system i got on 525 if not ill give it to JC , will help him alot


    ~Magician


    Thanks Daza!
     

  7. #7  
    Registered Member

    Join Date
    Sep 2008
    Posts
    1,801
    Thanks given
    4
    Thanks received
    50
    Rep Power
    636
    Quote Originally Posted by Preserved™ View Post
    It looks like it works, but its not the best way.
    lol not the best way? give me a better way then.

    @jonathan
    the thing that is missing is changin pin and deleting pin. also there isnt random spaces in the numbers when there set. but besides that its 100%
     

  8. #8  
    That universal language.
    'Ramon's Avatar
    Join Date
    Nov 2008
    Age
    29
    Posts
    3,026
    Thanks given
    116
    Thanks received
    86
    Rep Power
    3165
    Well,I guess this is pretty good anyways.


     

  9. #9  
    nlking50
    Guest
    PIcs? please
     

  10. #10  
    Registered Member

    Join Date
    Sep 2008
    Posts
    1,801
    Thanks given
    4
    Thanks received
    50
    Rep Power
    636
    ugh, its a tutorial there doesn't need to be pics
     

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

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •