else if ("changerace".equals(cmd2)) {
final int feeItemId = 4037; // ID валюты (например, 57 = адена)
final long feeItemCount = 30; // Стоимость смены расы
TIntStringHashMap tpls = HtmCache.getInstance().getTemplates("scripts/handler/bbs/pages/changerace.htm", player);
html = tpls.get(0);
StringBuilder content = new StringBuilder();
if (!st.hasMoreTokens()) {
if (feeItemCount > 0) {
String feeBlock = tpls.get(1)
.replace("<?fee_item_count?>", Util.formatAdena(feeItemCount))
.replace("<?fee_item_name?>", HtmlUtils.htmlItemName(feeItemId));
content.append(feeBlock);
} else {
content.append(tpls.get(2));
}
// Создаём таблицу с выбором рас и классов
String raceTable = "<table width=700 border=0 background=\"L2UI_CT1.editbox_df_bg\">";
raceTable += "<tr>";
raceTable += "<td align=center width=230><button value=\"" + (player.isLangRus() ? "Человек Воин" : "Human Warrior") + "\" action=\"bypass _cbbsservices_changerace_0_0\" width=200 height=30 back=\"L2UI_ct1.button_df_down\" fore=\"L2UI_ct1.button_df\"></td>";
raceTable += "<td align=center width=230><button value=\"" + (player.isLangRus() ? "Человек Маг" : "Human Mage") + "\" action=\"bypass _cbbsservices_changerace_0_10\" width=200 height=30 back=\"L2UI_ct1.button_df_down\" fore=\"L2UI_ct1.button_df\"></td>";
raceTable += "</tr>";
raceTable += "<tr>";
raceTable += "<td align=center width=230><button value=\"" + (player.isLangRus() ? "Эльф Воин" : "Elf Warrior") + "\" action=\"bypass _cbbsservices_changerace_1_18\" width=200 height=30 back=\"L2UI_ct1.button_df_down\" fore=\"L2UI_ct1.button_df\"></td>";
raceTable += "<td align=center width=230><button value=\"" + (player.isLangRus() ? "Эльф Маг" : "Elf Mage") + "\" action=\"bypass _cbbsservices_changerace_1_25\" width=200 height=30 back=\"L2UI_ct1.button_df_down\" fore=\"L2UI_ct1.button_df\"></td>";
raceTable += "</tr>";
raceTable += "<tr>";
raceTable += "<td align=center width=230><button value=\"" + (player.isLangRus() ? "Темный Эльф Воин" : "Dark Elf Warrior") + "\" action=\"bypass _cbbsservices_changerace_2_31\" width=200 height=30 back=\"L2UI_ct1.button_df_down\" fore=\"L2UI_ct1.button_df\"></td>";
raceTable += "<td align=center width=230><button value=\"" + (player.isLangRus() ? "Темный Эльф Маг" : "Dark Elf Mage") + "\" action=\"bypass _cbbsservices_changerace_2_38\" width=200 height=30 back=\"L2UI_ct1.button_df_down\" fore=\"L2UI_ct1.button_df\"></td>";
raceTable += "</tr>";
raceTable += "<tr>";
raceTable += "<td align=center width=230><button value=\"" + (player.isLangRus() ? "Орк Воин" : "Orc Warrior") + "\" action=\"bypass _cbbsservices_changerace_3_44\" width=200 height=30 back=\"L2UI_ct1.button_df_down\" fore=\"L2UI_ct1.button_df\"></td>";
raceTable += "<td align=center width=230><button value=\"" + (player.isLangRus() ? "Орк Маг" : "Orc Mage") + "\" action=\"bypass _cbbsservices_changerace_3_49\" width=200 height=30 back=\"L2UI_ct1.button_df_down\" fore=\"L2UI_ct1.button_df\"></td>";
raceTable += "</tr>";
raceTable += "<tr>";
raceTable += "<td align=center width=230><button value=\"" + (player.isLangRus() ? "Гном Воин" : "Dwarf Warrior") + "\" action=\"bypass _cbbsservices_changerace_4_53\" width=200 height=30 back=\"L2UI_ct1.button_df_down\" fore=\"L2UI_ct1.button_df\"></td>";
raceTable += "<td align=center width=230></td>";
raceTable += "</tr>";
raceTable += "<tr>";
raceTable += "<td align=center width=230><button value=\"" + (player.isLangRus() ? "Камаэль Мужчина" : "Kamael Male") + "\" action=\"bypass _cbbsservices_changerace_5_123\" width=200 height=30 back=\"L2UI_ct1.button_df_down\" fore=\"L2UI_ct1.button_df\"></td>";
raceTable += "<td align=center width=230><button value=\"" + (player.isLangRus() ? "Камаэль Женщина" : "Kamael Female") + "\" action=\"bypass _cbbsservices_changerace_5_124\" width=200 height=30 back=\"L2UI_ct1.button_df_down\" fore=\"L2UI_ct1.button_df\"></td>";
raceTable += "</tr>";
raceTable += "</table>";
content.append(raceTable);
} else {
if (!BBSConfig.GLOBAL_USE_FUNCTIONS_CONFIGS && !checkUseCondition(player)) {
onWrongCondition(player);
return;
}
int raceId, classId;
try {
raceId = Integer.parseInt(st.nextToken());
classId = Integer.parseInt(st.nextToken());
} catch (NumberFormatException e) {
player.sendMessage(player.isLangRus() ? "Ошибка: некорректный ID расы или класса." : "Error: invalid race or class ID.");
player.sendPacket(ShowBoard.CLOSE);
return;
}
if (raceId < 0 || raceId >= Race.VALUES.length) {
player.sendMessage(player.isLangRus() ? "Ошибка: указанная раса не существует." : "Error: the specified race does not exist.");
player.sendPacket(ShowBoard.CLOSE);
return;
}
Race newRace = Race.VALUES[raceId];
ClassId newClassId = ClassId.VALUES[classId];
if (newClassId.getRace() != newRace || newClassId.getClassLevel() != ClassLevel.NONE) {
player.sendMessage(player.isLangRus() ? "Ошибка: выбранный класс не соответствует расе." : "Error: selected class does not match the race.");
player.sendPacket(ShowBoard.CLOSE);
return;
}
if (feeItemCount > 0 && !ItemFunctions.deleteItem(player, feeItemId, feeItemCount, true)) {
String noHaveItemBlock = tpls.get(4)
.replace("<?fee_item_count?>", Util.formatAdena(feeItemCount))
.replace("<?fee_item_name?>", HtmlUtils.htmlItemName(feeItemId));
content.append(noHaveItemBlock);
} else {
boolean noban = true;
player.setRace(0, raceId);
player.setClassId(newClassId.getId(), noban, false);
player.broadcastUserInfo(true);
content.append(
tpls.get(5)
.replace("<?player_name?>", player.getName())
.replace("<?race_name?>", newRace.name())
.replace("<?class_name?>", newClassId.name())
);
Log.LogEvent(player.getName(), "ChangeRace", "RaceChange", "changed race to: " + newRace.name() + " with class " + newClassId.name());
}
}
html = html.replace("<?content?>", content.toString());
ShowBoard.separateAndSend(html, player);
}