show us the code
|
i added an object in my server and made it so that when you click on it you get an item,
but i need it to only give me the item once, like if i click it i get the item, but if i click it again it says something like "You allready got one"
any idea? 317 pi base
Im sure you can make a variable. and a player save that increases to 1 and make the object when u click it increase the variable and check if the variable is = 1 and if it is you cant click it any more.
here is my code
Code:case 10666: c.objectDistance = 2; c.stopMovement(); c.sendMessage("You recieve your christmas gift!"); c.getItems().addItem(995, 25000000); c.getItems().addItem(6862, 1); break;
just make a boolean in player class public boolean receivedGift; then under the code for object replace it with
case 10666:
c.objectDistance = 2;
c.stopMovement();
if (c.receivedGift) {
c.sendMessage("You have already received a gift!");
return;
}
c.sendMessage("You receive your christmas gift!");
c.getItems().addItem(995, 25000000);
c.getItems().addItem(6862, 1);
c.receivedGift = true;
break;
ofc you would have to save the boolean in playersave
did everything but just cant get it to save here is my code
under the other ones... any idea?Code:} else if (token.equals("receivedGift")) { p.receivedGift = Boolean.parseBoolean(token2);
you gotta also write a character save file?
characterfile.write("receivedGift = ", 0, 15);
characterfile.write(Integer.toString(p.receivedGif t), 0, Integer.toString(p.receivedGift).length());
characterfile.newLine();
lol idk if u put that in to see if im retarded the characterfile.write("receivedGift = ", 0, 15);
characterfile.write(Integer.toString(p.receivedGif t), 0, Integer.toString(p.receivedGift).length());
characterfile.newLine();
lmao seriously i saw it when i went back to edit it theres no space 0.0 so i just left it cuz i cba
got this tho
Code:src\server\model\players\PlayerSave.java:585: error: no suitable method found fo r toString(boolean) characterfile.write(Integer.toString(p.receivedGift), 0, Integer.toString(p.receivedGift).length()); ^ method Integer.toString() is not applicable (actual and formal argument lists differ in length) method Integer.toString(int) is not applicable (actual argument boolean cannot be converted to int by method invocation c onversion) method Integer.toString(int,int) is not applicable (actual and formal argument lists differ in length) src\server\model\players\PlayerSave.java:585: error: no suitable method found fo r toString(boolean) characterfile.write(Integer.toString(p.receivedGift), 0, Integer.toString(p.receivedGift).length()); ^ method Integer.toString() is not applicable (actual and formal argument lists differ in length) method Integer.toString(int) is not applicable (actual argument boolean cannot be converted to int by method invocation c onversion) method Integer.toString(int,int) is not applicable (actual and formal argument lists differ in length) Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 2 errors Press any key to continue . . .
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |