Jump to content

Sell Buff [Freya] L2Jserver


LioNa

Recommended Posts

Well this is a PJ that sells its buff - and adapted it for Freya l2jserver

 

#########################################

######### Algunas Cosillas Mejoradas #########

#########################################

1ª | Command Buff to Sell .SellBuffs

2ª | New Command to Rise .CancelSellBuffs

3ª | You can change the title from l2jmods.properties

4ª | When you see Buff and no need to remove the Target and give again and give him only with k leaves you to buff new tab.

5ª | Fixed error Adena

 

http://img22.imageshack.us/img22/9148/shot00007lj.jpg

http://img4.imageshack.us/img4/7599/shot00008os.jpg

 

Esto va en Eclipse

 

===================================================================
--- head-src/com/l2jserver/Config.java 
+++ head-src/com/l2jserver/Config.java 

  public static boolean L2JMOD_ENABLE_WAREHOUSESORTING_PRIVATE;
+  public static String ADD_TITULO_PJ_SELLBUFS;

===================================================================

       L2JMOD_ENABLE_WAREHOUSESORTING_PRIVATE = Boolean.valueOf(L2JModSettings.getProperty("EnableWarehouseSortingPrivate", "False"));
+      ADD_TITULO_PJ_SELLBUFS = L2JModSettings.getProperty("TituloPjSellBuffs", "BUFF");


===================================================================
--- head-src/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java 
+++ head-src/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java 
@@ -31,6 +31,7 @@
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;

+import javolution.text.TextBuilder;
import javolution.util.FastList;
import javolution.util.FastMap;
import com.l2jserver.Config;
@@ -451,6 +452,8 @@

    private boolean _noble = false;
    private boolean _hero = false;
+  private boolean _sellbuff = false;
+  private int _buffprize = 0;
+ private String _oldtitle = "";
+ private int _oldnamecolor = 0;
+   


    /** The L2FolkInstance corresponding to the last Folk wich one the player talked. */
    private L2FolkInstance _lastFolkNpc = null;
@@ -2375,6 +2378,9 @@
    */
    public void standUp()
    {
+      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 ...");
@@ -3945,6 +3951,42 @@

      // Target the new L2Object (add the target to the L2PcInstance _target, _knownObject and L2PcInstance to _KnownObject of the L2Object)
      super.setTarget(newTarget);
+
+      L2PcInstance t = null;
+      if(newTarget instanceof L2PcInstance)
+        t = (L2PcInstance) newTarget;
+     
+      if(t != null){
+        if(t.isSellBuff() && t != this){
+            TextBuilder tb = new TextBuilder();
+            NpcHtmlMessage n = new NpcHtmlMessage(0);
+           
+            tb.append("<html><body>");
+            tb.append("<br><br>");
+            tb.append("<center>Hola <font color=LEVEL>Campesin@</font> Quieres Buff!</center>");
+            tb.append("<br><center>Mis Buff Cuestan: <font color=LEVEL>"+t.getBuffPrize()+"</font> Adenas cada uno!</center><br><center><table><tr>");
+           
+            L2Skill[] skills = t.getAllSkills();
+            FastList<L2Skill> ba = new FastList<L2Skill>();
+           
+            for(L2Skill s : skills){
+              if(s == null)
+                  continue;
+             
+             
+              if(s.getSkillType() == L2SkillType.BUFF && s.isActive() && s.getId() != 970 && s.getId() != 357 && s.getId() != 1323 && s.getId() != 327 && s.getId() != 1325 && s.getId() != 1326 && s.getId() != 1327)
+                  ba.add(s);
+            }
+           
+            for(L2Skill p : ba){
+                tb.append("<td><button action=\"bypass -h buff "+p.getId()+"\" width=32 height=32 back=\"Icon.skill"+p.getId()+"\" fore=\"Icon.skill"+p.getId()+"\"></td>");
+                tb.append("<td><button value=\""+p.getName()+"\" action=\"bypass -h buff "+p.getId()+"\" width=200 height=32 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>");
+                tb.append("<td><button action=\"bypass -h buff "+p.getId()+"\" width=32 height=32 back=\"Icon.skill"+p.getId()+"\" fore=\"Icon.skill"+p.getId()+"\"></td></tr><tr>");
+            }
+           
+            tb.append("</tr></table></center></body></html>");
+           
+            n.setHtml(tb.toString());
+            sendPacket(n);
+        }
+      }
    }

    /**
@@ -8214,7 +8256,23 @@
      }
      return true;
    }
+  public boolean isSellBuff(){
+      return _sellbuff;
+  }
+ 
+    public void setSellBuff(boolean j){
+      _sellbuff = j;
+    }
+
+    public int getBuffPrize(){
+      return _buffprize;
+    }
+   
+    public void setBuffPrize(int x){
+      _buffprize = x;
+    }
+   
+    public String getOldTitle()
+    {
+       return _oldtitle;
+    }
+   
+    public int getOldNameColor()
+    {
+       return _oldnamecolor;
+    }
+   
+    public void setOldTitle(String title)
+    {
+       _oldtitle = title;
+    }
+   
+    public void setOldNameColor(int color)
+    {
+       _oldnamecolor = color;
+    }
+   
    public boolean isNoble()
    {
      return _noble;





===================================================================
--- head-src/com/l2jserver/gameserver/clientpackets/RequestBypassToServer.java
+++ head-src/com/l2jserver/gameserver/clientpackets/RequestBypassToServer.java
@@ -18,16 +18,20 @@
  */
package com.l2jserver.gameserver.network.clientpackets;

import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.l2jserver.Config;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.communitybbs.CommunityBoard;
import com.l2jserver.gameserver.datatables.AdminCommandAccessRights;
+import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.handler.AdminCommandHandler;
import com.l2jserver.gameserver.handler.BypassHandler;
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.L2CharPosition;
import com.l2jserver.gameserver.model.L2Object;
+import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2MerchantSummonInstance;
@@ -85,6 +89,57 @@
          {
            comeHere(activeChar);
          }
+        else if(_command.startsWith("buff")){
+           String[] val = _command.split(" ");
+            String x = val[1];
+            int id = Integer.parseInt(x);
+            L2PcInstance target = null;
+           
+            if(activeChar.getTarget() instanceof L2PcInstance)
+            target = (L2PcInstance) activeChar.getTarget();
+           
+            if(target == null)
+              return;
+           
+            if(activeChar.getInventory().getItemByItemId(57) == null || activeChar.getInventory().getItemByItemId(57).getCount() < ((L2PcInstance) activeChar.getTarget()).getBuffPrize()){
+              activeChar.sendMessage("* No tienes adena!");
+              return;
+            }
+           
+       
+            try{
+            L2Skill s = SkillTable.getInstance().getInfo(id, 3);
+            s.getEffects(activeChar, activeChar);
+            activeChar.sendMessage("* Has Comprado: "+s.getName());
+            activeChar.getInventory().destroyItemByItemId("", 57, target.getBuffPrize(), activeChar, null);
+            target.getInventory().addItem("", 57, target.getBuffPrize(), target, null);
+            TextBuilder tb = new TextBuilder();
+            NpcHtmlMessage n = new NpcHtmlMessage(0);
+           
+            tb.append("<html><body>");
+            tb.append("<br><br>");
+            tb.append("<center>Hola <font color=LEVEL>Campesin@</font> Quieres Buff!</center>");
+            tb.append("<br><center>Mis Buff Cuestan: <font color=LEVEL>"+target.getBuffPrize()+"</font> Adenas cada uno!</center><br><center><table><tr>");
+           
+           
+            L2Skill[] skills = target.getAllSkills();
+            FastList<L2Skill> ba = new FastList<L2Skill>();
+           
+            for(L2Skill skill : skills){
+              if(skill == null)
+                  continue;
+             
+             
+              if(skill.getSkillType() == L2SkillType.BUFF && skill.isActive() && skill.getId() != 970 && skill.getId() != 357 && skill.getId() != 1323 && skill.getId() != 327 && skill.getId() != 1325 && skill.getId() != 1326 && skill.getId() != 1327)
+                  ba.add(skill);
+            }
+           
+            for(L2Skill p : ba){
+                tb.append("<td><button action=\"bypass -h buff "+p.getId()+"\" width=32 height=32 back=\"Icon.skill"+p.getId()+"\" fore=\"Icon.skill"+p.getId()+"\"></td>");
+                tb.append("<td><button value=\""+p.getName()+"\" action=\"bypass -h buff "+p.getId()+"\" width=200 height=32 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>");
+                tb.append("<td><button action=\"bypass -h buff "+p.getId()+"\" width=32 height=32 back=\"Icon.skill"+p.getId()+"\" fore=\"Icon.skill"+p.getId()+"\"></td></tr><tr>");
+            }
+           
+            tb.append("</tr></table></center></body></html>");
+           
+            n.setHtml(tb.toString());
+            activeChar.sendPacket(n);
+            }
+            catch(Exception e){
+              e.printStackTrace();
+            }
+        }
+        else if(_command.startsWith("actr")){
+            String l = _command.substring(5);
+           
+            int p = 0;
+
+            p = Integer.parseInt(l);
+           
+           
+            if(p == 0)
+              return;
+           
+            if(p > 2000000000){
+              activeChar.sendMessage("* Te has colado el limite de Adena!");
+              return;
+            }
+           
+              activeChar.setBuffPrize(p);
+              activeChar.sitDown();
+              activeChar.setTeam(1);
+              activeChar.setSellBuff(true);
+              activeChar.setOldTitle(activeChar.getTitle());
+              activeChar.setOldNameColor(activeChar.getAppearance().getNameColor());
+              /*activeChar.getAppearance().setNameColor(0x55155);*/
+              activeChar.getAppearance().setNameColor(99, 22, 11);
+              activeChar.setTitle(Config.ADD_TITULO_PJ_SELLBUFS);
+              activeChar.broadcastUserInfo();
+              activeChar.broadcastTitleInfo();
+        }
          else if (_command.startsWith("player_help "))
          {
            playerHelp(activeChar, _command.substring(12));

 

Cuando pongamos este codigo guardams y copilamos.

 

Luego bamos a Ruta --> game\data\scripts\handlers

 

y abrimos el MasterHandler y añadimos

 

import handlers.voicedcommandhandlers.stats;

  import handlers.voicedcommandhandlers.VisualArmor;

+import handlers.voicedcommandhandlers.sellbuff;

 

  import java.util.logging.Logger;

 

  import com.l2jserver.Config;

 

##############################

 

 

      VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new stats());

