Ofcourse.. your code only work if player have an X amount of them
|
There's gotta be a better way to do this.Code:case 6943: if(itemId == 995) { if (c.getItems().playerHasItem(995, 2000000000)) { c.getItems().deleteItem(995, 2000000000); c.getItems().addItem(13204, 2000000); c.sendMessage("@blu@You exchange your 2 billion coins for platinum tokens!"); } } if(itemId == 13204) { if (c.getItems().playerHasItem(13204, 2000000)) { c.getItems().deleteItem(13204, 2000000); c.getItems().addItem(995, 2000000000); c.sendMessage("@blu@You exchange your 2 million platinum tokens for coins!"); } } break;
Ofcourse.. your code only work if player have an X amount of them
Code:if(itemID == 995 && usedOnObjectID == 6943) { int tokens = c.getItems().getItemAmount(995) / 1000; c.getItems().deleteItem(995, tokens*1000); c.getItems().addItem(13204, tokens); player.sendMessage("You exchange your coins for platinum tokens."); } if(itemID == 13204 && usedOnObjectID == 6943) { int tokens = c.getItems().getItemAmount(13204); c.getItems().deleteItem(13204, tokens); c.getItems().addItem(995, tokens*1000); c.sendMessage("You exchange your coins for platinum tokens."); }
Wouldnt this also be ineffective because token * 1000 will return positive or negative dependent on how many they have. E.g. anything token amount greater than ~ 2147m tokens and less than ~ 4294m will be negative, but anything greater than 4294m and less than ~6400m will return positive.
He should just insert a check using item.getAmount() and say that they can't use more than 2147m tokens at a time.
I may be wrong though.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |