PDA

View Full Version : 95% bank pin



hellman2741
March 19th, 2011, 08:33
I've only seen this on one server (besides my own. Probably on others, but I've only seen on one)
So, I thought I'd put it on my server.
And seeing as if I said something like "one of the only servers with a bank pin system" to advertise my server, other coders could easily make one.
So, easier just to say I was one of the first to make a tutorial on it ;)

This will add bank pins to players accounts in case they get hacked.
Quite easy, just, if you have a bank pin. You have to type ::bankpin (pin) to use it. You can still open a bank without, but it'll give you a message warning you to get a bank pin to be more secure.


-----------------------------------------------------------------
Let's get started.
First, open up player.java and just below
public final class Player extends Entity {
add
public String bankPin;

Then search "rights" and you'll see
public int rights = 0;

Below that, add
public int haspin = 0;
public int typedpin = 0;
Close player.java

Next, open commandpackethandler and add this in

if(cmd[0].equals("delpin")) {
if(cmd[1].equals(""+player.bankPin+"")) {
player.haspin = 0;
player.sm("You have deleted your bank pin, do ::setpin to make a new one");
} else {
player.sm("That is not the correct pin");
player.sm("The command is '::delpin (pin)'");
}
}
if(cmd[0].equals("changepin")) {
String setPin = cmd[2];
String oldPin = cmd[1];
String name = "";
for(int i = 2; i < cmd.length; i++) {
name += cmd[1];
name += " ";
}
if (cmd[1].equals(""+player.bankPin+"")) {
player.bankPin = ""+setPin+"";
player.sm("Your new pin is "+setPin+". Write it down!");
XStreamPlayerLoader.punish.writeTo(player.getUsern ame() + " has changed their bankpin from "+oldPin+" to "+setPin+"/"+ player.getSession().getRemoteAddress(), "data/text/pinchanges");
} else {
player.sm("Correct sytax is ::changepass (oldpass) (newpass)");
player.sm("If you have forgotten your bankpin, please talk to <img=1>Worldofwar or <img=1>Cody");
}
}
if(cmd[0].equals("setpin")) {
if(player.haspin == 0) {
String setPin = cmd[1];
String name = "";
for(int i = 2; i < cmd.length; i++) {
name += cmd[1];
name += " ";
}
player.bankPin = ""+setPin+"";
player.sm("Your new bank pin is "+setPin+". Write it down somewhere!");
player.haspin = 1;
} else {
player.sm("You already have a bank pin");
}
}

add the same into commandspackethandler, just add "::" infront of the commands... (or add . infront of them and put all in commandspackethandler if you're using a dotsystem)

now, still in commandpackethandler, find your bank command (command that opens your bank) and replace it with this
if (cmd[0].equals("bank")) {
if (player.haspin == 0) {
player.getBank().openBank();
player.sm("You've opened your bank.");
player.sm("<col=FF0000>For extra security, please do ::setpin (pin) to set a bank pin");
} else if(player.haspin == 1 && player.typedpin == 0) {
player.sm("Please enter your pin by doing ::bankpin (pin) first");
} else if (player.haspin == 1 && player.typedpin == 1) {
player.getBank().openBank();
player.sm("You've opened your bank.");
}
}
You can also add it to your commandspackethandler if you want a command for a normal player/mod to be able to use it, but you'll have to add in the wilderness variables and stuff.

Now, open up your object1packethandler, objectpackethandler, npcpackethandler, and summonpackethandler.

In all of them, search "openbank" and replace the banking method with this
case ####://
if (player.haspin == 0) {
player.getBank().openBank();
player.sm("You've opened your bank.");
player.sm("<col=FF0000>For extra security, please do ::setpin (pin) to set a bank pin");
} else if(player.haspin == 1 && player.typedpin == 0) {
player.sm("Please enter your pin by doing ::bankpin (pin) first");
} else if (player.haspin == 1 && player.typedpin == 1) {
player.getBank().openBank();
player.sm("You've opened your bank.");
}
break;

You may have to change "player" to just "p" for some of the files.

Finally, in actionsender, search for "starter" and add
player.typedpin = 0; under it and the
} else {

And that's it. You have a 95% bank pin

People set a pin by doing ::setpin (pin)
Change their pin by doing ::changepin (oldpin) (newpin)
delete their pin by doing ::delpin (pin)
and finally, they enter their pins by doing ::bankpin (pin)

Hope you liked.

Acrylix
March 20th, 2011, 02:20
Does this have the interface when opening the bank?

apache ah64
March 20th, 2011, 09:58
No it dont thats why it suck i go add interface -.- just let some configs at a number with ints like pin1 pin2 pin3 pin4 and done..

Acrylix
March 20th, 2011, 10:51
Their called variables not ints.

Lukedawesome
March 20th, 2011, 13:42
this is exactly what near reality uses...nice i guess, but almost pointless seeing that hardly anyone gets hacked in rsps

vanweele
March 20th, 2011, 18:34
what if they got hacked and someone typed those commands to change it or w/e?

SiniSoul
March 20th, 2011, 18:35
Why is the class final xD?

hellman2741
March 20th, 2011, 19:36
Does this have the interface when opening the bank?

Unfortunately, no. I don't think I'd be able to do that. But, I guess I might as well try when I get home ;)


what if they got hacked and someone typed those commands to change it or w/e?

They would have to know the old pin to change it.
And, if you look in the commandpackethandler and commandspackethandler codes.
I have set it up to actually write to a file when someone changes their pin. It will also tell me the ip of the person who changed the pin. So, I can tell who it was ;)

champ
March 20th, 2011, 19:37
wud have been good if u used the enter pin thing..rather than command :p

tedhead2
March 20th, 2011, 23:03
umm.... it wouldn't be that hard to make it so to change the pin you had to do like "::changepin [old pin] [new pin]"

Acrylix
March 20th, 2011, 23:14
He's done that...

hellman2741
March 21st, 2011, 08:01
umm.... it wouldn't be that hard to make it so to change the pin you had to do like "::changepin [old pin] [new pin]"

Tip: Read the code before posting... It already is like that.
Always was tbh

apache ah64
April 1st, 2011, 19:01
LOL, i made it done with real rs bank system on 562 ^^ you able to change, set, delete etc... xD

David
April 1st, 2011, 20:04
I wouldn't call some commands that add a bank pin "95% bank pin". It's only a real bank pin when you do it via the interface.

SiniSoul
April 1st, 2011, 20:06
This be ugly. I suggest you read more about teh javaz.



public final class Player extends Entity {


What the fuck to that.



public String bankPin;


Strings are bad, use a hash. Google String Hash and go from there.

One I use:


long idhash = 0;
int len = id.length();
for (int i = 0; i < len; i++) {
idhash = 31 * idhash + id.charAt(i);
}
return idhash;


Compare hashes generated from the player entering the bank pin, be aware 2 answers may be possible for one hash.

Please use OOP programming and add this to a "Banking" class as to make it easier and less chaotic to edit/implement.



if(cmd[0].equals("delpin")) {
if(cmd[1].equals(""+player.bankPin+"")) {
player.haspin = 0;
player.sm("You have deleted your bank pin, do ::setpin to make a new one");
} else {
player.sm("That is not the correct pin");
player.sm("The command is '::delpin (pin)'");
}
}
if(cmd[0].equals("changepin")) {
String setPin = cmd[2];
String oldPin = cmd[1];
String name = "";
for(int i = 2; i < cmd.length; i++) {
name += cmd[1];
name += " ";
}
if (cmd[1].equals(""+player.bankPin+"")) {
player.bankPin = ""+setPin+"";
player.sm("Your new pin is "+setPin+". Write it down!");
XStreamPlayerLoader.punish.writeTo(player.getUsern ame() + " has changed their bankpin from "+oldPin+" to "+setPin+"/"+ player.getSession().getRemoteAddress(), "data/text/pinchanges");
} else {
player.sm("Correct sytax is ::changepass (oldpass) (newpass)");
player.sm("If you have forgotten your bankpin, please talk to <img=1>Worldofwar or <img=1>Cody");
}
}
if(cmd[0].equals("setpin")) {
if(player.haspin == 0) {
String setPin = cmd[1];
String name = "";
for(int i = 2; i < cmd.length; i++) {
name += cmd[1];
name += " ";
}
player.bankPin = ""+setPin+"";
player.sm("Your new bank pin is "+setPin+". Write it down somewhere!");
player.haspin = 1;
} else {
player.sm("You already have a bank pin");
}
}


Use methods. This is just gross.

Also, try and use the interface and make it so that all the buttons are handled.

I would actually personally call this 10% bank pins, and that is being generous.

titandino
April 14th, 2011, 05:14
It truly isn't 95%... I added it via interface to my project edu project.

jefferson
April 18th, 2011, 21:12
Bank pin its easy.. lol..

Nouish
June 1st, 2011, 13:38
if(cmd[1].equals(""+player.bankPin+"")) {

You declared bankPin as java.lang.String, hence you can skip the quotes;


if(cmd[1].equals(player.bankPin)) {