Pics ?
|
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
then place this under processCode:/*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(); }
Save a closeCode: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); } }
Step 2:
Open up FileManager.java and place this somewhere in the save method
then place this in the load methodCode:for (int i = 1; i < p.pin.length; i++) { if(p.pin[i] > -1) { stream.writeString("pin" + i + ":" + p.pin[i]); } }
save a closeCode: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)); }
Step 3:
place this in ActionButtons.java
Save and closeCode: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;
Step 4:
Add this to the method that you want to set the pin, for example talking to the banker
Step 5:Code:p.openPin(); p.setRandomSlot(); p.frames.showInterface(p, 13); p.setStrings(); p.pinDelay = 2; p.updatePin = true;
place this in all the places that opens the players bank, for example clicking a bank booth
Save and closeCode: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; }
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
Pics ?
very nice whats missing?
It looks like it works, but its not the best way.
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
Well,I guess this is pretty good anyways.
PIcs? please
ugh, its a tutorial there doesn't need to be pics
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |