@Override public boolean useUserCommand(int id, Player activeChar) { if (id != COMMAND_IDS[0]) return false; GameObject objectTarget = Config.OLYMPIAD_OLDSTYLE_STAT ? activeChar : activeChar.getTarget(); if (objectTarget == null || !objectTarget.isPlayer() || !objectTarget.getPlayer().isNoble()) { activeChar.sendPacket(SystemMsg.THIS_COMMAND_CAN_ONLY_BE_USED_BY_A_NOBLESSE); return true; } Player playerTarget = objectTarget.getPlayer(); SystemMessage2 sm = new SystemMessage2( SystemMsg .FOR_THE_CURRENT_GRAND_OLYMPIAD_YOU_HAVE_PARTICIPATED_IN_S1_MATCHES_S2_WINS_S3_DEFEATS_YOU_CURRENTLY_HAVE_S4_OLYMPIAD_POINTS); sm.addInteger(Olympiad.getCompetitionDone(playerTarget.getObjectId())); sm.addInteger(Olympiad.getCompetitionWin(playerTarget.getObjectId())); sm.addInteger(Olympiad.getCompetitionLoose(playerTarget.getObjectId())); sm.addInteger(Olympiad.getNoblePoints(playerTarget.getObjectId())); activeChar.sendPacket(sm); int[] ar = Olympiad.getWeekGameCounts(playerTarget.getObjectId()); sm = new SystemMessage2( SystemMsg .YOU_HAVE_S1_MATCHES_REMAINING_THAT_YOU_CAN_PARTICIPATE_IN_THIS_WEEK_S2_1_VS_1_CLASS_MATCHES_S3_1_VS_1_MATCHES__S4_3_VS_3_TEAM_MATCHES); sm.addInteger(ar[0]); sm.addInteger(ar[1]); sm.addInteger(ar[2]); sm.addInteger(0 /*ar[3]*/); activeChar.sendPacket(sm); return true; }
public static long removeItem(Playable playable, ItemInstance item, long count, boolean notify) { long removed = 0; if (playable == null || count < 1) return removed; Playable player = playable.getPlayer(); if (item.getTemplate().isStackable()) { if (player.getInventory().destroyItem(item, count)) removed = count; } else for (long i = 0; i < count; i++) if (player.getInventory().destroyItem(item, 1)) removed++; if (removed > 0 && notify) player.sendPacket(SystemMessage2.removeItems(item.getItemId(), removed)); return removed; }
/** * Добавляет предмет в инвентарь игрока, корректно обрабатывает нестыкуемые вещи * * @param playable Владелец инвентаря * @param itemId ID предмета * @param count количество */ public static void addItem(Playable playable, int itemId, long count, boolean notify) { if (playable == null || count < 1) return; Playable player; if (playable.isSummon()) player = playable.getPlayer(); else player = playable; if (itemId > 0) { ItemTemplate t = ItemHolder.getInstance().getTemplate(itemId); if (t.isStackable()) player.getInventory().addItem(itemId, count); else for (long i = 0; i < count; i++) player.getInventory().addItem(itemId, 1); if (notify) player.sendPacket(SystemMessage2.obtainItems(itemId, count, 0)); } else if (itemId == -100 && player.isPlayer()) { player.getPlayer().addPcBangPoints((int) count, false); } else if (itemId == -200 && player.isPlayer()) { if (player.getPlayer().getClan() != null) player.getPlayer().getClan().incReputation((int) count, false, "itemFunction"); } else if (itemId == -300 && player.isPlayer()) { player.getPlayer().setFame((int) count + player.getPlayer().getFame(), "itemFunction"); } }