Thread: 1 item at a time...

Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1 1 item at a time... 
    Registered Member Deathbyu's Avatar
    Join Date
    Aug 2010
    Posts
    359
    Thanks given
    17
    Thanks received
    7
    Rep Power
    1
    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



    Spoiler for I was such a noob...:
    Reply With Quote  
     

  2. #2  
    Super Donator

    Batukka's Avatar
    Join Date
    Oct 2011
    Posts
    2,433
    Thanks given
    86
    Thanks received
    342
    Rep Power
    496
    show us the code
    Reply With Quote  
     

  3. #3  
    Kacey
    I Am Kacey's Avatar
    Join Date
    May 2011
    Posts
    738
    Thanks given
    243
    Thanks received
    56
    Rep Power
    19
    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.
    Nothing But Love
    Attached image
    Reply With Quote  
     

  4. #4  
    Registered Member Deathbyu's Avatar
    Join Date
    Aug 2010
    Posts
    359
    Thanks given
    17
    Thanks received
    7
    Rep Power
    1
    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;



    Spoiler for I was such a noob...:
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Mar 2011
    Posts
    4,062
    Thanks given
    194
    Thanks received
    689
    Rep Power
    0
    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
    Reply With Quote  
     

  6. #6  
    Registered Member Deathbyu's Avatar
    Join Date
    Aug 2010
    Posts
    359
    Thanks given
    17
    Thanks received
    7
    Rep Power
    1
    did everything but just cant get it to save here is my code
    Code:
    					} else if (token.equals("receivedGift")) {
    						p.receivedGift = Boolean.parseBoolean(token2);
    under the other ones... any idea?



    Spoiler for I was such a noob...:
    Reply With Quote  
     

  7. #7  
    Kacey
    I Am Kacey's Avatar
    Join Date
    May 2011
    Posts
    738
    Thanks given
    243
    Thanks received
    56
    Rep Power
    19
    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();
    Nothing But Love
    Attached image
    Reply With Quote  
     

  8. #8  
    Registered Member Deathbyu's Avatar
    Join Date
    Aug 2010
    Posts
    359
    Thanks given
    17
    Thanks received
    7
    Rep Power
    1
    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();



    Spoiler for I was such a noob...:
    Reply With Quote  
     

  9. #9  
    Kacey
    I Am Kacey's Avatar
    Join Date
    May 2011
    Posts
    738
    Thanks given
    243
    Thanks received
    56
    Rep Power
    19
    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
    Nothing But Love
    Attached image
    Reply With Quote  
     

  10. #10  
    Registered Member Deathbyu's Avatar
    Join Date
    Aug 2010
    Posts
    359
    Thanks given
    17
    Thanks received
    7
    Rep Power
    1
    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 . . .



    Spoiler for I was such a noob...:
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [PI] Item Degrading Within a Time Limit.
    By Rockstar Jax in forum Help
    Replies: 5
    Last Post: 03-13-2013, 01:48 AM
  2. Replies: 18
    Last Post: 08-15-2010, 09:16 AM
  3. randrom item wen login first time
    By Vsall in forum Requests
    Replies: 4
    Last Post: 02-27-2010, 09:10 AM
  4. Client freezes each time I add an item over 7995
    By Mr. Gangster in forum Help
    Replies: 3
    Last Post: 09-04-2009, 07:48 AM
  5. Replies: 10
    Last Post: 03-15-2009, 12:08 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •