05-10-2012, 03:48 AM
когда пишу слишком много цветов в конфиге то выдает ошибку String Index out of range: 6
где в скрипте ограничение стойт не могу понять подскажите, что бы добавить 20+ цветов
config
Код:
# Сервис смены цвета ника
# ffbf00;ffba00;ffa500;ff9900;e28b00;e49b0f;daa520;b8860b;cd83f;b87333;cc7722;a25f2a;964b00;904d30;734a12;704214;834d18;7b3f00;654321;3d2b1f;4422d25;987654;fdeaa8;a6e6fa;d5d5d5;c7d0cc;ccccff;abcdef;7fc7ff;9db1cc;79a0c1;6495ed;42aaff;1e90ff;008cf0;007fff;0095b6;4682b4;3a75c4;007ba7;1560bd;2a52be;0047ab;1a4780;08457e;003366;092567;003153;464451;505050;808080;708090;99958c;afeeee;7df9ff;00ffff;08e8de;30d5c8;00cccc;008080;01796f;1c6b72;116062
NickColorChangeEnabled = True
# Порядок цветов инвертирован - BBGGRR
NickColorChangeList = ffbf00;ffba00;ffa500;ff9900;e28b00;e49b0f;daa520;b8860b
NickColorChangePrice = 100
NickColorChangeItem = 57
script
Код:
package services;
import l2p.gameserver.Config;
import l2p.gameserver.cache.Msg;
import l2p.gameserver.data.xml.holder.ItemHolder;
import l2p.gameserver.model.Player;
import l2p.gameserver.serverpackets.components.SystemMsg;
import l2p.gameserver.scripts.Functions;
public class NickColor extends Functions
{
public void list()
{
Player player = getSelf();
if(player == null)
return;
StringBuilder append = new StringBuilder();
append.append("You can change nick color for small price ").append(Config.SERVICES_CHANGE_NICK_COLOR_PRICE).append(" ").append(ItemHolder.getInstance().getTemplate(Config.SERVICES_CHANGE_NICK_COLOR_ITEM).getName()).append(".");
append.append("<br>Possible colors:<br>");
for(String color : Config.SERVICES_CHANGE_NICK_COLOR_LIST)
append.append("<br><a action=\"bypass -h scripts_services.NickColor:change ").append(color).append("\"><font color=\"").append(color.substring(4, 6) + color.substring(2, 4) + color.substring(0, 2)).append("\">").append(color.substring(4, 6) + color.substring(2, 4) + color.substring(0, 2)).append("</font></a>");
append.append("<br><a action=\"bypass -h scripts_services.NickColor:change FFFFFF\"><font color=\"FFFFFF\">Revert to default (free)</font></a>");
show(append.toString(), player, null);
}
public void change(String[] param)
{
Player player = getSelf();
if(player == null)
return;
if(param[0].equalsIgnoreCase("FFFFFF"))
{
player.setNameColor(Integer.decode("0xFFFFFF"));
player.broadcastUserInfo(true);
return;
}
if(player.getInventory().destroyItemByItemId(Config.SERVICES_CHANGE_NICK_COLOR_ITEM, Config.SERVICES_CHANGE_NICK_COLOR_PRICE))
{
player.setNameColor(Integer.decode("0x" + param[0]));
player.broadcastUserInfo(true);
}
else if(Config.SERVICES_CHANGE_NICK_COLOR_ITEM == 57)
player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
else
player.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT);
}
}