Juggles Posted January 27, 2017 Share Posted January 27, 2017 My account needs to keep 4.3m gold in the inventory. The amount of gold before muling is a number above 4.3m. So I used the equation amount in inventory - 4.3m = amount to trade So in my code I put long x = getInventory().getAmount(995); long amountToTrade = x - 4300000; Now in my mule code, I put trade.offer(995, amountToTrade); Sadly this does not work even though all the math makes sense. I know the string requires an int but I cannot use int when i am getting the amount in the inventory. Any help or suggestions would be greatly appreciated Quote Link to comment Share on other sites More sharing options...
Stimpack Posted January 27, 2017 Share Posted January 27, 2017 not sure if this is what you're looking for.. cast long to int trade.offer(995, Math.toIntExact(amountToTrade)); this will throw ArithmeticException if overflow (amountToTrade greater than 2,147,483,647) 1 Quote Link to comment Share on other sites More sharing options...
Team Cape Posted January 27, 2017 Share Posted January 27, 2017 since you know that its not gonna be greater than 2b, just cast it to an int. 1 Quote Link to comment Share on other sites More sharing options...
ct1996 Posted January 27, 2017 Share Posted January 27, 2017 Longs are not commonly used for this type of thing. Doubles would be easier. Also you can use Integer.ParseInt(input) to cast anything to an int, except I think BigInts. Which you should never need for OSRS 1 Quote Link to comment Share on other sites More sharing options...
Juggles Posted January 27, 2017 Author Share Posted January 27, 2017 1 hour ago, Stimpack said: not sure if this is what you're looking for.. cast long to int trade.offer(995, Math.toIntExact(amountToTrade)); this will throw ArithmeticException if overflow (amountToTrade greater than 2,147,483,647) Thanks it worked! 1 Quote Link to comment Share on other sites More sharing options...
Magarac Posted January 27, 2017 Share Posted January 27, 2017 Yeah I was gonna say, an int should be fine so long as its under 2,147,483,647 gp which I would assume you don't make before trading to the mule; otherwise that'd be hella impressive Quote Link to comment Share on other sites More sharing options...
Tom Posted January 27, 2017 Share Posted January 27, 2017 13 minutes ago, Magarac said: Yeah I was gonna say, an int should be fine so long as its under 2,147,483,647 gp which I would assume you don't make before trading to the mule; otherwise that'd be hella impressive That is the max cash stack on rs so he cant really trade more than it 1 Quote Link to comment Share on other sites More sharing options...
Magarac Posted January 27, 2017 Share Posted January 27, 2017 Just now, Tom said: That is the max cash stack on rs so he cant really trade more than it I feel dumb. Completely forgot about RS's own limits. 1 Quote Link to comment Share on other sites More sharing options...