+      VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new sellbuff());

      if (Config.L2JMOD_ALLOW_WEDDING)

        VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Wedding());

      if (Config.BANKING_SYSTEM_ENABLED)

        VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Banking());

 

y guardamos y luego bamos a ruta --> game\data\scripts\handlers\voicedcommandhandlers

y creamos un archivo llamado --> sellbuff

 

y le añadimos el codigo

 

package handlers.voicedcommandhandlers;

 

import javolution.text.TextBuilder;

import com.l2jserver.gameserver.handler.IVoicedCommandHandler;

import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;

import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;

 

/**

*

* @author  Iratus

*/

public class sellbuff implements IVoicedCommandHandler

{

 

  private static final String[] VOICED_COMMANDS = {"sellbuffs","cancelsellbuffs"};

 

  public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)

  {

      if(activeChar == null)

        return false;

   

      if (command.equals(VOICED_COMMANDS[0]))

    {

        if(activeChar.isDead() || activeChar.isAlikeDead()){

          activeChar.sendMessage("You are dead , 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(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(activeChar.getClassId().getId() != 98){

          activeChar.sendMessage("You must be a buffer class to sell buffs");

          return false;

        }

     

        TextBuilder tb = new TextBuilder(0);

        tb.append("<html><body><center>");

        tb.append("<table><tr>");

        tb.append("<td><img src=\"icon.etc_alphabet_b_i00\" width=32 height=32 align=left></td><td><img src=\"icon.etc_alphabet_u_i00\" width=32 height=32 align=left></td>");

        tb.append("<td><img src=\"icon.etc_alphabet_f_i00\" width=32 height=32 align=left></td><td><img src=\"icon.etc_alphabet_f_i00\" width=32 height=32 align=left></td>");

        tb.append("</tr></table><br>");

        tb.append("<br><font color=LEVEL>Hola</font>, completando este formulario<br>");

        tb.append("<br>usted podra de <font color=LEVEL>vender</font> tus <font color=LEVEL>Buff</font>.<br>");

        tb.append("<br>Los <font color=LEVEL>Players</font> Podran Echarse tus <font color=LEVEL>Buff</font>.<br>");

        tb.append("<br><font color=LEVEL>Tu Pones la Cantidad</font><br>");

        tb.append("<br>de adena para echarse los Buff<br>");

        tb.append("<p><font color=LEVEL>Precio de Buff:</font></p>");

        tb.append("<p><edit var=\"pri\" width=120 height=15></p>");

        tb.append("<button value=\"Confirmar\" action=\"bypass -h actr $pri\" width=160 height=32 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">");

        tb.append("</center><br>");

        tb.append("<center>.:<font color=LEVEL>Lineage II</font>:.</center>");

        tb.append("</body></html>");

        NpcHtmlMessage n = new NpcHtmlMessage(0);

        n.setHtml(tb.toString());

        activeChar.sendPacket(n);

    }

    else if (command.equals(VOICED_COMMANDS[1]))

    {

      if (activeChar.isSellBuff())

      {

        activeChar.setSellBuff(false);

        activeChar.standUp();

        activeChar.setTeam(0);

        activeChar.getAppearance().setNameColor(activeChar.getOldNameColor());

            activeChar.setTitle(activeChar.getOldTitle());

            activeChar.broadcastUserInfo();

            activeChar.broadcastTitleInfo();

      }

    }

   

    return true;

  }

 

 

  @Override

  public String[] getVoicedCommandList()

  {

      return VOICED_COMMANDS;

  }

 

}

 

Luego bamos a ruta -> game\config y abrimas el archivo l2jmods.properties y le agregamos

 

EnableWarehouseSortingPrivate = False
+
+###########################
+#### TITULO SELLBUFFS #####
+###########################
+# TITULO PARA VENDER BUFF
+TituloPjSellBuffs = * VENDO BUFF *

 

Creditos : Lobillo , LioNa

 

and Save and you're all set if it works do not forget to give the +

 

sorry with my English

Link to comment
Share on other sites

next version:

 

Contains the window to sell items to sell buff.

Areglado error when you wake sete change the name and title color as you had before selling buff. etc

 

sorry for my English

Link to comment
Share on other sites

  • 1 year later...

hi i put this in my server H5 l2jserver and:

when i buy some buffs and target mayself i see my buffs that i can buy ;p

html appear when i target buffseller from far far far away ;p

when i have enchanted buffs and want to sell buyer get not enchanted buffs

and some other bugs ;]

 

