nakashimi

Members
  • Content Count

    130
  • Joined

  • Last visited

  • Feedback

    0%

Community Reputation

0 Neutral

About nakashimi

  • Rank
    Heir

Profile Information

  • Gender
    Male
  • Location
    Alagoas
  • Interests
    Java Developer Garvian

Recent Profile Visitors

442 profile views
  1. Would anyone have a voice command for interlude that opens the gmshop and can buy the items?
  2. Guys wanted to know how to put multiple players that do not serve in the same login but all joining the same type of world [BRASIL] L2KKK [AMERICA] L2KKK [AFRICA] L2KKK Anybody know?
  3. I'm having problems only on these lines. lastAttacker.doAutoLoot((L2Attackable) mob, item); return ((L2Attackable) mob).dropItem(lastAttacker, item); super(-1, GlobalDropMonsters.class.getSimpleName()); if (npcTemplate.getType().equalsIgnoreCase("L2Monster")) super.addKillId(npcTemplate.getIdTemplate());
  4. Could someone help me adapt this mod for l2jhellas? Index: config/players.properties =================================================================== --- config/players.properties (revision 5) +++ config/players.properties (working copy) @@ -320,4 +320,18 @@ DressMeLegs = Imperial,6374 DressMeBoots = Draconic,6381;Imperial,6376;Arcana,6385 DressMeGloves = Draconic,6380;Imperial,6375;Arcana,6384 DressMeWeapons = Draconic_Bow,7577;Shining_Bow,6594;Arcana_Mace,6608 + +#============================================================= +# Global Drop +#============================================================= +# Configuração de Drop Global +# Liga / Desliga Drop Global +AllowGlobalDrop = True +# Ativa Drop random que aumenta de acordo com level do MOB. +AllowRandomQuantityDrop = True +# Itemid,chance,min,max;Itemid,chance,min,max +GlobalDropItems = 6392,100,1,2;6393,50,1,3; +# Itemid,chance,min,max;Itemid,chance,min,max +# Essa configuração é para mobs do tipo Champion +ChampionGlobalDropItems = 6391,100,1,2; \ No newline at end of file Index: java/net/sf/l2j/Config.java =================================================================== --- java/net/sf/l2j/Config.java (revision 5) +++ java/net/sf/l2j/Config.java (working copy) @@ -690,6 +690,11 @@ public static int CLIENT_PACKET_QUEUE_MAX_OVERFLOWS_PER_MIN = 1; // default 1 public static int CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN = 1; // default 1 public static int CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN = 5; // default 5 + + public static Map<Integer, List<Integer>> GLOBAL_DROP_ITEMS = new HashMap<>(); + public static Map<Integer, List<Integer>> GLOBAL_DROP_ITEMS_CHAMPION = new HashMap<>(); + public static boolean ALLOW_GLOBAL_DROP_RANDOM; + public static boolean ALLOW_GLOBAL_DROP; // -------------------------------------------------- @@ -1133,7 +1138,31 @@ */ private static final void loadPlayers() { final ExProperties players = initProperties(PLAYERS_FILE); + String globalTemp = players.getProperty("GlobalDropItems", ""); + String[] globalTemp2 = globalTemp.split(";"); + for (String s : globalTemp2) + { + List<Integer> list = new ArrayList<>(); + String[] t = s.split(","); + list.add(Integer.parseInt(t[1])); + list.add(Integer.parseInt(t[2])); + list.add(Integer.parseInt(t[3])); + GLOBAL_DROP_ITEMS.put(Integer.parseInt(t[0]), list); + } + globalTemp = players.getProperty("ChampionGlobalDropItems", ""); + globalTemp2 = globalTemp.split(";"); + for (String s : globalTemp2) + { + List<Integer> list = new ArrayList<>(); + String[] t = s.split(","); + list.add(Integer.parseInt(t[1])); + list.add(Integer.parseInt(t[2])); + list.add(Integer.parseInt(t[3])); + GLOBAL_DROP_ITEMS_CHAMPION.put(Integer.parseInt(t[0]), list); + } + ALLOW_GLOBAL_DROP_RANDOM = players.getProperty("AllowRandomQuantityDrop", true); + ALLOW_GLOBAL_DROP = players.getProperty("AllowGlobalDrop", true); STARTING_ADENA = players.getProperty("StartingAdena", 100); EFFECT_CANCELING = players.getProperty("CancelLesserEffect", true); HP_REGEN_MULTIPLIER = players.getProperty("HpRegenMultiplier", 1.); Index: java/net/sf/l2j/gameserver/scripting/scripts/custom/GlobalDropMonsters.java =================================================================== --- java/net/sf/l2j/gameserver/scripting/scripts/custom/GlobalDropMonsters.java (nonexistent) +++ java/net/sf/l2j/gameserver/scripting/scripts/custom/GlobalDropMonsters.java (working copy) @@ -0,0 +1,125 @@ + +package net.sf.l2j.gameserver.scripting.scripts.custom; + +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import net.sf.l2j.commons.random.Rnd; + +import net.sf.l2j.Config; +import net.sf.l2j.gameserver.datatables.NpcTable; +import net.sf.l2j.gameserver.model.actor.L2Attackable; +import net.sf.l2j.gameserver.model.actor.L2Npc; +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate; +import net.sf.l2j.gameserver.model.holder.IntIntHolder; +import net.sf.l2j.gameserver.model.item.instance.ItemInstance; +import net.sf.l2j.gameserver.scripting.Quest; + +/** + * @author Tayran.JavaDev + * @version 4 + */ +public class GlobalDropMonsters extends Quest +{ + + @Override + public String onKill(L2Npc mob, L2PcInstance killer, boolean isPet) + { + int levelMobMin = 0; + for (int i = 1; i < 81; i++) + { + levelMobMin = killer.getLevel() - 8; + if (i > 10) + { + if (killer.getLevel() == i && mob.getLevel() < levelMobMin) + return ""; + } + } + if (mob.isChampion()) + dropItem(mob, killer, Config.GLOBAL_DROP_ITEMS_CHAMPION); + else + dropItem(mob, killer, Config.GLOBAL_DROP_ITEMS); + return super.onKill(mob, killer, isPet); + } + + private static void dropItem(final L2Npc mob, final L2PcInstance player, final Map<Integer, List<Integer>> droplist) + { + Integer key; + Integer chance; + Integer min; + Integer max; + Integer itemMin; + Integer itemMax; + Integer count; + Integer rnd; + for (Entry<Integer, List<Integer>> entry : droplist.entrySet()) + { + key = entry.getKey(); + List<Integer> valueList = entry.getValue(); + + chance = valueList.get(0); + min = valueList.get(1); + max = valueList.get(2); + + if (mob.getLevel() > 9 && Config.ALLOW_GLOBAL_DROP_RANDOM) + { + itemMin = mob.getLevel() * min / 5; + itemMax = mob.getLevel() * max / 6; + } + else + { + itemMin = min; + itemMax = max; + } + count = Rnd.get(itemMin, itemMax); + + rnd = Rnd.get(100); + + if (rnd < chance) + { + IntIntHolder item = new IntIntHolder(key, count); + dropItem(mob, player, item); + continue; + } + } + + } + + /** + * Drop item. + * @author Tayran.JavaDev + * @param mob + * @param lastAttacker The player who made ultimate damage. + * @param item instance IntIntHolder. + * @return the dropped item instance. + */ + public static ItemInstance dropItem(L2Npc mob, L2PcInstance lastAttacker, IntIntHolder item) + { + if (Config.AUTO_LOOT) + lastAttacker.doAutoLoot((L2Attackable) mob, item); + else + return ((L2Attackable) mob).dropItem(lastAttacker, item); + return null; + } + + + public GlobalDropMonsters() + { + super(-1, GlobalDropMonsters.class.getSimpleName()); + if (Config.ALLOW_GLOBAL_DROP) + { + for (NpcTemplate npcTemplate : NpcTable.getInstance().getAllNpcs()) + { + if (npcTemplate.getType().equalsIgnoreCase("L2Monster")) + super.addKillId(npcTemplate.getIdTemplate()); + } + System.out.println("[Drop Global Activated] All L2Monster have been added with Global Drop Items"); + } + else + { + System.out.println("[Drop Global Disabled] No L2Monster was changed"); + } + } +} \ No newline at end of file
  5. From what I studied of the pack I saw that the parts of enterworld was transferred to L2PcInstance if I'm not mistaken
  6. Thank you, you are really right but I don't know how I can use the system as @AbsolutePower mentioned right above I don't handle much of java so the integration with the premium account I was able to understand only in the method of completion days, but the skills I can't understand what the method will help in the form of sendskills
  7. Good to acquire this system I wanted to know how to make the character stand up and buff instead of being static like no video. VIDEO I'm trying to get the character to give the buff if you understand me that way in the video COD ### Eclipse Workspace Patch 1.0 #P L2jFrozen_GameServer Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestGiveNickName.java =================================================================== --- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestGiveNickName.java (revision 991) +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestGiveNickName.java (working copy) @@ -46,54 +46,59 @@ L2PcInstance activeChar = getClient().getActiveChar(); if(activeChar == null) return; - - // Noblesse can bestow a title to themselves - if(activeChar.isNoble() && _target.matches(activeChar.getName())) - { - activeChar.setTitle(_title); - SystemMessage sm = new SystemMessage(SystemMessageId.TITLE_CHANGED); - activeChar.sendPacket(sm); - activeChar.broadcastTitleInfo(); - } - //Can the player change/give a title? - else if((activeChar.getClanPrivileges() & L2Clan.CP_CL_GIVE_TITLE) == L2Clan.CP_CL_GIVE_TITLE) - { - if(activeChar.getClan().getLevel() < 3) + + // If activeChar is not selling buffs + if(!activeChar.isSellBuff()){ + // Noblesse can bestow a title to themselves + if(activeChar.isNoble() && _target.matches(activeChar.getName())) { - SystemMessage sm = new SystemMessage(SystemMessageId.CLAN_LVL_3_NEEDED_TO_ENDOWE_TITLE); + activeChar.setTitle(_title); + SystemMessage sm = new SystemMessage(SystemMessageId.TITLE_CHANGED); activeChar.sendPacket(sm); - sm = null; - return; + activeChar.broadcastTitleInfo(); } - - L2ClanMember member1 = activeChar.getClan().getClanMember(_target); - if(member1 != null) + //Can the player change/give a title? + else if((activeChar.getClanPrivileges() & L2Clan.CP_CL_GIVE_TITLE) == L2Clan.CP_CL_GIVE_TITLE) { - L2PcInstance member = member1.getPlayerInstance(); - if(member != null) + if(activeChar.getClan().getLevel() < 3) { - //is target from the same clan? - member.setTitle(_title); - SystemMessage sm = new SystemMessage(SystemMessageId.TITLE_CHANGED); - member.sendPacket(sm); - member.broadcastTitleInfo(); + SystemMessage sm = new SystemMessage(SystemMessageId.CLAN_LVL_3_NEEDED_TO_ENDOWE_TITLE); + activeChar.sendPacket(sm); sm = null; + return; } + + L2ClanMember member1 = activeChar.getClan().getClanMember(_target); + if(member1 != null) + { + L2PcInstance member = member1.getPlayerInstance(); + if(member != null) + { + //is target from the same clan? + member.setTitle(_title); + SystemMessage sm = new SystemMessage(SystemMessageId.TITLE_CHANGED); + member.sendPacket(sm); + member.broadcastTitleInfo(); + sm = null; + } + else + { + SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2); + sm.addString("Target needs to be online to get a title"); + activeChar.sendPacket(sm); + sm = null; + } + } else { SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2); - sm.addString("Target needs to be online to get a title"); + sm.addString("Target does not belong to your clan"); activeChar.sendPacket(sm); sm = null; } } - else - { - SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2); - sm.addString("Target does not belong to your clan"); - activeChar.sendPacket(sm); - sm = null; - } + }else{ + activeChar.sendMessage("You can't change title when sell buffs"); } } Index: head-src/com/l2jfrozen/gameserver/custom/SellBuffMsg.java =================================================================== --- head-src/com/l2jfrozen/gameserver/custom/SellBuffMsg.java (revision 0) +++ head-src/com/l2jfrozen/gameserver/custom/SellBuffMsg.java (working copy) @@ -0,0 +1,1007 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package com.l2jfrozen.gameserver.custom; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.logging.Logger; + +import javolution.text.TextBuilder; +import javolution.util.FastList; + +import com.l2jfrozen.Config; +import com.l2jfrozen.gameserver.datatables.SkillTable; +import com.l2jfrozen.gameserver.model.L2Skill; +import com.l2jfrozen.gameserver.model.L2Skill.SkillType; +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; +import com.l2jfrozen.util.CloseUtil; +import com.l2jfrozen.util.database.L2DatabaseFactory; + + +/** + * @author Matthew Mazan + * + */ +public class SellBuffMsg +{ + + @SuppressWarnings("unused") + private static Logger _log = Logger.getLogger(SellBuffMsg.class.getName()); + + private int _lastPage = 0; + private int _subPage = 0; + + public void setLastPage(int page){ + _lastPage = page; + } + + public int getLastPage(){ + return _lastPage; + } + + public void setSubPage(int subPage){ + _subPage = subPage; + } + + public int getSubPage(){ + return _subPage; + } + + /** + * Construct response to buff buyer. + * @param seller + * @param buyer + * @return + */ + private TextBuilder buyerResponse(L2PcInstance seller, L2PcInstance buyer){ + TextBuilder tb = new TextBuilder(); + int buffsPerPage = 8; //8 is maximum + int buffsCount = 0; //count all player buffs + int sellBuffsCount = 0; // count buffs on actual page + String buffFor = " player"; + + if(_lastPage == 1 || _lastPage == 2){ + if(_lastPage == 2){buffFor = " pet"; } + tb.append("<html><title>"+seller.getName()+"("+seller.getLevel()+") buff price for"+buffFor+": "+seller.getBuffPrice()+" adena</title><body><br>"); + + FastList<L2Skill> ba = this.getBuffList(seller); + + for(L2Skill p : ba){ + if(Config.SELL_BUFF_SKILL_LIST.containsKey(p.getId())){ + buffsCount++; + if(buffsCount > buffsPerPage * _subPage && buffsCount <= buffsPerPage * (_subPage + 1)){// show subpage with buffs. + //_log.info("party skill entered:"+p.getTargetType().name()); + if(!Config.ALLOW_PARTY_BUFFS && p.getTargetType() == L2Skill.SkillTargetType.TARGET_PARTY){ + if(buyer.getParty() != null && seller.getParty() != null && buyer.getParty().equals(seller.getParty())){ //check is in party. + sellBuffsCount++; + createHtmlSkillField(tb, _lastPage, p.getName()+" ("+p.getLevel()+")", p.getId(), buffsCount); + } + }else if(!Config.ALLOW_CLAN_BUFFS && (p.getTargetType() == L2Skill.SkillTargetType.TARGET_CLAN || p.getTargetType() == L2Skill.SkillTargetType.TARGET_ALLY)){ + if((buyer.getClan() != null && seller.getClan() != null && buyer.getClanId() == seller.getClanId())||(buyer.getClan() != null && seller.getClan() != null && buyer.getClan().getAllyName() != null && seller.getClan().getAllyName() != null && buyer.getClan().getAllyName().equals(seller.getClan().getAllyName()))){ //check is in clan or ally. + sellBuffsCount++; + createHtmlSkillField(tb, _lastPage, p.getName()+" ("+p.getLevel()+")", p.getId(), buffsCount); + } + }else{ + sellBuffsCount++; + createHtmlSkillField(tb, _lastPage, p.getName()+" ("+p.getLevel()+")", p.getId(), buffsCount); + } + } + } + } + + + if(sellBuffsCount > 0){ + for(int x=(buffsCount-(_subPage*buffsPerPage)) ; x<buffsPerPage; x++){ + this.createHtmlEmptySkillField(tb); + } + }else{ + tb.append("<center><table><tr><td width=270 align=center height="+36*buffsPerPage+"><font color=FF0000>I am sorry. I have no buffs for you now.</font></td></tr></table></center>"); + } + + tb.append("<br>"); + tb.append("<center><table><tr>"); + + if(sellBuffsCount > 0){ + if(buffsCount > 1*buffsPerPage){ + this.subPageButton(tb, 0); + this.subPageButton(tb, 1); + } + if(buffsCount > 2*buffsPerPage){ + this.subPageButton(tb, 2); + } + if(buffsCount > 3*buffsPerPage){ + this.subPageButton(tb, 3); + } + if(buffsCount > 4*buffsPerPage){ + this.subPageButton(tb, 4); + } + } + + tb.append("<td width=102>"); + tb.append("<button value=\"Back\" action=\"bypass -h sellbuffpage0\" width=100 height=23 back=\"L2UI_ch3.bigbutton_down\" fore=\"L2UI_ch3.bigbutton\">"); + tb.append("</td></tr></table></center>"); + + tb.append("</body></html>"); + + }else{ + tb.append("<html><title>"+seller.getName()+"("+seller.getLevel()+") price for 1 buff: "+seller.getBuffPrice()+" adena</title><body>"); + + tb.append("<br><center>Choose buffs for:<br>"); + tb.append("<table><tr>"); + tb.append("<td><center><button value=\"Player\" action=\"bypass -h sellbuffpage1\" width=100 height=23 back=\"L2UI_ch3.bigbutton_down\" fore=\"L2UI_ch3.bigbutton\"></center></td>"); + tb.append("<td><center><button value=\"Pet\" action=\"bypass -h sellbuffpage2\" width=100 height=23 back=\"L2UI_ch3.bigbutton_down\" fore=\"L2UI_ch3.bigbutton\"></center></td>"); + tb.append("</tr></table>"); + + tb.append("<br>"); + + if(seller.getClassId().getId() != 96 && seller.getClassId().getId() != 14 && seller.getClassId().getId() != 104 && seller.getClassId().getId() != 28){ + if(Config.SELL_BUFFSET_ENABLED && Config.SELL_BUFF_MIN_LVL <= seller.getLevel() && Config.SELL_BUFFSET_MIN_LVL <= seller.getLevel() && (Config.SELL_BUFFSET_WARRIOR.size() > 0 || Config.SELL_BUFFSET_MAGE.size() > 0 || Config.SELL_BUFFSET_RECHARGER.size() > 0 || Config.SELL_BUFFSET_TANKER.size() > 0)){ + tb.append("<br><br><center>Schemes</center><br>"); + tb.append("<table><tr>"); + tb.append("<td><center>Player</center></td><td><center>Pet</center></td>"); + tb.append("</tr><tr>"); + tb.append("<td><center><button value=\"Fighter\" action=\"bypass -h zbuffset1\" width=100 height=23 back=\"L2UI_ch3.bigbutton_down\" fore=\"L2UI_ch3.bigbutton\"></center></td>"); + tb.append("<td><center><button value=\"Fighter\" action=\"bypass -h zpetbuff1\" width=100 height=23 back=\"L2UI_ch3.bigbutton_down\" fore=\"L2UI_ch3.bigbutton\"></center></td>"); + tb.append("</tr><tr>"); + tb.append("<td><center><button value=\"Mage\" action=\"bypass -h zbuffset2\" width=100 height=23 back=\"L2UI_ch3.bigbutton_down\" fore=\"L2UI_ch3.bigbutton\"></center></td>"); + tb.append("<td><center><button value=\"Mage\" action=\"bypass -h zpetbuff2\" width=100 height=23 back=\"L2UI_ch3.bigbutton_down\" fore=\"L2UI_ch3.bigbutton\"></center></td>"); + tb.append("</tr><tr>"); + tb.append("<td><center><button value=\"Recharger\" action=\"bypass -h zbuffset3\" width=100 height=23 back=\"L2UI_ch3.bigbutton_down\" fore=\"L2UI_ch3.bigbutton\"></center></td>"); + tb.append("<td><center><button value=\"Recharger\" action=\"bypass -h zpetbuff3\" width=100 height=23 back=\"L2UI_ch3.bigbutton_down\" fore=\"L2UI_ch3.bigbutton\"></center></td>"); + tb.append("</tr><tr>"); + tb.append("<td><center><button value=\"Tank\" action=\"bypass -h zbuffset4\" width=100 height=23 back=\"L2UI_ch3.bigbutton_down\" fore=\"L2UI_ch3.bigbutton\"></center></td>"); + tb.append("<td><center><button value=\"Tank\" action=\"bypass -h zpetbuff4\" width=100 height=23 back=\"L2UI_ch3.bigbutton_down\" fore=\"L2UI_ch3.bigbutton\"></center></td>"); + tb.append("</tr></table>"); + } + } + if(seller.getBuffPrice() >= Config.SELL_BUFF_PUNISHED_PRICE){ + tb.append("<br><br><font color=FF0000>Be careful! <br>Buff price is very high!</font>"); + } + tb.append("</center></body></html>"); + } + + + return tb; + + } + + /** + * Send html response to buyer. + * @param seller + * @param buyer + * @param error - if set true, return first page and send msg to buyer with error type. + */ + public void sendBuyerResponse(L2PcInstance seller, L2PcInstance buyer, boolean error){ + + if(seller != null){ + if(seller.isSellBuff() && seller != buyer){ + TextBuilder tb = null; + if(!error){ + tb = buyer.getSellBuffMsg().buyerResponse(seller, buyer); //buyer == this from l2pcinstance + }else{ + this.setLastPage(0); + this.setSubPage(0); + tb = buyer.getSellBuffMsg().buyerResponse(seller, buyer); + } + NpcHtmlMessage n = new NpcHtmlMessage(0); + n.setHtml(tb.toString()); + buyer.sendPacket(n); + } + } + } + + public void sendSellerResponse(L2PcInstance seller){ + TextBuilder tb = new TextBuilder(0); + //create sell + if(!seller.isSellBuff()){ + tb.append("<html><body><center>"); + tb.append("Hello , by completing this form<br>you will be able to sell buffs."); + tb.append("<br>Players will be able,<br>targeting you to take your buff services<br>"); + tb.append("<br>You will be rewarded with adenas<br>for each buff a player takes."); + tb.append("<br><center>Now choose the price:</center><br>"); + tb.append("<center><edit var=\"pri\" width=120 height=15></center><br><br>"); + tb.append("<center><button value=\"Confirm\" action=\"bypass -h actr $pri\" width=100 height=23 back=\"L2UI_ch3.bigbutton_down\" fore=\"L2UI_ch3.bigbutton\">"); + tb.append("</center></body></html>"); + //abort sell + }else{ + tb.append("<html><body><center>"); + tb.append("<br>Actual buff price: "+seller.getBuffPrice()+"<br>"); + tb.append("Would you abort selling buffs?<br><br>"); + tb.append("<center><button value=\"Abort\" action=\"bypass -h pctra\" width=100 height=23 back=\"L2UI_ch3.bigbutton_down\" fore=\"L2UI_ch3.bigbutton\">"); + tb.append("</center></body></html>"); + } + NpcHtmlMessage n = new NpcHtmlMessage(0); + n.setHtml(tb.toString()); + seller.sendPacket(n); + + } + + private void createHtmlSkillField(TextBuilder tb, int buffPage, String skillName, int skillId, int buffRowNumber){ + //buffPage mean buff for player = 1, or buff for pet = 2. + String buffType = ""; + if(buffPage == 2){ + buffType = "pet"; + } + + String col1 = ""; + String col2 = "LEVEL"; + + if(buffRowNumber % 2 == 0){ + col1 = " bgcolor=000000"; + col2 = "FFFFFF"; + } + + int desc_skillId = skillId; + + // if summoners skills (exception) + if(skillId == 4699 || skillId == 4700){ + skillId = 1331; + } + if(skillId == 4702 || skillId == 4703){ + skillId = 1332; + } + + String tmp_skillId = ""+skillId; + if(skillId < 1000){ + tmp_skillId = "0"+skillId; + } + + + + tb.append("<table"+col1+">"); + tb.append("<tr>"); + tb.append("<td width=40><button action=\"bypass -h "+buffType+"buff"+ desc_skillId+"\" width=32 height=32 back=\"icon.skill"+tmp_skillId+"\" fore=\"icon.skill"+tmp_skillId+"\"></td>"); + tb.append("<td width=240>"); + tb.append("<table>"); + tb.append("<tr><td width=240 align=left><font color=\""+col2+"\">"+skillName+"</td></tr>"); + tb.append("<tr><td width=240 align=left><font color=\"ae9977\">"+this.getSkillDescription(desc_skillId)+"</font></td></tr>"); + tb.append("</table>"); + tb.append("</td>"); + tb.append("</tr>"); + tb.append("</table>"); + } + + private void subPageButton(TextBuilder tb, int page){ + int btnValue = page+1; + tb.append("<td width=34>"); + if(_subPage == page){ + tb.append("<button value=\""+btnValue+"\" action=\"bypass -h sellbuffpage"+_lastPage+"sub"+page+"\" width=32 height=23 back=\"L2UI_ch3.bigbutton_dow\" fore=\"L2UI_ch3.bigbutto\">"); //wrong button bg for black bg. + }else{ + tb.append("<button value=\""+btnValue+"\" action=\"bypass -h sellbuffpage"+_lastPage+"sub"+page+"\" width=32 height=23 back=\"\" fore=\"\">"); + } + tb.append("</td>"); + } + + private void createHtmlEmptySkillField(TextBuilder tb){ + tb.append("<table>"); + tb.append("<tr>"); + tb.append("<td height=36></td>"); + tb.append("</tr>"); + tb.append("</table>"); + } + + private String getSkillDescription(int skillId){ + String desc = "&nbsp;"; + + Connection con = null; + try + { + con = L2DatabaseFactory.getInstance().getConnection(false); + PreparedStatement statement = con.prepareStatement("Select buffId, description from sellbuff_describe where buffId = ?"); + statement.setInt(1, skillId); + ResultSet rs = statement.executeQuery(); + + while(rs.next()) + { + desc = rs.getString("description"); + } + + rs.close(); + statement.close(); + statement = null; + rs = null; + } + catch(Exception e) + { + e.printStackTrace(); + } + finally + { + CloseUtil.close(con); + con = null; + } + return desc; + } + + public FastList<L2Skill> getBuffList(L2PcInstance seller){ + L2Skill[] skills = seller.getAllSkills(); + FastList<L2Skill> ba = new FastList<L2Skill>(); + + for(L2Skill s : skills){ + if(s == null) + continue; + // if not summoner classes and skill type == buff + if((seller.getClassId().getId() != 96 && seller.getClassId().getId() != 14 && seller.getClassId().getId() != 104 && seller.getClassId().getId() != 28)&&((s.getSkillType() == SkillType.BUFF || s.getSkillType() == SkillType.HEAL_PERCENT || s.getSkillType() == SkillType.COMBATPOINTHEAL) && s.isActive())){ + if(Config.SELL_BUFF_FILTER_ENABLED){ + if(seller.getClassId().getId() == 115 || seller.getClassId().getId() == 51){ //manual useless buffs check for dominator and overlord class + if(s.getId() != 1002 && s.getId() != 1006 && s.getId() != 1007 && s.getId() != 1009){ + ba.add(s); + } + }else if(seller.getClassId().getId() == 116 || seller.getClassId().getId() == 52){ //doomcryer and warcryer + if(s.getId() != 1003 && s.getId() != 1005){ + ba.add(s); + } + }else if(seller.getClassId().getId() == 97 || seller.getClassId().getId() == 16){ //cardinal and bishop + if(s.getId() == 1353 || s.getId() == 1307 || s.getId() == 1311){ + ba.add(s); + } + }else{ + ba.add(s); + } + }else{ + ba.add(s); + } + }else{ + L2Skill skill = null; + if(s.getId() == 1332){ + skill = SkillTable.getInstance().getInfo(4702, getSkillLevel(seller, 1332)); + ba.add(skill); + skill = SkillTable.getInstance().getInfo(4703, getSkillLevel(seller, 1332)); + ba.add(skill); + } + if(s.getId() == 1331){ + skill = SkillTable.getInstance().getInfo(4699, getSkillLevel(seller, 1331)); + ba.add(skill); + skill = SkillTable.getInstance().getInfo(4700, getSkillLevel(seller, 1331)); + ba.add(skill); + } + } + } + return ba; + } + + public FastList<L2Skill> getBuffsetList(L2PcInstance seller, FastList<String> buffset){ + + L2Skill[] skills = seller.getAllSkills(); + FastList<L2Skill> ba = new FastList<L2Skill>(); + + for(L2Skill s : skills){ + if(s == null) + continue; + + if(buffset.contains(Integer.toString(s.getId()))){ + // if not summoner classes and skill type == buff + if((seller.getClassId().getId() != 96 && seller.getClassId().getId() != 14 && seller.getClassId().getId() != 104 && seller.getClassId().getId() != 28)&&((s.getSkillType() == SkillType.BUFF || s.getSkillType() == SkillType.HEAL_PERCENT || s.getSkillType() == SkillType.COMBATPOINTHEAL) && s.isActive())){ + if(Config.SELL_BUFF_FILTER_ENABLED){ + if(seller.getClassId().getId() == 115 || seller.getClassId().getId() == 51){ //manual useless buffs check for dominator and overlord class + if(s.getId() != 1002 && s.getId() != 1006 && s.getId() != 1007 && s.getId() != 1009){ + ba.add(s); + } + }else if(seller.getClassId().getId() == 116 || seller.getClassId().getId() == 52){ //doomcryer and warcryer + if(s.getId() != 1003 && s.getId() != 1005){ + ba.add(s); + } + }else if(seller.getClassId().getId() == 97 || seller.getClassId().getId() == 16){ //cardinal and bishop + if(s.getId() == 1353 || s.getId() == 1307 || s.getId() == 1311){ + ba.add(s); + } + }else{ + ba.add(s); + } + }else{ + ba.add(s); + } + }else{ + if(s.getId() == 4699){ + ba.add(s); + } + if(s.getId() == 4700){ + ba.add(s); + } + if(s.getId() == 4702){ + ba.add(s); + } + if(s.getId() == 4703){ + ba.add(s); + } + } + } + } + return ba; + } + + public void setPage(L2PcInstance seller, L2PcInstance buyer, int page, int subPage){ + if(page == 1){ + buyer.getSellBuffMsg().setLastPage(1); + buyer.getSellBuffMsg().setSubPage(subPage); + }else if(page == 2){ + buyer.getSellBuffMsg().setLastPage(2); + buyer.getSellBuffMsg().setSubPage(subPage); + }else{ + buyer.getSellBuffMsg().setLastPage(0); + buyer.getSellBuffMsg().setSubPage(0); + } + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, false); + } + + public void buffBuyer(L2PcInstance seller, L2PcInstance buyer, int buffId){ + if(buyer.getDistanceSq(seller) > 5000){ + buyer.sendMessage("You must be closer the buffer!"); + //buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + buyer.setTarget(null); + }else if(!seller.isSellBuff()){ + buyer.sendMessage("You cant buy buffs now!"); + return; + }else if(!this.enoughSpiritOreForBuff(seller, buffId)){ + if(!seller.isOffline()){ + seller.sendMessage("You can't sell buff, you haven't Spirit Ore for use skill!"); + } + buyer.sendMessage("You can't buff now. Buff seller has no item for use skill!"); + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, false); + }else{ + int buffprice = seller.getBuffPrice(); + + if(buyer.getInventory().getItemByItemId(57) == null || buyer.getInventory().getItemByItemId(57).getCount() < buffprice){ + buyer.sendMessage("Not enought adena!"); + }else{ + try{ + //get buff data + L2Skill skill = SkillTable.getInstance().getInfo(buffId, getSkillLevel(seller, buffId)); + + //single skill mp consume + if(Config.SELL_BUFF_SKILL_MP_ENABLED){ + if(seller.getCurrentMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER >= (skill.getMpConsume()+1)){ + seller.setCurrentMp(Math.round(seller.getCurrentMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER - skill.getMpConsume())/Config.SELL_BUFF_SKILL_MP_MULTIPLIER); + }else{ + buyer.sendMessage("Buffer has no Mana Points ("+Math.round(seller.getCurrentMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER)+" / "+Math.round(seller.getMaxMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER)+")"); + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, false); + return; + } + } + //add adena for seller + seller.addItem("buff sell", 57, buffprice, seller, true); + + //remove adena from buyer + buyer.destroyItemByItemId("buff sell", 57, buffprice, buyer, false); + + //destroy Spirit Ore: + destroySpiritOre(seller, buffId); + + //give buffs for buyer + skill.getEffects(buyer, buyer); + + buyer.sendMessage("You buyed: "+skill.getName()+" for "+seller.getBuffPrice()+" adena."); + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, false); + + }catch(Exception e){ + e.printStackTrace(); + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + } + } + } + } + + public void buffBuyerPet(L2PcInstance seller, L2PcInstance buyer, int buffId){ + //checking pet/summon if error return to first page; + if(buyer.getPet() == null || buyer.getPet().isDead()){ + //buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + buyer.sendMessage("You must summon your pet first!"); + buyer.setTarget(null); + }else if(buyer.getDistanceSq(seller) > 10000){ + //buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + buyer.sendMessage("Your pet must be closer the buffer!"); + buyer.setTarget(null); + }else if(!seller.isSellBuff()){ + buyer.sendMessage("You cant buy buffs now!"); + return; + }else if(!this.enoughSpiritOreForBuff(seller, buffId)){ + if(!seller.isOffline()){ + seller.sendMessage("You can't sell buff, you haven't Spirit Ore for use skill!"); + } + buyer.sendMessage("You can't buff now. Buff seller has no item for use skill!"); + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, false); + }else{ + int buffprice = seller.getBuffPrice(); + + if(buyer.getInventory().getItemByItemId(57) == null || buyer.getInventory().getItemByItemId(57).getCount() < buffprice){ + buyer.sendMessage("Not enought adena!"); + }else{ + + try{ + //get buff data + L2Skill skill = SkillTable.getInstance().getInfo(buffId, getSkillLevel(seller, buffId)); + + // single skill mp consume + if(Config.SELL_BUFF_SKILL_MP_ENABLED){ + if(seller.getCurrentMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER >= (skill.getMpConsume()+1)){ + seller.setCurrentMp(Math.round(seller.getCurrentMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER - skill.getMpConsume())/Config.SELL_BUFF_SKILL_MP_MULTIPLIER); + }else{ + buyer.sendMessage("Buffer has no Mana Points ("+Math.round(seller.getCurrentMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER)+" / "+Math.round(seller.getMaxMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER)+")"); + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + return; + } + } + + //buff seller + seller.addItem("buff sell", 57, buffprice, seller, true); + + //buff buyer + buyer.destroyItemByItemId("buff sell", 57, buffprice, buyer, false); + + //destroy Spirit Ore: + destroySpiritOre(seller, buffId); + + //give buffs for pet + skill.getEffects(buyer.getPet(), buyer.getPet()); + + + buyer.sendMessage("You buyed: "+skill.getName()+" for "+seller.getBuffPrice()+" adena, for your pet."); + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, false); + + + + }catch(Exception e){ + e.printStackTrace(); + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + } + } + } + } + + public void buffsetBuyer(L2PcInstance seller, L2PcInstance buyer, int setId){ + String buffSetName = " "; + FastList<L2Skill> ba = new FastList<L2Skill>(); + //---------------------------------------------------------------------------------------------- + if(setId == 1){ + ba = seller.getSellBuffMsg().getBuffsetList(seller, Config.SELL_BUFFSET_WARRIOR); + buffSetName = " Warrior "; + }else if(setId == 2){ + ba = seller.getSellBuffMsg().getBuffsetList(seller, Config.SELL_BUFFSET_MAGE); + buffSetName = " Mage "; + }else if(setId == 3){ + ba = seller.getSellBuffMsg().getBuffsetList(seller, Config.SELL_BUFFSET_RECHARGER); + buffSetName = " Recharger "; + }else if(setId == 4){ + ba = seller.getSellBuffMsg().getBuffsetList(seller, Config.SELL_BUFFSET_TANKER); + buffSetName = " Tanker "; + } + + int buffsetSize = ba.size(); + + if(buyer.getDistanceSq(seller) > 5000){ + buyer.sendMessage("You must be closer the buffer!"); + //buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + buyer.setTarget(null); + }else if(!seller.isSellBuff()){ + buyer.sendMessage("You cant buy buffs now!"); + return; + }else{ + int buffprice = seller.getBuffPrice(); + if(seller.getBuffPrice() == 0){ + buyer.sendMessage("This buffset is empty!"); + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + }else if(buyer.getInventory().getItemByItemId(57) == null || buyer.getInventory().getItemByItemId(57).getCount() < buffprice*buffsetSize){ + buyer.sendMessage("Not enought adena!"); + }else{ + try{ + boolean mpOK = true; + boolean soOK = true; + int mpConsumeSum = 0; + int soConsumeSum = 0; //Spirit Ore sum. + + if(Config.SELL_BUFF_SKILL_MP_ENABLED || Config.SELL_BUFF_SKILL_ITEM_CONSUME_ENABLED){ + // calculate all skills set mana use: + for(L2Skill p : ba){ + L2Skill skill = SkillTable.getInstance().getInfo(p.getId(), getSkillLevel(seller, p.getId())); + if(Config.SELL_BUFF_SKILL_MP_ENABLED){ + mpConsumeSum += skill.getMpConsume(); + } + if(Config.SELL_BUFF_SKILL_ITEM_CONSUME_ENABLED){ + soConsumeSum += getSkillConsumeSOCount(p.getId(), p.getLevel()); + } + } + // set ok == false if buffset mp cost greater than seller current mp. + if(mpConsumeSum > 0 && (mpConsumeSum + 1) > seller.getCurrentMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER){ + mpOK = false; + } + // set ok == false if buffset require more SO count than count SO in inventory. + if(soConsumeSum > 0 && (seller.getInventory().getItemByItemId(3031) == null || soConsumeSum > seller.getInventory().getItemByItemId(3031).getCount())){ + soOK = false; + } + } + + if(mpOK && soOK){ + for(L2Skill p : ba){ + L2Skill skill = SkillTable.getInstance().getInfo(p.getId(), getSkillLevel(seller, p.getId())); + + //give buffs + skill.getEffects(buyer, buyer); + + //destroy Spirit Ore: + destroySpiritOre(seller, skill.getId()); + + buyer.sendMessage("You buyed: "+skill.getName()); + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, false); + if(Config.SELL_BUFF_SKILL_MP_ENABLED){ + seller.setCurrentMp(Math.round(seller.getCurrentMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER - skill.getMpConsume())/Config.SELL_BUFF_SKILL_MP_MULTIPLIER); + } + } + + //buff seller + seller.addItem("buff sell", 57, buffprice*buffsetSize, seller, true); + + //buff buyer + buyer.destroyItemByItemId("buff sell", 57, buffprice*buffsetSize, buyer, false); + + buyer.sendMessage("You bought"+buffSetName+"buffs for: "+buffprice*buffsetSize+" adena."); + }else{ + if(!mpOK){ + buyer.sendMessage("Buffer has no Mana Points for this set ("+Math.round(seller.getCurrentMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER)+" / "+Math.round(seller.getMaxMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER)+")"); + } + if(!soOK){ + buyer.sendMessage("You can't buff now. Buff seller has no item for use skill!"); + seller.sendMessage("You can't sell buff, you haven't Spirit Ore for use skill!"); + } + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + } + }catch(Exception e){ + e.printStackTrace(); + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + } + } + } + } + + public void buffsetBuyerPet(L2PcInstance seller, L2PcInstance buyer, int setId){ + String buffSetName = " "; + FastList<L2Skill> ba = new FastList<L2Skill>(); + //---------------------------------------------------------------------------------------------- + if(setId == 1){ + ba = seller.getSellBuffMsg().getBuffsetList(seller, Config.SELL_BUFFSET_WARRIOR); + buffSetName = " Warrior "; + }else if(setId == 2){ + ba = seller.getSellBuffMsg().getBuffsetList(seller, Config.SELL_BUFFSET_MAGE); + buffSetName = " Mage "; + }else if(setId == 3){ + ba = seller.getSellBuffMsg().getBuffsetList(seller, Config.SELL_BUFFSET_RECHARGER); + buffSetName = " Recharger "; + }else if(setId == 4){ + ba = seller.getSellBuffMsg().getBuffsetList(seller, Config.SELL_BUFFSET_TANKER); + buffSetName = " Tanker "; + } + + int buffsetSize = ba.size(); + + //checking pet/summon if error return to first page; + if(buyer.getPet() == null || buyer.getPet().isDead()){ + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + buyer.sendMessage("You must summon your pet first!"); + }else if(buyer.getDistanceSq(seller) > 10000){ + //buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + buyer.sendMessage("Your pet must be closer the buffer!"); + buyer.setTarget(null); + }else if(!seller.isSellBuff()){ + buyer.sendMessage("You cant buy buffs now!"); + return; + }else{ + int buffprice = seller.getBuffPrice(); + if(seller.getBuffPrice() == 0){ + buyer.sendMessage("This buffset is empty!"); + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + }else if(buyer.getInventory().getItemByItemId(57) == null || buyer.getInventory().getItemByItemId(57).getCount() < buffprice){ + buyer.sendMessage("Not enought adena!"); + }else{ + + try{ + boolean mpOK = true; + boolean soOK = true; + int mpConsumeSum = 0; + int soConsumeSum = 0; //Spirit Ore sum. + + if(Config.SELL_BUFF_SKILL_MP_ENABLED || Config.SELL_BUFF_SKILL_ITEM_CONSUME_ENABLED){ + // calculate all skills set mana use: + for(L2Skill p : ba){ + L2Skill skill = SkillTable.getInstance().getInfo(p.getId(), getSkillLevel(seller, p.getId())); + if(Config.SELL_BUFF_SKILL_MP_ENABLED){ + mpConsumeSum += skill.getMpConsume(); + } + if(Config.SELL_BUFF_SKILL_ITEM_CONSUME_ENABLED){ + soConsumeSum += getSkillConsumeSOCount(p.getId(), p.getLevel()); + } + } + // set ok == false if buffset mp cost greater than seller current mp. + if(mpConsumeSum > 0 && (mpConsumeSum + 1) > seller.getCurrentMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER){ + mpOK = false; + } + // set ok == false if buffset require more SO count than count SO in inventory. + if(soConsumeSum > 0 && (seller.getInventory().getItemByItemId(3031) == null || soConsumeSum > seller.getInventory().getItemByItemId(3031).getCount())){ + soOK = false; + } + } + + if(mpOK && soOK){ + for(L2Skill p : ba){ + L2Skill skill = SkillTable.getInstance().getInfo(p.getId(), getSkillLevel(seller, p.getId())); + + //give buffs + skill.getEffects(buyer.getPet(), buyer.getPet()); + + //destroy Spirit Ore: + destroySpiritOre(seller, skill.getId()); + + buyer.sendMessage("You buyed: "+skill.getName()); + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, false); + if(Config.SELL_BUFF_SKILL_MP_ENABLED){ + seller.setCurrentMp(Math.round(seller.getCurrentMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER - skill.getMpConsume())/Config.SELL_BUFF_SKILL_MP_MULTIPLIER); + } + } + + //buff seller + seller.addItem("buff sell", 57, buffprice*buffsetSize, seller, true); + + //buff buyer + buyer.destroyItemByItemId("buff sell", 57, buffprice*buffsetSize, buyer, false); + + buyer.sendMessage("You bought"+buffSetName+"buffs for: "+buffprice*buffsetSize+" adena."); + }else{ + if(!mpOK){ + buyer.sendMessage("Buffer has no Mana Points for this set ("+Math.round(seller.getCurrentMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER)+" / "+Math.round(seller.getMaxMp()*Config.SELL_BUFF_SKILL_MP_MULTIPLIER)+")"); + } + if(!soOK){ + buyer.sendMessage("You can't buff now. Buff seller has no item for use skill!"); + seller.sendMessage("You can't sell buff, you haven't Spirit Ore for use skill!"); + } + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + } + }catch(Exception e){ + e.printStackTrace(); + buyer.getSellBuffMsg().sendBuyerResponse(seller, buyer, true); + } + } + } + } + + public void startBuffStore(L2PcInstance seller, int price, boolean saveSellerData){ + if(price <= 0){ + seller.sendMessage("Too low price. Min is 1 adena."); + return; + } + + if(price > 2000000000){ + seller.sendMessage("Too big price. Max is 2 000 000 000 adena."); + return; + } + + if(saveSellerData){ + saveSellerData(seller); + } + + seller.setBuffPrice(price); + seller.sitDown(); + seller.setSellBuff(true); + + if(seller.getClassId().getId() < 90){ //if 2nd profession or lower. + seller.getAppearance().setTitleColor(0xFFDD); //dark green (yellow now) + }else{ + seller.getAppearance().setTitleColor(0xFF00); //light green + } + seller.setTitle(getClassName(seller.getClassId().getId())); //set title like class name + seller.getAppearance().setNameColor(0x1111); + seller.broadcastUserInfo(); + seller.broadcastTitleInfo(); + + } + + public void stopBuffStore(L2PcInstance seller){ + + restoreSellerData(seller); + + seller.broadcastUserInfo(); + seller.broadcastTitleInfo(); + + seller.setSellBuff(false); + seller.standUp(); + + } + + private void saveSellerData(L2PcInstance seller){ + Connection con = null; + try + { + con = L2DatabaseFactory.getInstance().getConnection(false); + PreparedStatement statement; + statement = con.prepareStatement("CALL sellbuff_saveSellerData(?,?,?,?)"); + statement.setInt(1, seller.getObjectId()); + statement.setString(2, seller.getTitle()); + statement.setInt(3, seller.getAppearance().getTitleColor()); + statement.setInt(4, seller.getAppearance().getNameColor()); + statement.execute(); + statement.close(); + statement = null; + } + catch(Exception e) + { + if(Config.ENABLE_ALL_EXCEPTIONS) + e.printStackTrace(); + } + finally + { + CloseUtil.close(con); + con = null; + } + } + + public void restoreSellerData(L2PcInstance seller){ + //int defaultNickColor = 16777215; // white + //int defaultTitleColor = 16777079; // light blue + + Connection con = null; + try + { + con = L2DatabaseFactory.getInstance().getConnection(false); + PreparedStatement statement; + statement = con.prepareStatement("CALL sellbuff_restoreSellerData(?)"); + statement.setInt(1, seller.getObjectId()); + + ResultSet res = statement.executeQuery(); + + while(res.next()) + { + seller.setTitle(res.getString("lastTitle")); + seller.getAppearance().setTitleColor(Integer.parseInt(res.getString("lastTitleColor"))); + seller.getAppearance().setNameColor(Integer.parseInt(res.getString("lastNameColor"))); + } + res.close(); + res = null; + statement.close(); + statement = null; + } + catch(Exception e) + { + if(Config.ENABLE_ALL_EXCEPTIONS) + e.printStackTrace(); + } + finally + { + CloseUtil.close(con); + con = null; + } + } + + /** + * Returns skill consume count (Spirit Ore count). + * @param skillId + * @param skillLvl + * @return + */ + private int getSkillConsumeSOCount(int skillId, int skillLvl){ + // Buffs what consume items like Spirit Ore + // {skillId, skillLvl, itemConsumeId, itemConsumeCount} + int[][] skillsData = { + {1388,1,3031,1}, + {1388,2,3031,2}, + {1388,3,3031,3}, + {1389,1,3031,1}, + {1389,2,3031,2}, + {1389,3,3031,3}, + {1356,1,3031,10}, + {1397,1,3031,1}, + {1397,2,3031,2}, + {1397,3,3031,3}, + {1355,1,3031,10}, + {1357,1,3031,10}, + {1416,1,3031,20}, + {1414,1,3031,40}, + {1391,1,3031,4}, + {1391,2,3031,8}, + {1391,3,3031,12}, + {1390,1,3031,4}, + {1390,2,3031,8}, + {1390,3,3031,12}, + {1363,1,3031,40}, + {1413,1,3031,40}, + {1323,1,3031,5} + }; + + for(int i=0 ; i<skillsData.length ; i++){ + if(skillsData[i][0] == skillId && skillsData[i][1] == skillLvl){ + return skillsData[i][3]; + } + } + return 0; + } + + private boolean enoughSpiritOreForBuff(L2PcInstance seller, int skillId){ + if(Config.SELL_BUFF_SKILL_ITEM_CONSUME_ENABLED){ + if(getSkillConsumeSOCount(skillId, seller.getSkillLevel(skillId)) > 0){ + // 3031 == Spirit Ore ID + if(seller.getInventory().getItemByItemId(3031) == null || seller.getInventory().getItemByItemId(3031).getCount() < getSkillConsumeSOCount(skillId, seller.getSkillLevel(skillId))){ + return false; + } + } + } + return true; + } + + private void destroySpiritOre(L2PcInstance seller, int skillId){ + if(Config.SELL_BUFF_SKILL_ITEM_CONSUME_ENABLED){ + if(seller.getInventory().getItemByItemId(3031) != null && seller.getInventory().getItemByItemId(3031).getCount() >= getSkillConsumeSOCount(skillId, seller.getSkillLevel(skillId))){ + seller.destroyItemByItemId("buff sell", 3031, getSkillConsumeSOCount(skillId, seller.getSkillLevel(skillId)), seller, false); + } + } + } + + private String getClassName(int classId){ + switch (classId) { + case 14: return "Warlock"; + case 96: return "ArcanaLord"; + case 16: return "Bishop"; + case 97: return "Cardinal"; + case 17: return "Prophet"; + case 98: return "Hierophant"; + case 21: return "SwordSinger"; + case 100: return "SwordMuse"; + case 28: return "Elem.Summoner"; + case 104: return "Elem.Master"; + case 29: return "Oracle"; + case 30: return "Elder"; + case 105: return "EvaSaint"; + case 34: return "BladeDancer"; + case 107: return "SpectralDancer"; + case 42: return "ShilenOracle"; + case 43: return "ShilenElder"; + case 112: return "ShilenSaint"; + case 50: return "Shaman"; + case 51: return "Overlord"; + case 115: return "Dominator"; + case 52: return "Warcryer"; + case 116: return "Doomcryer"; + + default: return "Buff Sell"; + } + } + + /** + * Special summoners skill level or normal skill level. + * @param seller + * @param skillId + * @return + */ + private int getSkillLevel(L2PcInstance seller, int skillId){ + + if(seller.getClassId().getId() != 96 && seller.getClassId().getId() != 14 && seller.getClassId().getId() != 104 && seller.getClassId().getId() != 28){ + return seller.getSkillLevel(skillId); + } + + // summon lvl != summon buff lvl, example: feline queen skill lvl != feline queen buff lvl. + // skill levels by current db: min: 5, max: 8. + if(seller.getLevel() >= 56 && seller.getLevel() <= 57){ + return 5; + } + if(seller.getLevel() >= 58 && seller.getLevel() <= 67){ + return 6; + } + if(seller.getLevel() >= 68 && seller.getLevel() <= 73){ + return 7; + } + if(seller.getLevel() >= 74){ + return 8; + } + return 1; + } + +} Index: head-src/com/l2jfrozen/Config.java =================================================================== --- head-src/com/l2jfrozen/Config.java (revision 991) +++ head-src/com/l2jfrozen/Config.java (working copy) @@ -616,7 +616,28 @@ public static int FS_PARTY_MEMBER_COUNT; public static boolean ALLOW_QUAKE_SYSTEM; public static boolean ENABLE_ANTI_PVP_FARM_MSG; - + public static boolean SELL_BUFF_ENABLED; + public static FastList<String> SELL_BUFF_CLASS_LIST = new FastList<String>(); + public static FastMap<Integer, Integer> SELL_BUFF_SKILL_LIST; + public static boolean ALLOW_PARTY_BUFFS; + public static boolean ALLOW_CLAN_BUFFS; + public static int SELL_BUFF_PUNISHED_PRICE; + public static boolean SELL_BUFF_FILTER_ENABLED; + + public static int SELL_BUFF_MIN_LVL; + + public static boolean SELL_BUFFSET_ENABLED; + public static int SELL_BUFFSET_MIN_LVL; + public static FastList<String> SELL_BUFFSET_WARRIOR = new FastList<String>(); + public static FastList<String> SELL_BUFFSET_MAGE = new FastList<String>(); + public static FastList<String> SELL_BUFFSET_RECHARGER = new FastList<String>(); + public static FastList<String> SELL_BUFFSET_TANKER = new FastList<String>(); + + public static boolean OFFLINE_SELLBUFF_ENABLED; + public static boolean SELL_BUFF_SKILL_MP_ENABLED; + public static double SELL_BUFF_SKILL_MP_MULTIPLIER; + public static boolean SELL_BUFF_SKILL_ITEM_CONSUME_ENABLED; + public static FastList<String> SELL_BUFF_RESTRICTED_ZONES_IDS = new FastList<String>(); public static long CLICK_TASK; //============================================================ @@ -668,6 +689,103 @@ RAID_MIN_RESPAWN_MULTIPLIER = Float.parseFloat(otherSettings.getProperty("RaidMinRespawnMultiplier", "1.0")); RAID_MAX_RESPAWN_MULTIPLIER = Float.parseFloat(otherSettings.getProperty("RaidMaxRespawnMultiplier", "1.0")); ENABLE_AIO_SYSTEM = Boolean.parseBoolean(otherSettings.getProperty("EnableAioSystem", "True")); + SELL_BUFF_ENABLED = Boolean.parseBoolean(otherSettings.getProperty("SellBuffEnabled", "True")); + if(SELL_BUFF_ENABLED) //create map if system is enabled + { + SELL_BUFF_SKILL_LIST = new FastMap<Integer, Integer>(); + + String[] propertySplit; + propertySplit = otherSettings.getProperty("SellBuffSkillList", "").split(";"); + + for(String skill : propertySplit) + { + String[] skillSplit = skill.split(","); + if(skillSplit.length != 2) + { + System.out.println("[SellBuffSkillList]: invalid config property -> SellBuffSkillList \"" + skill + "\""); + } + else + { + try + { + SELL_BUFF_SKILL_LIST.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1])); + } + catch(NumberFormatException nfe) + { + if(Config.ENABLE_ALL_EXCEPTIONS) + nfe.printStackTrace(); + + if(!skill.equals("")) + { + System.out.println("[SellBuffSkillList]: invalid config property -> SellBuffSkillList \"" + skillSplit[0] + "\"" + skillSplit[1]); + } + } + } + } + } + if(SELL_BUFF_ENABLED) //create map if system is enabled + { + String SELL_BUFF_CLASS_STRING = otherSettings.getProperty("SellBuffClassList"); + int i=0; + for(String classId : SELL_BUFF_CLASS_STRING.split(",")){ + SELL_BUFF_CLASS_LIST.add(i,classId); + i++; + } + } + ALLOW_PARTY_BUFFS = Boolean.parseBoolean(otherSettings.getProperty("AllowPartyBuffs", "True")); + ALLOW_CLAN_BUFFS = Boolean.parseBoolean(otherSettings.getProperty("AllowClanBuffs", "True")); + SELL_BUFF_PUNISHED_PRICE = Integer.parseInt(otherSettings.getProperty("SellBuffPunishedPrice", "10000")); + SELL_BUFF_FILTER_ENABLED = Boolean.parseBoolean(otherSettings.getProperty("SellBuffFilterEnabled", "True")); + + SELL_BUFF_MIN_LVL = Integer.parseInt(otherSettings.getProperty("SellBuffMinLvl", "20")); + SELL_BUFFSET_ENABLED = Boolean.parseBoolean(otherSettings.getProperty("SellBuffsetEnabled", "True")); + + SELL_BUFFSET_MIN_LVL = Integer.parseInt(otherSettings.getProperty("SellBuffSetMinLvl", "79")); + + if(SELL_BUFFSET_ENABLED) //create map if system is enabled + { + String tempStr = ""; + int i = 0; + + tempStr = otherSettings.getProperty("SellBuffsetWarrior"); + i=0; + for(String skillId : tempStr.split(",")){ + SELL_BUFFSET_WARRIOR.add(i,skillId); + i++; + } + tempStr = otherSettings.getProperty("SellBuffsetMage"); + i=0; + for(String skillId : tempStr.split(",")){ + SELL_BUFFSET_MAGE.add(i,skillId); + i++; + } + tempStr = otherSettings.getProperty("SellBuffsetRecharger"); + i=0; + for(String skillId : tempStr.split(",")){ + SELL_BUFFSET_RECHARGER.add(i,skillId); + i++; + } + tempStr = otherSettings.getProperty("SellBuffsetTanker"); + i=0; + for(String skillId : tempStr.split(",")){ + SELL_BUFFSET_TANKER.add(i,skillId); + i++; + } + } + OFFLINE_SELLBUFF_ENABLED = Boolean.parseBoolean(otherSettings.getProperty("OfflineSellbuffEnabled", "True")); + SELL_BUFF_SKILL_MP_ENABLED = Boolean.parseBoolean(otherSettings.getProperty("SellBuffSkillMpEnabled", "False")); + SELL_BUFF_SKILL_MP_MULTIPLIER = Double.parseDouble(otherSettings.getProperty("SellBuffSkillMpMultiplier", "1.")); + SELL_BUFF_SKILL_ITEM_CONSUME_ENABLED = Boolean.parseBoolean(otherSettings.getProperty("SellBuffSkillItemConsumeEnabled", "True")); + //RESTRICTED ZONES IDS: + int i = 0; + String tempStr = otherSettings.getProperty("SellBuffRestrictedZonesIds"); + if(tempStr != null && tempStr.length() > 0){ + for(String rZoneId : tempStr.split(",")){ + SELL_BUFF_RESTRICTED_ZONES_IDS.add(i,rZoneId); + i++; + } + } + ALLOW_AIO_NCOLOR = Boolean.parseBoolean(otherSettings.getProperty("AllowAioNameColor", "True")); AIO_NCOLOR = Integer.decode("0x" + otherSettings.getProperty("AioNameColor", "88AA88")); ALLOW_AIO_TCOLOR = Boolean.parseBoolean(otherSettings.getProperty("AllowAioTitleColor", "True")); Index: head-src/com/l2jfrozen/gameserver/Shutdown.java =================================================================== --- head-src/com/l2jfrozen/gameserver/Shutdown.java (revision 991) +++ head-src/com/l2jfrozen/gameserver/Shutdown.java (working copy) @@ -610,7 +610,7 @@ try { - if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS) + if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE || Config.OFFLINE_SELLBUFF_ENABLED) && Config.RESTORE_OFFLINERS) OfflineTradeTable.storeOffliners(); } catch (Throwable t) Index: config/head/other.properties =================================================================== --- config/head/other.properties (revision 991) +++ config/head/other.properties (working copy) @@ -238,4 +238,136 @@ ClickTask = 50 # Crit announce -GMShowCritAnnouncerName = False \ No newline at end of file +GMShowCritAnnouncerName = False + +# ----------------------------------------- +# Sell Buff System - +# ----------------------------------------- +# Describe: +# System allow sell buffs by players who's classes are declared in SellBuffClassList. +# + +# Enable / Disable Sell Buff System +SellBuffEnabled = true + +# Allow offline buff sell. +OfflineSellbuffEnabled = True + +# Enable skill mp use. +SellBuffSkillMpEnabled = False + +# Multiplier skill mp consume. +# If character have 2000 mp, and multiplier = 100.0, sell buff mp = 200 000. +SellBuffSkillMpMultiplier = 1.0 + +# Enable specific skill item consume. Example: Skill Chant of Victory using Spirit Ore. +SellBuffSkillItemConsumeEnabled = True + +# Choose allowed classes. +# Format : classid,classid,classid,classid, ... classid,classid +SellBuffClassList = 15,16,97,17,98,29,30,105,42,43,112,50,116,51,115,100,21,107,34 + +# Allowed skillsId, and duration of this skills list: +# Format : skillid,duration;skillid,duration; ... ;skillid,duration +# SkillDuration is not implemented yet. +SellBuffSkillList = 33,7200;67,7200;264,7200;265,7200;266,7200;267,7200;268,7200;\ +269,7200;270,7200;271,7200;272,7200;273,7200;274,7200;275,7200;276,7200;277,7200;\ +304,7200;305,7200;306,7200;307,7200;308,7200;309,7200;310,7200;311,7200;\ +349,7200;363,7200;364,7200;365,7200;366,7200;\ +1002,7200;1003,7200;1004,7200;1005,7200;1006,7200;1007,7200;1008,7200;1009,7200;\ +1032,7200;1033,7200;1035,7200;1036,7200;1040,7200;1043,7200;1044,7200;1045,7200;1048,7200;\ +1059,7200;1062,7200;1068,7200;1073,7200;1077,7200;1078,7200;1085,7200;1086,7200;1087,7200;\ +1182,7200;1189,7200;1191,7200;1204,7200;1240,7200;1242,7200;1243,7200;1249,7200;1250,7200;1251,7200;1252,7200;1253,7200;\ +1257,7200;1259,7200;1260,7200;1261,7200;1268,7200;1279,7200;1280,7200;1281,7200;1282,7200;1284,7200;\ +1303,7200;1307,7200;1308,7200;1309,7200;1310,7200;1311,7200;1328,7200;1352,7200;1353,7200;1354,7200;1355,7200;1356,7200;\ +1357,7200;1362,7200;1363,7200;1364,7200;1365,7200;1388,7200;1389,7200;1390,7200;1391,7200;1392,7200;\ +1393,7200;1397,7200;1413,7200;1414,7200;1415,7200;1416,7200;\ +4699,7200;4700,7200;4702,7200;4703,7200;1323,7200 + +# Allow selling party buffs for no party members. +AllowPartyBuffs = True + +# Allow selling clan buffs for no clan members. +AllowClanBuffs = True + +# Buff buyer will be informed about buff price greater than SellBuffPunishedPrice. +# This option must be between <1, 2 000 000 000> (Default: 5000) (if it have other value, the option will be ignored). +SellBuffPunishedPrice = 5000 + +# If Enabled, remove useless buffs like shield lv.1 from dominator buff set. +# This option should be enabled, for helping players to get wrong buffs. +SellBuffFilterEnabled = True + +# SellBuffMinLvl default: 40 (lower level's not implemented yet) +SellBuffMinLvl = 40 + +# Enable/disable selling buffs sets like Warrior set, Mage set... +SellBuffsetEnabled = True + +# Set minimum character level to sell buffs sets (Default: 79) +SellBuffSetMinLvl = 79 + +# Define Buffsets: Warrior, Mage, Recharger, Tanker: +# Format: SellBuffsetWarrior = skillId,skillId,...,skillId +# No skills is disable show this buffset in menu. +SellBuffsetWarrior = 33,67,264,265,266,267,268,\ +269,270,271,272,273,274,275,276,277,\ +304,305,306,307,308,309,310,311,\ +349,363,364,365,366,\ +1002,1003,1004,1005,1006,1007,1008,1009,\ +1032,1033,1035,1036,1040,1043,1044,1045,1048,\ +1059,1062,1068,1073,1077,1078,1085,1086,1087,\ +1182,1189,1191,1204,1240,1242,1243,1249,1250,1251,1252,1253,\ +1257,1259,1260,1261,1268,1279,1280,1281,1282,1284,\ +1303,1307,1308,1309,1310,1311,1328,1352,1353,1354,1355,1356,\ +1357,1362,1363,1364,1365,1388,1389,1390,1391,1392,\ +1393,1397,1413,1414,1415,1416,\ +4699,4700,4702,4703,1323 +#--------------------------------------------------------------- +SellBuffsetMage =33,67,264,265,266,267,268,\ +269,270,271,272,273,274,275,276,277,\ +304,305,306,307,308,309,310,311,\ +349,363,364,365,366,\ +1002,1003,1004,1005,1006,1007,1008,1009,\ +1032,1033,1035,1036,1040,1043,1044,1045,1048,\ +1059,1062,1068,1073,1077,1078,1085,1086,1087,\ +1182,1189,1191,1204,1240,1242,1243,1249,1250,1251,1252,1253,\ +1257,1259,1260,1261,1268,1279,1280,1281,1282,1284,\ +1303,1307,1308,1309,1310,1311,1328,1352,1353,1354,1355,1356,\ +1357,1362,1363,1364,1365,1388,1389,1390,1391,1392,\ +1393,1397,1413,1414,1415,1416,\ +4699,4700,4702,4703,1323 +#--------------------------------------------------------------- +SellBuffsetRecharger = 33,67,264,265,266,267,268,\ +269,270,271,272,273,274,275,276,277,\ +304,305,306,307,308,309,310,311,\ +349,363,364,365,366,\ +1002,1003,1004,1005,1006,1007,1008,1009,\ +1032,1033,1035,1036,1040,1043,1044,1045,1048,\ +1059,1062,1068,1073,1077,1078,1085,1086,1087,\ +1182,1189,1191,1204,1240,1242,1243,1249,1250,1251,1252,1253,\ +1257,1259,1260,1261,1268,1279,1280,1281,1282,1284,\ +1303,1307,1308,1309,1310,1311,1328,1352,1353,1354,1355,1356,\ +1357,1362,1363,1364,1365,1388,1389,1390,1391,1392,\ +1393,1397,1413,1414,1415,1416,\ +4699,4700,4702,4703,1323 +#--------------------------------------------------------------- +SellBuffsetTanker = 33,67,264,265,266,267,268,\ +269,270,271,272,273,274,275,276,277,\ +304,305,306,307,308,309,310,311,\ +349,363,364,365,366,\ +1002,1003,1004,1005,1006,1007,1008,1009,\ +1032,1033,1035,1036,1040,1043,1044,1045,1048,\ +1059,1062,1068,1073,1077,1078,1085,1086,1087,\ +1182,1189,1191,1204,1240,1242,1243,1249,1250,1251,1252,1253,\ +1257,1259,1260,1261,1268,1279,1280,1281,1282,1284,\ +1303,1307,1308,1309,1310,1311,1328,1352,1353,1354,1355,1356,\ +1357,1362,1363,1364,1365,1388,1389,1390,1391,1392,\ +1393,1397,1413,1414,1415,1416,\ +4699,4700,4702,4703,1323 + +# Restricted zones id's. +# It's mean if 'SellBuffRestrictedZonesIds = 300003' , buff sell is impossible here. +# Format: zoneId,zoneId, ... ,zoneId,zoneId +# Default: SellBuffRestrictedZonesIds =(no spaces) +SellBuffRestrictedZonesIds = Index: head-src/com/l2jfrozen/gameserver/datatables/OfflineTradeTable.java =================================================================== --- head-src/com/l2jfrozen/gameserver/datatables/OfflineTradeTable.java (revision 991) +++ head-src/com/l2jfrozen/gameserver/datatables/OfflineTradeTable.java (working copy) @@ -142,6 +142,18 @@ stm_items.clearParameters(); } break; + case L2PcInstance.STORE_SELLBUFF: + if (!Config.OFFLINE_SELLBUFF_ENABLED) + continue; + title = ""; + + stm_items.setInt(1, pc.getObjectId()); + stm_items.setInt(2, 0); + stm_items.setLong(3, 0); + stm_items.setLong(4, pc.getBuffPrice()); + stm_items.executeUpdate(); + stm_items.clearParameters(); + break; default: //_log.info( "OfflineTradersTable[storeTradeItems()]: Error while saving offline trader: " + pc.getObjectId() + ", store type: "+pc.getPrivateStoreType()); //no save for this kind of shop @@ -254,6 +266,13 @@ player.setCreateList(createList); player.getCreateList().setStoreName(rs.getString("title")); break; + case L2PcInstance.STORE_SELLBUFF: + while (items.next()) + { + player.getSellBuffMsg().startBuffStore(player, items.getInt(4), false); + break; + } + break; default: _log.info("Offline trader "+player.getName()+" finished to sell his items"); } @@ -385,6 +404,18 @@ stm_items.clearParameters(); } break; + case L2PcInstance.STORE_SELLBUFF: + if (!Config.OFFLINE_SELLBUFF_ENABLED) + break; + title = ""; + + stm_items.setInt(1, pc.getObjectId()); + stm_items.setInt(2, 0); + stm_items.setLong(3, 0); + stm_items.setLong(4, pc.getBuffPrice()); + stm_items.executeUpdate(); + stm_items.clearParameters(); + break; default: //_log.info( "OfflineTradersTable[storeOffliner()]: Error while saving offline trader: " + pc.getObjectId() + ", store type: "+pc.getPrivateStoreType()); //no save for this kind of shop Index: head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java =================================================================== --- head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java (revision 991) +++ head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java (working copy) @@ -37,11 +37,13 @@ import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.VersionCmd; import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.Voting; import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.Wedding; +import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.sellbuff; /** * This class ... * @version $Revision: 1.1.4.6 $ $Date: 2009/05/12 19:44:09 $ */ +@SuppressWarnings("unused") public class VoicedCommandHandler { private static Logger _log = Logger.getLogger(GameServer.class.getName()); Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java =================================================================== --- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java (revision 991) +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java (working copy) @@ -121,6 +121,112 @@ { comeHere(activeChar); } + // SELL BUFF SYSTEM: -> + else if(_command.startsWith("sellbuffpage")){ //load page number (player or pet) //to sellbuff system. // + + int page = 0; + if(_command.length() == 13 || _command.length() == 17){ + String x = _command.substring(12,13); + try{ + page = Integer.parseInt(x); + }catch(Exception e){ + _log.info(e.getMessage()); + } + } + + int subPage = 0; + if(_command.length() == 17){ + String y = _command.substring(16,17); // zmieniono nie testowano. + try{ + subPage = Integer.parseInt(y); + }catch(Exception e){ + _log.info(e.getMessage()); + } + } + + + L2PcInstance target = null; + + if(activeChar.getTarget() instanceof L2PcInstance) + target = (L2PcInstance) activeChar.getTarget(); + + if(target == null) + return; + + activeChar.getSellBuffMsg().setPage(target, activeChar, page, subPage); + } + else if(_command.startsWith("buff")){ //load buffId from html->bypass. //to sellbuff system. // + String x = _command.substring(4); + int id = Integer.parseInt(x); + L2PcInstance target = null; + + if(activeChar.getTarget() instanceof L2PcInstance) + target = (L2PcInstance) activeChar.getTarget(); + + if(target == null) + return; + + activeChar.getSellBuffMsg().buffBuyer(target, activeChar, id); + } + else if(_command.startsWith("zbuffset")){ //load buffset from html->bypass. //to sellbuff system. // + String x = _command.substring(8); + int id = Integer.parseInt(x); + L2PcInstance target = null; + + if(activeChar.getTarget() instanceof L2PcInstance) + target = (L2PcInstance) activeChar.getTarget(); + + if(target == null) + return; + + activeChar.getSellBuffMsg().buffsetBuyer(target, activeChar, id); + } + else if(_command.startsWith("petbuff")){ //load buffId from html->bypass. //to sellbuff system. // + String x = _command.substring(7); + int id = Integer.parseInt(x); + L2PcInstance target = null; + + if(activeChar.getTarget() instanceof L2PcInstance) + target = (L2PcInstance) activeChar.getTarget(); + + if(target == null) + return; + + activeChar.getSellBuffMsg().buffBuyerPet(target, activeChar, id); + } + else if(_command.startsWith("zpetbuff")){ //load buff set from html->bypass. //to sellbuff system. // + String x = _command.substring(8); + int id = Integer.parseInt(x); + L2PcInstance target = null; + + if(activeChar.getTarget() instanceof L2PcInstance) + target = (L2PcInstance) activeChar.getTarget(); + + if(target == null) + return; + + activeChar.getSellBuffMsg().buffsetBuyerPet(target, activeChar, id); + } + else if(_command.startsWith("actr")){ //to sellbuff system. // + try{ + String l = _command.substring(5); + int p = 0; + + p = Integer.parseInt(l); + + activeChar.getSellBuffMsg().startBuffStore(activeChar, p, true); + }catch(Exception e){ + activeChar.sendMessage("Wrong field value!"); + } + } + else if(_command.startsWith("pctra")){ //to sellbuff system. // + try{ + activeChar.getSellBuffMsg().stopBuffStore(activeChar); + }catch(Exception e){ + + } + } + // -> SELL BUFF SYSTEM. else if(_command.startsWith("player_help ")) { playerHelp(activeChar, _command.substring(12)); Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java =================================================================== --- head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java (revision 991) +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java (working copy) @@ -618,6 +618,10 @@ // Color System checks - Start // Check if the custom PvP and PK color systems are enabled and if so check the character's counters // and apply any color changes that must be done. Thankz Kidzor + + // Sellbuff system: + activeChar.getSellBuffMsg().restoreSellerData(activeChar); + /** KidZor: Ammount 1 **/ if (activeChar.getPvpKills() >= Config.PVP_AMOUNT1 && Config.PVP_COLOR_SYSTEM_ENABLED) activeChar.updatePvPColor(activeChar.getPvpKills()); Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java =================================================================== --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java (revision 991) +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java (working copy) @@ -126,6 +126,7 @@ import com.l2jfrozen.gameserver.model.PcWarehouse; import com.l2jfrozen.gameserver.model.PetInventory; import com.l2jfrozen.gameserver.model.PlayerStatus; +import com.l2jfrozen.gameserver.custom.SellBuffMsg; import com.l2jfrozen.gameserver.model.ShortCuts; import com.l2jfrozen.gameserver.model.TradeList; import com.l2jfrozen.gameserver.model.actor.appearance.PcAppearance; @@ -520,6 +521,9 @@ /** The Constant STORE_PRIVATE_PACKAGE_SELL. */ public static final int STORE_PRIVATE_PACKAGE_SELL = 8; + + /** The Constant STORE_SELLBUFF. */ + public static final int STORE_SELLBUFF = 12; /** The fmt. */ private final SimpleDateFormat fmt = new SimpleDateFormat("H:mm."); @@ -1040,6 +1044,11 @@ /** The _hero. */ private boolean _hero = false; + /** If player is selling buffs value = true. */ + private boolean _sellbuff = false; + private int _buffprice = 0; + private SellBuffMsg _sbm = new SellBuffMsg(); + /** The _donator. */ private boolean _donator = false; @@ -4583,6 +4592,9 @@ return; } + if(isSellBuff()) + return; + if(L2Event.active && eventSitForced) { sendMessage("A dark force beyond your mortal understanding makes your knees to shake when you try to stand up ..."); @@ -7092,8 +7104,40 @@ // Target the new L2Object (add the target to the L2PcInstance _target, _knownObject and L2PcInstance to _KnownObject of the L2Object) super.setTarget(newTarget); + + if(Config.SELL_BUFF_ENABLED){ + if(newTarget instanceof L2PcInstance && ((L2PcInstance) newTarget).isSellBuff()){ + this.getSellBuffMsg().setLastPage(0); // Back to first page when new target. + L2PcInstance seller = (L2PcInstance)newTarget; + this.getSellBuffMsg().sendBuyerResponse(seller, this, false); + } + } + } + + + public boolean isSellBuff(){ + return _sellbuff; + } + + public void setSellBuff(boolean j){ + _sellbuff = j; + if(j){ + _privatestore = STORE_SELLBUFF; + }else{ + _privatestore = STORE_PRIVATE_NONE; + } + } + + public int getBuffPrice(){ + return _buffprice; + } + + public void setBuffPrice(int x){ + _buffprice = x; + } + /** * Return the active weapon instance (always equiped in the right hand).<BR> * <BR> @@ -9190,7 +9234,7 @@ * <li>3 : STORE_PRIVATE_BUY</li><BR> * <li>4 : buymanage</li><BR> * <li>5 : STORE_PRIVATE_MANUFACTURE</li><BR> - * + * <li>6 : PRIVATE_SELLBUFF</li><BR> * @param type the new private store type */ public void setPrivateStoreType(int type) @@ -17845,6 +17889,10 @@ { return Config.FREIGHT_SLOTS + (int) getStat().calcStat(Stats.FREIGHT_LIM, 0, null, null); } + + public SellBuffMsg getSellBuffMsg(){ + return _sbm; + } /** * Gets the dwarf recipe limit. Index: head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/sellbuff.java =================================================================== --- head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/sellbuff.java (revision 0) +++ head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/sellbuff.java (working copy) @@ -0,0 +1,112 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * http://www.gnu.org/copyleft/gpl.html + */ +package com.l2jfrozen.gameserver.handler.voicedcommandhandlers; + +import com.l2jfrozen.Config; +import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad; +import com.l2jfrozen.gameserver.handler.IVoicedCommandHandler; +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; + +/** + * + * + * @author Matthew + */ +public class sellbuff implements IVoicedCommandHandler +{ + private static final String[] VOICED_COMMANDS = {"sellbuffs"}; + + @SuppressWarnings("static-access") + @Override + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target) + { + if(activeChar == null) + return false; + + if(activeChar.isDead() || activeChar.isAlikeDead()){ + activeChar.sendMessage("You are dead , you can't sell at the moment"); + return false; + } + else if(activeChar.isInOlympiadMode() || Olympiad.getInstance().isRegistered(activeChar)){ + activeChar.sendMessage("You are in olympiad , you can't sell at the moment"); + return false; + } + else if(activeChar.atEvent){ + activeChar.sendMessage("You are in event , you can't sell at the moment"); + return false; + } + else if(!activeChar.isInsideZone(L2PcInstance.ZONE_PEACE)){ + activeChar.sendMessage("You are not in peacefull zone , you can sell only in peacefull zones"); + return false; + } + else if(isInRestrictedZone(activeChar)){ + activeChar.sendMessage("You can't sell in restricted zone"); + return false; + } + else if(activeChar.getPvpFlag() > 0 || activeChar.isInCombat() || activeChar.getKarma() > 0){ + activeChar.sendMessage("You are in combat mode , you can't sell at the moment"); + return false; + } + else if(!Config.SELL_BUFF_CLASS_LIST.contains(Integer.toString(activeChar.getClassId().getId()))){ + activeChar.sendMessage("Your class can't sell buffs"); + return false; + } + else if(activeChar.getLevel() < Config.SELL_BUFF_MIN_LVL){ + activeChar.sendMessage("You can sell buffs on "+Config.SELL_BUFF_MIN_LVL+" level"); + return false; + } + // summoner classes exception, buffs allowed from 56 level. + else if(activeChar.getClassId().getId() == 96 || activeChar.getClassId().getId() == 14 || activeChar.getClassId().getId() == 104 || activeChar.getClassId().getId() == 28){ + if(activeChar.getLevel() < 56){ + activeChar.sendMessage("You can sell buffs on 56 level"); + return false; + } + } + + activeChar.getSellBuffMsg().sendSellerResponse(activeChar); + + return true; + } + + + @Override + public String[] getVoicedCommandList() + { + return VOICED_COMMANDS; + } + + private boolean isInRestrictedZone(L2PcInstance activeChar){ + for(int i=0; i<Config.SELL_BUFF_RESTRICTED_ZONES_IDS.size(); i++){ + try{ + if(activeChar.isInsideZone(Integer.parseInt(Config.SELL_BUFF_RESTRICTED_ZONES_IDS.get(i)))){ + return true; + } + }catch(Exception e){ + return false; + } + + } + return false; + } + +} + + + +
  8. Well I added this code of aio system in the review of the most recent l2jhellas, so far everything was ok. the system is working but when i restart the character the aio skills disappear and i have to give the command // add_aio <days> could someone give me a solution of what may be happening? https://pastebin.com/8cQatb0t
  9. I even managed to adapt the problem. When I open the store, the character doesn’t sit down to sell if I understand him, he has no action and doesn’t make any mistake.
  10. Could someone help me adopt this model for l2jhellas? Index: config/server.properties =================================================================== --- config/server.properties (revision 339) +++ config/server.properties (working copy) @@ -286,4 +286,44 @@ ShowServerNews = False # Disable tutorial on new player game entrance. Default: False. -DisableTutorial = False \ No newline at end of file +DisableTutorial = False + +# ================================================================ +# Offline trade & craft +# ================================================================ + +# Option to enable or disable offline trade feature. +# Default: False +OfflineTradeEnable = True + +# Option to enable or disable offline craft feature. +# Default: False +OfflineCraftEnable = True + +# If set to True, offline shops will be possible only peace zones. +# Default: False +OfflineModeInPeaceZone = True + +# If set to True, players in offline shop mode won't take any damage, thus they can't be killed. +# Default: False +OfflineModeNoDamage = True + +# If set to True, name color will be changed then entering offline mode +OfflineSetNameColor = True + +# Color of the name in offline mode (if OfflineSetNameColor = True) +OfflineNameColor = 808080 + +#Restore offline traders/crafters after restart/shutdown. +# Default: false. +RestoreOffliners = True + +#Do not restore offline characters, after OfflineMaxDays days spent from first restore. +#Require server restart to disconnect expired shops. +#0 = disabled (always restore). +#Default: 10 +OfflineMaxDays = 10 + +#Disconnect shop after finished selling, buying. +#Default: True +OfflineDisconnectFinished = True \ No newline at end of file Index: java/net/sf/l2j/Config.java =================================================================== --- java/net/sf/l2j/Config.java (revision 339) +++ java/net/sf/l2j/Config.java (working copy) @@ -646,6 +646,17 @@ public static int ZONE_TOWN; public static boolean DISABLE_TUTORIAL; + /** Offline stores */ + public static boolean OFFLINE_TRADE_ENABLE; + public static boolean OFFLINE_CRAFT_ENABLE; + public static boolean OFFLINE_MODE_IN_PEACE_ZONE; + public static boolean OFFLINE_MODE_NO_DAMAGE; + public static boolean RESTORE_OFFLINERS; + public static int OFFLINE_MAX_DAYS; + public static boolean OFFLINE_DISCONNECT_FINISHED; + public static boolean OFFLINE_SET_NAME_COLOR; + public static int OFFLINE_NAME_COLOR; + // -------------------------------------------------- // Those "hidden" settings haven't configs to avoid admins to fuck their server // You still can experiment changing values here. But don't say I didn't warn you. @@ -1240,6 +1251,16 @@ ZONE_TOWN = server.getProperty("ZoneTown", 0); SERVER_NEWS = server.getProperty("ShowServerNews", false); DISABLE_TUTORIAL = server.getProperty("DisableTutorial", false); + + OFFLINE_TRADE_ENABLE = server.getProperty("OfflineTradeEnable", false); + OFFLINE_CRAFT_ENABLE = server.getProperty("OfflineCraftEnable", false); + OFFLINE_MODE_IN_PEACE_ZONE = server.getProperty("OfflineModeInPeaceZone", false); + OFFLINE_MODE_NO_DAMAGE = server.getProperty("OfflineModeNoDamage", false); + OFFLINE_SET_NAME_COLOR = server.getProperty("OfflineSetNameColor", false); + OFFLINE_NAME_COLOR = Integer.decode("0x" + server.getProperty("OfflineNameColor", "808080")); + RESTORE_OFFLINERS = server.getProperty("RestoreOffliners", false); + OFFLINE_MAX_DAYS = server.getProperty("OfflineMaxDays", 10); + OFFLINE_DISCONNECT_FINISHED = server.getProperty("OfflineDisconnectFinished", true); } else if (Server.serverMode == Server.MODE_LOGINSERVER) { Index: java/net/sf/l2j/gameserver/GameServer.java =================================================================== --- java/net/sf/l2j/gameserver/GameServer.java (revision 339) +++ java/net/sf/l2j/gameserver/GameServer.java (working copy) @@ -54,6 +54,7 @@ import net.sf.l2j.gameserver.datatables.MultisellData; import net.sf.l2j.gameserver.datatables.NpcTable; import net.sf.l2j.gameserver.datatables.NpcWalkerRoutesTable; +import net.sf.l2j.gameserver.datatables.OfflineTradersTable; import net.sf.l2j.gameserver.datatables.PetDataTable; import net.sf.l2j.gameserver.datatables.RecipeTable; import net.sf.l2j.gameserver.datatables.SkillTable; @@ -309,6 +310,9 @@ MovieMakerManager.getInstance(); + if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS) + OfflineTradersTable.getInstance().restoreOfflineTraders(); + if (Config.DEADLOCK_DETECTOR) { _log.info("Deadlock detector is enabled. Timer: " + Config.DEADLOCK_CHECK_INTERVAL + "s."); Index: java/net/sf/l2j/gameserver/Shutdown.java =================================================================== --- java/net/sf/l2j/gameserver/Shutdown.java (revision 339) +++ java/net/sf/l2j/gameserver/Shutdown.java (working copy) @@ -21,6 +21,7 @@ import net.sf.l2j.Config; import net.sf.l2j.L2DatabaseFactory; import net.sf.l2j.gameserver.datatables.BufferTable; +import net.sf.l2j.gameserver.datatables.OfflineTradersTable; import net.sf.l2j.gameserver.instancemanager.CastleManorManager; import net.sf.l2j.gameserver.instancemanager.FishingChampionshipManager; import net.sf.l2j.gameserver.instancemanager.FourSepulchersManager; @@ -119,6 +120,16 @@ { Util.printSection("Under " + MODE_TEXT[_shutdownMode] + " process"); + try + { + if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS) + OfflineTradersTable.getInstance().storeOffliners(); + } + catch (Throwable t) + { + _log.log(Level.WARNING, "Error saving offline shops.", t); + } + // disconnect players try { Index: java/net/sf/l2j/gameserver/datatables/OfflineTradersTable.java =================================================================== --- java/net/sf/l2j/gameserver/datatables/OfflineTradersTable.java (revision 0) +++ java/net/sf/l2j/gameserver/datatables/OfflineTradersTable.java (revision 0) @@ -0,0 +1,266 @@ +/* + * Copyright (C) 2004-2015 L2J Server + * + * This file is part of L2J Server. + * + * L2J Server is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * L2J Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package net.sf.l2j.gameserver.datatables; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.Calendar; +import java.util.logging.Level; +import java.util.logging.Logger; + +import net.sf.l2j.Config; +import net.sf.l2j.L2DatabaseFactory; +import net.sf.l2j.gameserver.LoginServerThread; +import net.sf.l2j.gameserver.model.L2ManufactureItem; +import net.sf.l2j.gameserver.model.L2ManufactureList; +import net.sf.l2j.gameserver.model.L2World; +import net.sf.l2j.gameserver.model.TradeList.TradeItem; +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; +import net.sf.l2j.gameserver.network.L2GameClient; +import net.sf.l2j.gameserver.network.L2GameClient.GameClientState; + +public class OfflineTradersTable +{ + private static Logger LOGGER = Logger.getLogger(OfflineTradersTable.class.getName()); + + // SQL DEFINITIONS + private static final String SAVE_OFFLINE_STATUS = "INSERT INTO character_offline_trade (`charId`,`time`,`type`,`title`) VALUES (?,?,?,?)"; + private static final String SAVE_ITEMS = "INSERT INTO character_offline_trade_items (`charId`,`item`,`count`,`price`) VALUES (?,?,?,?)"; + private static final String CLEAR_OFFLINE_TABLE = "DELETE FROM character_offline_trade"; + private static final String CLEAR_OFFLINE_TABLE_ITEMS = "DELETE FROM character_offline_trade_items"; + private static final String LOAD_OFFLINE_STATUS = "SELECT * FROM character_offline_trade"; + private static final String LOAD_OFFLINE_ITEMS = "SELECT * FROM character_offline_trade_items WHERE charId = ?"; + + public void storeOffliners() + { + try (Connection con = L2DatabaseFactory.getInstance().getConnection(); + PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE); + PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS); + PreparedStatement stm3 = con.prepareStatement(SAVE_OFFLINE_STATUS); + PreparedStatement stm_items = con.prepareStatement(SAVE_ITEMS)) + { + stm1.execute(); + stm2.execute(); + con.setAutoCommit(false); // avoid halfway done + + for (L2PcInstance pc : L2World.getInstance().getAllPlayers().values()) + { + try + { + if ((pc.getPrivateStoreType() != L2PcInstance.STORE_PRIVATE_NONE) && ((pc.getClient() == null) || pc.getClient().isDetached())) + { + stm3.setInt(1, pc.getObjectId()); // Char Id + stm3.setLong(2, pc.getOfflineStartTime()); + stm3.setInt(3, pc.getPrivateStoreType()); // store type + String title = null; + + switch (pc.getPrivateStoreType()) + { + case L2PcInstance.STORE_PRIVATE_BUY: + if (!Config.OFFLINE_TRADE_ENABLE) + continue; + + title = pc.getBuyList().getTitle(); + for (TradeItem i : pc.getBuyList().getItems()) + { + stm_items.setInt(1, pc.getObjectId()); + stm_items.setInt(2, i.getItem().getItemId()); + stm_items.setLong(3, i.getCount()); + stm_items.setLong(4, i.getPrice()); + stm_items.executeUpdate(); + stm_items.clearParameters(); + } + break; + + case L2PcInstance.STORE_PRIVATE_SELL: + case L2PcInstance.STORE_PRIVATE_PACKAGE_SELL: + if (!Config.OFFLINE_TRADE_ENABLE) + continue; + + title = pc.getSellList().getTitle(); + for (TradeItem i : pc.getSellList().getItems()) + { + stm_items.setInt(1, pc.getObjectId()); + stm_items.setInt(2, i.getObjectId()); + stm_items.setLong(3, i.getCount()); + stm_items.setLong(4, i.getPrice()); + stm_items.executeUpdate(); + stm_items.clearParameters(); + } + break; + + case L2PcInstance.STORE_PRIVATE_MANUFACTURE: + if (!Config.OFFLINE_CRAFT_ENABLE) + continue; + + title = pc.getCreateList().getStoreName(); + for (L2ManufactureItem i : pc.getCreateList().getList()) + { + stm_items.setInt(1, pc.getObjectId()); + stm_items.setInt(2, i.getRecipeId()); + stm_items.setLong(3, 0); + stm_items.setLong(4, i.getCost()); + stm_items.executeUpdate(); + stm_items.clearParameters(); + } + } + stm3.setString(4, title); + stm3.executeUpdate(); + stm3.clearParameters(); + con.commit(); // flush + } + } + catch (Exception e) + { + LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Error while saving offline trader: " + pc.getObjectId() + " " + e, e); + } + } + LOGGER.info(getClass().getSimpleName() + ": Offline traders stored."); + } + catch (Exception e) + { + LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Error while saving offline traders: " + e, e); + } + } + + public void restoreOfflineTraders() + { + LOGGER.info(getClass().getSimpleName() + ": Loading offline traders..."); + int nTraders = 0; + try (Connection con = L2DatabaseFactory.getInstance().getConnection(); + Statement stm = con.createStatement(); + ResultSet rs = stm.executeQuery(LOAD_OFFLINE_STATUS)) + { + while (rs.next()) + { + long time = rs.getLong("time"); + if (Config.OFFLINE_MAX_DAYS > 0) + { + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(time); + cal.add(Calendar.DAY_OF_YEAR, Config.OFFLINE_MAX_DAYS); + if (cal.getTimeInMillis() <= System.currentTimeMillis()) + continue; + } + + int type = rs.getInt("type"); + if (type == L2PcInstance.STORE_PRIVATE_NONE) + continue; + + L2PcInstance player = null; + + try + { + L2GameClient client = new L2GameClient(null); + client.setDetached(true); + player = L2PcInstance.restore(rs.getInt("charId")); + client.setActiveChar(player); + player.setOnlineStatus(true, false); + client.setAccountName(player.getAccountNamePlayer()); + client.setState(GameClientState.IN_GAME); + player.setClient(client); + player.setOfflineStartTime(time); + player.spawnMe(player.getX(), player.getY(), player.getZ()); + LoginServerThread.getInstance().addGameServerLogin(player.getAccountName(), client); + try (PreparedStatement stm_items = con.prepareStatement(LOAD_OFFLINE_ITEMS)) + { + stm_items.setInt(1, player.getObjectId()); + try (ResultSet items = stm_items.executeQuery()) + { + switch (type) + { + case L2PcInstance.STORE_PRIVATE_BUY: + while (items.next()) + { + if (player.getBuyList().addItemByItemId(items.getInt(2), items.getInt(3), items.getInt(4)) == null) + throw new NullPointerException(); + } + player.getBuyList().setTitle(rs.getString("title")); + break; + + case L2PcInstance.STORE_PRIVATE_SELL: + case L2PcInstance.STORE_PRIVATE_PACKAGE_SELL: + while (items.next()) + { + if (player.getSellList().addItem(items.getInt(2), items.getInt(3), items.getInt(4)) == null) + throw new NullPointerException(); + } + player.getSellList().setTitle(rs.getString("title")); + player.getSellList().setPackaged(type == L2PcInstance.STORE_PRIVATE_PACKAGE_SELL); + break; + + case L2PcInstance.STORE_PRIVATE_MANUFACTURE: + L2ManufactureList createList = new L2ManufactureList(); + while (items.next()) + { + createList.add(new L2ManufactureItem(items.getInt(2), items.getInt(4))); + } + player.getCreateList().setStoreName(rs.getString("title")); + break; + } + } + } + + player.sitDown(); + if (Config.OFFLINE_SET_NAME_COLOR) + player.getAppearance().setNameColor(Config.OFFLINE_NAME_COLOR); + player.setPrivateStoreType(type); + player.setOnlineStatus(true, true); + player.restoreEffects(); + player.broadcastUserInfo(); + nTraders++; + } + catch (Exception e) + { + LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Error loading trader: " + player, e); + if (player != null) + player.deleteMe(); + } + } + + LOGGER.info(getClass().getSimpleName() + ": Loaded: " + nTraders + " offline trader(s)"); + + try (Statement stm1 = con.createStatement()) + { + stm1.execute(CLEAR_OFFLINE_TABLE); + stm1.execute(CLEAR_OFFLINE_TABLE_ITEMS); + } + } + catch (Exception e) + { + LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Error while loading offline traders: ", e); + } + } + + /** + * Gets the single instance of OfflineTradersTable. + * @return single instance of OfflineTradersTable + */ + public static OfflineTradersTable getInstance() + { + return SingletonHolder._instance; + } + + private static class SingletonHolder + { + protected static final OfflineTradersTable _instance = new OfflineTradersTable(); + } +} Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java =================================================================== --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 339) +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy) @@ -451,6 +451,7 @@ public int _telemode = 0; private boolean _inCrystallize; private boolean _inCraftMode; + private long _offlineShopStart = 0; private final Map<Integer, RecipeList> _dwarvenRecipeBook = new HashMap<>(); private final Map<Integer, RecipeList> _commonRecipeBook = new HashMap<>(); @@ -740,9 +741,17 @@ public String getAccountName() { + if (getClient() == null) + return getAccountNamePlayer(); + return getClient().getAccountName(); } + public String getAccountNamePlayer() + { + return _accountName; + } + public Map<Integer, String> getAccountChars() { return _chars; @@ -4623,6 +4632,9 @@ public void setPrivateStoreType(int type) { _privateStore = type; + + if (Config.OFFLINE_DISCONNECT_FINISHED && (_privateStore == STORE_PRIVATE_NONE) && ((getClient() == null) || getClient().isDetached())) + deleteMe(); } /** @@ -10574,6 +10586,16 @@ return _selectedBlocksList; } + public long getOfflineStartTime() + { + return _offlineShopStart; + } + + public void setOfflineStartTime(long time) + { + _offlineShopStart = time; + } + /** * Test if player inventory is under 80% capaity * @param includeQuestInv check also quest inventory Index: java/net/sf/l2j/gameserver/model/actor/status/PcStatus.java =================================================================== --- java/net/sf/l2j/gameserver/model/actor/status/PcStatus.java (revision 339) +++ java/net/sf/l2j/gameserver/model/actor/status/PcStatus.java (working copy) @@ -68,6 +68,10 @@ if (getActiveChar().isDead()) return; + // If OFFLINE_MODE_NO_DAMAGE is enabled and player is offline and he is in store/craft mode, no damage is taken. + if (Config.OFFLINE_MODE_NO_DAMAGE && (getActiveChar().getClient() != null) && getActiveChar().getClient().isDetached() && ((Config.OFFLINE_TRADE_ENABLE && ((getActiveChar().getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_SELL) || (getActiveChar().getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_BUY))) || (Config.OFFLINE_CRAFT_ENABLE && (getActiveChar().isInCraftMode() || (getActiveChar().getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_MANUFACTURE))))) + return; + // invul handling if (getActiveChar().isInvul()) { Index: java/net/sf/l2j/gameserver/network/L2GameClient.java =================================================================== --- java/net/sf/l2j/gameserver/network/L2GameClient.java (revision 339) +++ java/net/sf/l2j/gameserver/network/L2GameClient.java (working copy) @@ -25,6 +25,7 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.locks.ReentrantLock; import java.util.logging.Level; +import java.util.logging.LogRecord; import java.util.logging.Logger; import net.sf.l2j.Config; @@ -41,6 +42,8 @@ import net.sf.l2j.gameserver.model.L2Clan; import net.sf.l2j.gameserver.model.L2World; import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager; +import net.sf.l2j.gameserver.model.zone.ZoneId; import net.sf.l2j.gameserver.network.serverpackets.ActionFailed; import net.sf.l2j.gameserver.network.serverpackets.L2GameServerPacket; import net.sf.l2j.gameserver.network.serverpackets.ServerClose; @@ -445,9 +448,20 @@ public void close(L2GameServerPacket gsp) { + if (getConnection() == null) + return; + getConnection().close(gsp); } + public void close(L2GameServerPacket[] gspArray) + { + if (getConnection() == null) + return; + + getConnection().close(gspArray); + } + /** * @param charslot * @return @@ -541,6 +555,39 @@ if (getActiveChar() != null && !isDetached()) { setDetached(true); + if (offlineMode(getActiveChar())) + { + getActiveChar().leaveParty(); + OlympiadManager.getInstance().unRegisterNoble(getActiveChar()); + + // If the L2PcInstance has Pet, unsummon it + if (getActiveChar().hasPet()) + { + getActiveChar().getPet().unSummon(getActiveChar()); + + // Dead pet wasn't unsummoned, broadcast npcinfo changes (pet will be without owner name - means owner offline) + if (getActiveChar().getPet() != null) + getActiveChar().getPet().broadcastNpcInfo(0); + + } + + if (Config.OFFLINE_SET_NAME_COLOR) + { + getActiveChar().getAppearance().setNameColor(Config.OFFLINE_NAME_COLOR); + getActiveChar().broadcastUserInfo(); + } + + if (getActiveChar().getOfflineStartTime() == 0) + getActiveChar().setOfflineStartTime(System.currentTimeMillis()); + + final LogRecord record = new LogRecord(Level.INFO, "Entering offline mode"); + record.setParameters(new Object[] + { + L2GameClient.this + }); + _log.log(record); + return; + } fast = !getActiveChar().isInCombat() && !getActiveChar().isLocked(); } cleanMe(fast); @@ -552,6 +599,43 @@ } } + /** + * @param player the player to be check. + * @return {@code true} if the player is allowed to remain as offline shop. + */ + protected static boolean offlineMode(L2PcInstance player) + { + if (player.isInOlympiadMode() || player.isFestivalParticipant() || player.isInJail() || (player.getVehicle() != null)) + return false; + + boolean canSetShop = false; + switch (player.getPrivateStoreType()) + { + case L2PcInstance.STORE_PRIVATE_SELL: + case L2PcInstance.STORE_PRIVATE_PACKAGE_SELL: + case L2PcInstance.STORE_PRIVATE_BUY: + { + canSetShop = Config.OFFLINE_TRADE_ENABLE; + break; + } + case L2PcInstance.STORE_PRIVATE_MANUFACTURE: + { + canSetShop = Config.OFFLINE_TRADE_ENABLE; + break; + } + default: + { + canSetShop = Config.OFFLINE_CRAFT_ENABLE && player.isInCraftMode(); + break; + } + } + + if (Config.OFFLINE_MODE_IN_PEACE_ZONE && !player.isInsideZone(ZoneId.PEACE)) + canSetShop = false; + + return canSetShop; + } + public void cleanMe(boolean fast) { try Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminEditChar.java =================================================================== --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminEditChar.java (revision 339) +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminEditChar.java (working copy) @@ -661,6 +661,13 @@ */ private static void gatherCharacterInfo(L2PcInstance activeChar, L2PcInstance player, String filename) { + final L2GameClient client = player.getClient(); + + if (client == null) + activeChar.sendMessage("Client is null."); + else if (client.isDetached()) + activeChar.sendMessage("Client is detached."); + final String clientInfo = player.getClient().toString(); final String account = clientInfo.substring(clientInfo.indexOf("Account: ") + 9, clientInfo.indexOf(" - IP: ")); final String ip = clientInfo.substring(clientInfo.indexOf(" - IP: ") + 7, clientInfo.lastIndexOf("]"));
  11. Could any good soul adapt this mode to l2jfrozen? package handlers.voicedcommandhandlers; import net.sf.l2j.gameserver.handler.IVoicedCommandHandler; import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; /** * @author Cobra */ public class autoloot implements IVoicedCommandHandler { private static final String[] VOICED_COMMANDS = private static String[] _voicedCommands = { "autolooton", "autolootoff" }; public String[] getVoicedCommandList() { return VOICED_COMMANDS; } public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target) { if (command.equalsIgnoreCase("autolooton")) { activeChar.setAutoLootEnabled(true); activeChar.sendMessage("Auto loot is now enabled."); } else if (command.equalsIgnoreCase("autolootoff")) { activeChar.setAutoLootEnabled(false); activeChar.sendMessage("Auto loot is now disabled."); } return true; } } It is for l2jserver but it is missing the L2PCInstance file from setAutoLootEnabled I even tried it but when I tested it it didn't run the code I created it was this /** AutoLoot parameters*/ private boolean _autoLootEnabled = false; public void setAutoLootEnabled(final boolean autoLootEnabled) { _autoLootEnabled = autoLootEnabled; } /** * @param reference * @return Returns the autoLootEnabled. */ public boolean isAutoLootEnabled(final L2Object reference) { return _autoLootEnabled && !(reference instanceof L2GrandBossInstance) && !(reference instanceof L2RaidBossInstance) && !(reference instanceof L2MinionInstance); }
  12. Whoa? can you help me here fast? I'm trying to adapt a mod for l2jhellas and I've been breaking my head with this line since morning Collection <L2Character> players = activeChar.getKnownList().getKnownTypeInRadius(L2Character.class, 480); When reviewing L2JHELLAS, there are no parameters that I marked in red, because it is not possible to find a parameter for them