player.reduceAdena(price, true);
sm = new SystemMessage(SystemMessage.ACQUIRED__S1_S2);
sm.addNumber(lotonumber);
sm.addItemName(4442);
player.sendPacket(sm);
L2ItemInstance item = ItemTable.getInstance().createItem(4442);
item.setCustomType1(lotonumber);
item.setEnchantLevel(enchant);
item.setCustomType2(type2);
player.getInventory().addItem(item);
Log.LogItem(player, Log.BuyItem, item);
html.setHtml("<html><body>Lottery Ticket Seller:<br>Thank you for playing the lottery<br>The winners will be announced at 7:00 pm <br><center><a action=\"bypass -h npc_%objectId%_Chat 0\">Back</a></center></body></html>");
} else if (val == 23) // 23 - current lottery jackpot
{
filename = getHtmlPath(npcId, 3);
html.setFile(filename);
} else if (val == 24) {
filename = getHtmlPath(npcId, 4);
html.setFile(filename);
int lotonumber = LotteryManager.getInstance().getId();
String message = "";
for (L2ItemInstance item : player.getInventory().getItems()) {
if (item == null) {
continue;
}
if (item.getItemId() == 4442 && item.getCustomType1() < lotonumber) {
message = message + "<a action=\"bypass -h npc_%objectId%_Loto " + item.getObjectId() + "\">"
+ item.getCustomType1() + " Event Number ";
int[] numbers = LotteryManager.getInstance().decodeNumbers(item.getEnchantLevel(),
item.getCustomType2());
for (int i = 0; i < 5; i++) {
message += numbers[i] + " ";
}
int[] check = LotteryManager.getInstance().checkTicket(item);
if (check[0] > 0) {
switch (check[0]) {
case 1:
message += "- 1st Prize";
break;
case 2:
message += "- 2nd Prize";
break;
case 3:
message += "- 3th Prize";
break;
case 4:
message += "- 4th Prize";
break;
}
message += " " + check[1] + "a.";
}
message += "</a><br>";
}
}
if ("".equals(message)) {
message += "There is no winning lottery ticket...<br>";
}
html.replace("%result%", message);
} else if (val == 25) {
filename = getHtmlPath(npcId, 2);
html.setFile(filename);
} else if (val > 25) {
int lotonumber = LotteryManager.getInstance().getId();
L2ItemInstance item = player.getInventory().getItemByObjectId(val);
if (item == null || item.getItemId() != 4442 || item.getCustomType1() >= lotonumber) {
return;
}
int[] check = LotteryManager.getInstance().checkTicket(item);
player.sendPacket(SystemMessage.removeItems(4442, 1));
int adena = check[1];