Sorry for my english, hope u understund me.

Link to comment
Share on other sites

  • 5 weeks later...

Error in H5:

[18/10 17:45:16] Client: [Character: Ogmus[268483764] - Account: ogmus - IP: 77.241.112.63] - Failed writing: NpcHtmlMessage - L2J Server Version: 6663M - DP Revision: 10466M ; null
java.nio.BufferOverflowException
	at java.nio.Buffer.nextPutIndex(Buffer.java:527)
	at java.nio.HeapByteBuffer.putChar(HeapByteBuffer.java:270)
	at org.mmocore.network.SendablePacket.writeS(SendablePacket.java:113)
	at com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage.writeImpl(NpcHtmlMessage.java:84)
	at com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket.write(L2GameServerPacket.java:109)
	at org.mmocore.network.SelectorThread.putPacketIntoWriteBuffer(SelectorThread.java:621)
	at org.mmocore.network.SelectorThread.prepareWriteBuffer(SelectorThread.java:589)
	at org.mmocore.network.SelectorThread.writePacket(SelectorThread.java:500)
	at org.mmocore.network.SelectorThread.run(SelectorThread.java:187)

Critical Client to target player sell buff.

Link to comment
Share on other sites

  • 6 months later...

hello first thanks for this sellbuffer i added it right in my server and with somethings changed work fine, but i have a problem with the target.

 

1- if i target the buffer seller on the first clik the window to sell buffs appear ( even if you aren't near buffer).

2- if i close that window and try to reopen (with the buffer targeted) dont work and no errors ( seems only show htm in the first target click) if i leave target and target again work fine.

3- you are allowed to use buffs till your target dissappear from far far far.

 

someone know how to fix the issue with target to work normally as all npcs? i mean if you are inside radius it show htm i hope you understand me and sorry for my english not good, thanks in advance.

Link to comment
Share on other sites

Put the TextBuilder which displays the sell window under new method, put some checks, if all fine -> show window.

Edited by SweeTs
Link to comment
Share on other sites

Put the TextBuilder which displays the sell window under new method, put some checks, if all fine -> show window.

thanks sweets i will try now.

 

 

edit: well i try to add this change as you said, i added the "ifs" in the setTarget method as the script is example;

super.setTarget(newTarget); <-- this is the reference line.

L2PcInstance = null;

if(newtarget instanceof L2pcinstance)
{
t = (L2PcInstance) newTarget;
}

if(t != null)
{
if(t.issellBuff() && t != this)
{
showHtm()
}

---------------------------------

then the method showhtm():

textbuilder etc..


i added this but no work, if i target the buffer from far it show the html anyway, and if i add a restriction for if isinsideradius(target, l2npc.interact_distance true , false) --> return it works fine if i am far of buffer, but when i go near the buffer if i have it targeted it dont show the html ( because i have it targeted before enter in his radius LOL),i just want the html working the same as all npcs and texts, this problem are killing my life, thanks if someone can help me, greetings.

 

this is the final work using this base script:

 

sellbuffs.jpg

sellbuffs2.jpg

Edited by b0rto
Link to comment
Share on other sites

anybody know how to fix that?. seriously i need this issue fixed because i am fighting 4 days with the same shit, if someone have knowledge to fix that i can pay 10€ through paypal to fix it because i very need this working fine, contact me in skype: b0rtzito thanks in advance.

 

P.D a person already helped me to solve this, the problem was in actionhandlers -> l2pcinstanceAction  , just add a check if isSellBuffs do the same action as private shops and it work as it should now :p.

Edited by b0rto
Link to comment
Share on other sites

  • 4 weeks later...

1 problem. The html dont addapt the enchantment of the buff. So the seller can have it enchanted, but the buyer will buy it +0.

Link to comment
Share on other sites

  • 1 month later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...