12-11-2011, 09:15 AM
Код:
public void addSQLAuction(String args[])
{
int objItem = Integer.valueOf(args[0]);
int price = Integer.valueOf(args[1]);
long Time = System.currentTimeMillis() / 1000;
String timeSend = args[2];
if (timeSend.startsWith("1"))
Time+= 1 * 24 * 60 * 60;
else if (timeSend.startsWith("3"))
Time+= 3 * 24 * 60 * 60;
else if (timeSend.startsWith("7"))
Time+= 7 * 24 * 60 * 60;
int priceId = 57;
if (Integer.valueOf(args[4]) == 1)
priceId = 57;
else if (Integer.valueOf(args[4]) == 2)
priceId = 21002;
else if (Integer.valueOf(args[4]) == 3)
priceId = 21007;
else if (Integer.valueOf(args[4]) == 4)
priceId = 21008;
else if (Integer.valueOf(args[4]) == 5)
priceId = 21000;
else if (Integer.valueOf(args[4]) == 6)
priceId = 21001;
L2Player player = (L2Player) getSelf();
L2ItemInstance Lot = player.getInventory().getItemByObjectId(objItem);
if (Lot==null)
return;
int charId = player.getObjectId();
String TypeItem = "Бонус";
if (Lot.isWeapon())
TypeItem = "Оружие";
else if (Lot.isArmor())
TypeItem = "Броня";
else if (Lot.getItem().isAccessory())
TypeItem = "Бижутерия";
String nameItem = Lot.getName();
int idItem = Lot.getItemId();
int attEl = Lot.getAttackAttributeElement();
int attValue = Lot.getAttackElementValue();
int Enchant = Lot.getEnchantLevel();
int[] armorAtt = Lot.getDeffAttr();
if (Lot==null)
return;
ThreadConnection con = null;
FiltredPreparedStatement statement = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
statement = con.prepareStatement("REPLACE INTO auctionitem (char_id,Item_Id,TypeItem,NameItem,price,IdItem,time,elemValue,elemType,att0,att1,att2,att3,att4,att5,Enchant,IdPrice,client,startPrice) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
statement.setInt(1, charId);
statement.setInt(2, objItem);
statement.setString(3, TypeItem);
statement.setString(4, nameItem);
statement.setInt(5, price);
statement.setInt(6, idItem);
statement.setLong(7, Time);
statement.setInt(8, attValue);
statement.setInt(9, attEl);
statement.setInt(10, armorAtt[0]);
statement.setInt(11, armorAtt[1]);
statement.setInt(12, armorAtt[2]);
statement.setInt(13, armorAtt[3]);
statement.setInt(14, armorAtt[4]);
statement.setInt(15, armorAtt[5]);
statement.setInt(16, Enchant);
statement.setInt(17, priceId);
statement.setString(18, "");
statement.setInt(19, price);
statement.executeUpdate();
}
catch(Exception e)
{
}
finally
{
DatabaseUtils.closeDatabaseCS(con, statement);
}
player.getInventory().dropItem(Lot, 1, true);
}
При if (Integer.valueOf(args[4]) == 1)
priceId = 57;
else if (Integer.valueOf(args[4]) == 2)
priceId = 21002;
else if (Integer.valueOf(args[4]) == 3)
priceId = 21007;
else if (Integer.valueOf(args[4]) == 4)
priceId = 21008;
else if (Integer.valueOf(args[4]) == 5)
priceId = 21000;
else if (Integer.valueOf(args[4]) == 6)
priceId = 21001;
Работают только 1, 2, 6 а при нажатии на кнопки 3, 4 и 5
вылазит ошибка Caused by: java.lang.ArrayIndexOutOfBoundsException: 4
Как исправить?