Thread: adding limit to stardust

Results 1 to 5 of 5
  1. #1 adding limit to stardust 
    Registered Member
    Join Date
    Nov 2012
    Posts
    525
    Thanks given
    12
    Thanks received
    49
    Rep Power
    26
    im trying to add a limit to how much star dust a player can have.

    Limit im setting it to is 400, including x amount in inventory and bank combined, with my code it only does the inventory check correctly and doesnt check bank at all, heres my code:

    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  2. #2  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,545
    Thanks given
    638
    Thanks received
    634
    Rep Power
    334
    Quote Originally Posted by khayam View Post
    im trying to add a limit to how much star dust a player can have.

    Limit im setting it to is 400, including x amount in inventory and bank combined, with my code it only does the inventory check correctly and doesnt check bank at all, heres my code:

    [Only registered and activated users can see links. ]
    Post your bank's getAmountOf method. I believe it's different from Inventory on Matrix because Bank doesn't inherit ItemContainer compared to Inventory.
    Project thread
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Nov 2012
    Posts
    525
    Thanks given
    12
    Thanks received
    49
    Rep Power
    26
    i guess now that i looked into that method its empty lmfao.
    Spoiler for bank.java:
    public int getAmountOf(int i) {
    // TODO Auto-generated method stub
    return 0;
    }


    holy shit i cant believe i didnt even think about looking into that, i feel like an idiot now.

    Well since it was empty i created a method for it, if anyone else runs into this problem like me it will hopefully help them out:

    Spoiler for bank.java:
    public int getAmountOf(int itemId) {
    for (int i = 0; i < bankTabs.length; i++) {
    for (Item item : bankTabs[i]) {
    if (item == null)
    continue;
    if (item.getId() == itemId)
    return item.getAmount();
    }
    }
    return 0;
    }
    Last edited by khayam; 11-09-2020 at 07:27 AM. Reason: figured out a method for getAmountOf
    Reply With Quote  
     

  4. #4  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,545
    Thanks given
    638
    Thanks received
    634
    Rep Power
    334
    Quote Originally Posted by khayam View Post
    i guess now that i looked into that method its empty lmfao.
    Spoiler for bank.java:
    public int getAmountOf(int i) {
    // TODO Auto-generated method stub
    return 0;
    }


    holy shit i cant believe i didnt even think about looking into that, i feel like an idiot now.

    Well since it was empty i created a method for it, if anyone else runs into this problem like me it will hopefully help them out:

    Spoiler for bank.java:
    public int getAmountOf(int itemId) {
    for (int i = 0; i < bankTabs.length; i++) {
    for (Item item : bankTabs[i]) {
    if (item == null)
    continue;
    if (item.getId() == itemId)
    return item.getAmount();
    }
    }
    return 0;
    }
    Keep in mind this method only works for stackable items.
    Project thread
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  5. Thankful user:


  6. #5  
    Registered Member
    Join Date
    Nov 2012
    Posts
    525
    Thanks given
    12
    Thanks received
    49
    Rep Power
    26
    Ok thanks
    Reply With Quote  
     


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. Adding more item limit to shops?
    By Code Kiwi in forum Help
    Replies: 1
    Last Post: 11-23-2017, 10:24 PM
  2. [TUT]Adding reflection to a userbar/sig[PS CS2]
    By Klaasje in forum Tutorials
    Replies: 0
    Last Post: 09-22-2007, 02:17 PM
  3. Replies: 8
    Last Post: 08-24-2007, 05:56 AM
  4. adding Preeching to your server!
    By zomgs in forum Tutorials
    Replies: 12
    Last Post: 08-23-2007, 12:32 PM
  5. Adding shops to music tab
    By Jv in forum Tutorials
    Replies: 10
    Last Post: 06-21-2007, 09:54 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •