# Thread: Money swap

1. sorted

2. What's going on here?

does this not return the amount already?
Code:
``player.getInventory().getAmount(5023)``

3. Originally Posted by NeilG
What's going on here?

does this not return the amount already?
Code:
``player.getInventory().getAmount(5023)``
Nah this works fine i just need to find out how to do this all command line but in reverse

if(itemId == 5022) {
int amount = 0;

for(int i = 0; i < player.getInventory().getAmount(5022); i++) {
amount++;
}
player.getInventory().delete(5022,1000000);
player.getInventory().add(5023,1);
}

this is what im trying to do but it does not want to work properly cuz even if i have 1x 5022 it will give me 1x 5023

4. look up the modulo operator

5. So you are looping a amount to check for an amount? Seems like you need to fix your logic.
Spoiler for Spoiler:

Code:
``````if(itemId == 5022) {
int amount = player.getInventory().getAmount(5022) / 1000000;
player.getInventory().delete(5022,amount *1000000);
player.getInventory().add(5023,amount);
}``````

6. Originally Posted by Arch337
So you are looping a amount to check for an amount? Seems like you need to fix your logic.
Spoiler for Spoiler:

Code:
``````if(itemId == 5022) {
int amount = player.getInventory().getAmount(5022) / 1000000;
player.getInventory().delete(5022,amount *1000000);
player.getInventory().add(5023,amount);
}``````
ok bud

7. Originally Posted by koska
Nah this works fine i just need to find out how to do this all command line but in reverse
Yeah it works, but it makes no sense
you already have the amount figured out, so you're counting up from 0 to the amount to figure out the amount.

8. Originally Posted by NeilG
Yeah it works, but it makes no sense
you already have the amount figured out, so you're counting up from 0 to the amount to figure out the amount.
Concerned helped i figgure it out ty

9. Code:
``````		for(int i = 0; i <= player.getInventory().getAmount(5022); i++) {
if (i >= 1000000) {
if (i % 1000000 == 0)
amount++;
}
}
player.getInventory().add(5023, amount);``````

10. ## Thankful user:

11. Originally Posted by El Camino
Code:
``````		for(int i = 0; i <= player.getInventory().getAmount(5022); i++) {
if (i >= 1000000) {
if (i % 1000000 == 0)
amount++;
}
}
player.getInventory().add(5023, amount);``````
Yep thats what i figgured big thanx

Page 1 of 2 12 Last

 Thread Information
##### Users Browsing this Thread

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

## User Tag List

 Posting Permissions
 You may not post new threads You may not post replies You may not post attachments You may not edit your posts   BB code is On Smilies are On [IMG] code is On [VIDEO] code is On HTML code is Off Trackbacks are Off Pingbacks are Off Refbacks are On Forum Rules