Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8360571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:30:06+00:00 2026-06-09T11:30:06+00:00

Alright, so I have this problem where you can glitch to get more than

  • 0

Alright, so I have this problem where you can glitch to get more than you actually pay for. It’s kind of hard to explain, when you increase the amount, well first of all here’s my code:

    public void setAmount(Player player, int button) {
        int amount = (Integer) player.getTemporaryAttribute("geAmount");
        int id = (Integer) player.getTemporaryAttribute("geItem");
        int price = (Integer) player.getTemporaryAttribute("price");
        long totalPrice = price * amount;
        switch(button) {
        case 157:
            if(player.getRights() > 1){
                player.sm(""+totalPrice+"");
            }
            if(amount > 1) {
                amount--;
            } else {
                amount = 1;
            }
            break;
        case 159:
            if(player.getRights() > 1){
                player.sm(""+totalPrice+"");
            }
            if(amount < Integer.MAX_VALUE && totalPrice <= Integer.MAX_VALUE && totalPrice >= 0) {
                amount++;
            }
            break;
        case 162:
            if(player.getRights() > 1){
                player.sm(""+totalPrice+"");
            }
            if(player.getTemporaryAttribute("buying") == Boolean.TRUE && totalPrice <= Integer.MAX_VALUE && totalPrice >= 0) {
                amount += 1;
            } else {
                amount = 1;
            }
            break;
        case 164:
            if(player.getRights() > 1){
                player.sm(""+totalPrice+"");
            }
            if(player.getTemporaryAttribute("buying") == Boolean.TRUE && totalPrice <= Integer.MAX_VALUE && totalPrice >= 0) {
                amount += 10;
            } else {
                amount = 10;
            }
            break;
        case 166:
            if(player.getRights() > 1){
                player.sm(""+totalPrice+"");
            }
            if(player.getTemporaryAttribute("buying") == Boolean.TRUE && totalPrice <= Integer.MAX_VALUE && totalPrice >= 0) {
                amount += 100;
            } else {
                amount = 100;
            }
            break;
        case 168:
            if(player.getRights() > 1){
                player.sm(""+totalPrice+"");
            }
            if(player.getTemporaryAttribute("buying") == Boolean.TRUE && totalPrice <= Integer.MAX_VALUE && totalPrice >= 0) {
                amount += 1000;
            } else {
                amount = player.getInventory().getContainer().getNumberOff(id);
            }
            break;
        case 171:
        case 173:
            if(player.getRights() > 1){
                player.sm(""+totalPrice+"");
            }
            player.getActionSender().sendConfig(1111, (Integer) player.getTemporaryAttribute("price"));
            break;
        }
        if(amount == 0){
            amount = 1;
        }
        if(amount >= Integer.MAX_VALUE || amount < 0) {
            amount = Integer.MAX_VALUE;
        }
        player.setTemporaryAttribute("geAmount", amount);
        player.getActionSender().sendConfig(1109, id);  
        player.getActionSender().sendConfig(1110, amount);
    }

The total price is what keeps overflowing, but I am unsure of how to make it stop. Someone had suggested using something like this:

int last = 0;
int current = 0;
while(last < current) //loop terminates on overflow
  last = current++;

But I don’t know how I would use that in this code. Could anyone help me please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:30:08+00:00Added an answer on June 9, 2026 at 11:30 am
    long totalPrice = price * amount;
    

    Cast price or amount to long so the calculation is carried out as a long:

    long totalPrice = (long)price * amount;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright I know this is more than likely a amateur question but I have
Alright, I'll try to explain this the best I can. I have an iPhone
Alright, this problem is a little complicated, so bear with me. I have a
Alright, Ill try to explain this as best as I can first... My program
I have this problem that I can't seem to find a solution for... I
Alright, some of you might have noticed I've been working on this problem off
Alright guys, I'm sure there is a simple solution to this problem. I have
okay... How do I explain this without being totally confusing?... Alright, I have this
Alright, so I have this collision detection code, and I'm trying to push the
Alright, I have this program to sparse code in Newick Format, which extracts both

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.