Originally Posted by
Tampa Bay
OK so the code Jason provided works fine:
Code:
if (objectId == BLACK_HOLE) {
if(!c.getItems().playerHasItem(itemId))
return;
c.getItems().deleteItem2(itemId, c.getItems().getItemAmount(itemId));
c.sendMessage("The dark hole eats your "+c.getItems().getItemName(itemId)+".");
}
But i was wondeering how could i make it so it takes money in bundles, like you could only put in 500k or more, and then recieve a ticket. Like if you wud have 2m, you would get 4 tickets, etc. but if you put in less than 500k, it says sth like 500k or more. Whats missing then
Code:
if (objectId == BLACK_HOLE) {
final int REQUIRED = 500000;
if(!c.getItems().playerHasItem(995, REQUIRED)) {
c.sendMessage("The dark hole demands 500,000GP, get away peasant.");
return;
}
int amount = c.getItems().getItemAmount(995) / REQUIRED;
c.getItems().deleteItem2(995, REQUIRED * amount);
c.getItems().addItem(TICKET_ID, amount);
c.sendMessage("The dark hole eats your coins but gives you back something.");
}
For every 500k the player has, it will distribute another ticket.
@-MrC
Code:
c.getItems().addItem(**TICKETID**, i);
For every loop the amount of tickets will increase, replace i with 1.