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.
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.