Jump to content
  • 0

[Help]Problem with Java code


Question

Posted

Hey guys....

I try to put this java code in my server : http://www.maxcheaters.com/forum/index.php?topic=148257.0 and i put it :)

But when i wear S grade armor/weapon and i take out after i cant wear again any armor/weapon/jewel and in gameserver window say:

 

Client: [Character: Lougkraaaaaa[268479809] - Account: manos2864 - IP: 127.0.0.1

] - Failed running: [C] 14 UseItem - L2J Server Version: ${l2j.revision} - DP Re

vision: ${l2jdp.revision} ; null

java.lang.NullPointerException

       at com.l2jserver.gameserver.network.clientpackets.UseItem.runImpl(UseIte

m.java:103)

       at com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket.run

(L2GameClientPacket.java:93)

       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source

)

       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

       at java.lang.Thread.run(Unknown Source)

 

 

Some guys in greek section told me maybe i make something wrong.... and they try to help me with teamviewer but nothing happen!! Code had problem... Can someone fix this code pls!!! Or give me another code (i want olympiad only with A grade armor/weapons/jewels)

I use l2jserver Epilogue (Compile)

 

Recommended Posts

  • 0
Posted

i add only your code but nothing happen.... when i participate in olympiad it allow me enter with s grade armor / weapon

 

enter is 1 thing playing is another

  • 0
Posted

enter is 1 thing playing is another

:O What you mean??

 

**EDIT**

Try this,

UseItem.java

import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.Olympiad;
import net.sf.l2j.gameserver.handler.IItemHandler;

L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);

		if (item == null)
                               return;

+                      int lolz0r = item.getItem().getCrystalType();
+                      if (activeChar.isInOlympiadMode() || Olympiad.getInstance().isRegisteredInComp(activeChar) || +activeChar.getOlympiadGameId() > 0)
+                      {
+                            if (lolz0r == L2Item.CRYSTAL_S || lolz0r == L2Item.CRYSTAL_S80 || lolz0r == L2Item.CRYSTAL_S84)
+                            {
+        	                  activeChar.sendMessage("You may only use items up to Grade A in the Grand Olympiad Games.");
+                                  return;
+                            }
+                      }

Olympiad.java

public class Olympiad
{
/**
 *
 * @author  ascharot
 * 
 */
+      private int _objectId;
private class OlympiadGameTask implements Runnable
{
	public L2OlympiadGame _game = null;

if (!_inCompPeriod)
       {
           sm = new SystemMessage(SystemMessageId.THE_OLYMPIAD_GAME_IS_NOT_CURRENTLY_IN_PROGRESS);
           noble.sendPacket(sm);
           return false;
       }

+      L2ItemInstance item = noble.getInventory().getItemByObjectId(_objectId);
+      int lolz0r = item.getItem().getCrystalType();
+      if (lolz0r == L2Item.CRYSTAL_S || lolz0r == L2Item.CRYSTAL_S80 || lolz0r == L2Item.CRYSTAL_S84)
+      {
+          noble.sendMessage("You cannot use S grade equipment at the Grand Olympiad games.");
+          return false;
+      }

 

in useitem.java --->where i must add the import?? (my useitem.java)-->http://pastebin.com/5WY4ZVKs

and in olympiad.java i cant find where i must add this code

+      private int _objectId;

my olympiad.java-->http://pastebin.com/2GsdGYFR

 

and

+      L2ItemInstance item = noble.getInventory().getItemByObjectId(_objectId);

+      int lolz0r = item.getItem().getCrystalType();

+      if (lolz0r == L2Item.CRYSTAL_S || lolz0r == L2Item.CRYSTAL_S80 || lolz0r == L2Item.CRYSTAL_S84)

has problem :S

  • 0
Posted

Not sure about epilogue,try this:

 

import com.l2jserver.Config;

import com.l2jserver.gameserver.GameTimeController;

+import com.l2jserver.gameserver.model.olympiad.Olympiad;

:O What you mean??

 

**EDIT**

in useitem.java --->where i must add the import?? (my useitem.java)-->http://pastebin.com/5WY4ZVKs

and in olympiad.java i cant find where i must add this code

+      private int _objectId;

my olympiad.java-->http://pastebin.com/2GsdGYFR

 

and

+      L2ItemInstance item = noble.getInventory().getItemByObjectId(_objectId);

+      int lolz0r = item.getItem().getCrystalType();

+      if (lolz0r == L2Item.CRYSTAL_S || lolz0r == L2Item.CRYSTAL_S80 || lolz0r == L2Item.CRYSTAL_S84)

has problem :S

Private int _object...you can add it here:

 

public class Olympiad
{
        private int _objectId;
protected static final Logger _log = Logger.getLogger(Olympiad.class.getName());
protected static final Logger _logResults = Logger.getLogger("olympiad");

Has problem?what do you mean?

  • 0
Posted

L2ItemInstance item = noble.getInventory().getItemByObjectId(_objectId);

int lolz0r = item.getItem().getCrystalType();

if (lolz0r == L2Item.CRYSTAL_S || lolz0r == L2Item.CRYSTAL_S80 || lolz0r == L2Item.CRYSTAL_S84)

{

 

It say

L2iteminstance cannot be resolve to a type

and

multiple markers at this line: l2item cannot be resolve

  • 0
Posted

Add the import for l2iteminstance in Olympiad.java.

Multiple markerS? Oo?It works normally for me...

Add the import i told you,and check it again.

  • 0
Posted

Add the import for l2iteminstance in Olympiad.java.

Multiple markerS? Oo?It works normally for me...

Add the import i told you,and check it again.

how i will add import for l2iteminstance in olympiad.java??? com.l2jserver.gameserver.model.l2iteminstance;???

 

EDIT

ok i add the import i solve the problem with l2iteminstance.... but not with multiple markers :S

  • 0
Posted

how i will add import for l2iteminstance in olympiad.java??? com.l2jserver.gameserver.model.l2iteminstance;???

 

EDIT

ok i add the import i solve the problem with l2iteminstance.... but not with multiple markers :S

Instead of this:if (lolz0r == L2Item.CRYSTAL_S || lolz0r == L2Item.CRYSTAL_S80 || lolz0r == L2Item.CRYSTAL_S84)

try this:if (lolz0r == L2Item.CRYSTAL_S)

 

Compile,login to check if it works and i ll modify it for s80 and s84.

  • 0
Posted

Instead of this:if (lolz0r == L2Item.CRYSTAL_S || lolz0r == L2Item.CRYSTAL_S80 || lolz0r == L2Item.CRYSTAL_S84)

try this:if (lolz0r == L2Item.CRYSTAL_S)

 

Compile,login to check if it works and i ll modify it for s80 and s84.

I put this if (lolz0r == L2Item.CRYSTAL_S) but again say L2item cannot be  resolve

  • 0
Posted

I put this if (lolz0r == L2Item.CRYSTAL_S) but again say L2item cannot be  resolve

lol,import for l2item doesnt exist either.import com.l2jserver.gameserver.templates.item.L2Item;

Revert my previous post and add the import.

  • 0
Posted

olympiad not work :S

and in gameserver(window) say:

[Character: [Admin]Imperfect[268479864] - Account: manos2864 - IP: 192.168.0.137

] sent bad RequestBypassToServer: "npc_268463562_OlympiadNoble 5"

java.lang.NullPointerException

        at com.l2jserver.gameserver.model.olympiad.Olympiad.registerNoble(Olympi

ad.java:478)

        at com.l2jserver.gameserver.model.actor.instance.L2OlympiadManagerInstan

ce.onBypassFeedback(L2OlympiadManagerInstance.java:119)

        at com.l2jserver.gameserver.network.clientpackets.RequestBypassToServer.

runImpl(RequestBypassToServer.java:143)

        at com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket.run

(L2GameClientPacket.java:93)

        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source

)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

        at java.lang.Thread.run(Unknown Source)

  • 0
Posted

In Olympiad.java,change the code to be like this:

      L2ItemInstance item = noble.getInventory().getItemByObjectId(_objectId);
      int lolz0r = item.getItem().getCrystalType();
      if (item != null)
      {
          if (lolz0r == L2Item.CRYSTAL_S || lolz0r == L2Item.CRYSTAL_S80 || lolz0r == L2Item.CRYSTAL_S84)
          {
              noble.sendMessage("You cannot use S grade equipment at the Grand Olympiad games.");
              return false;
          }
      }

  • 0
Posted

In Olympiad.java,change the code to be like this:

     L2ItemInstance item = noble.getInventory().getItemByObjectId(_objectId);
     int lolz0r = item.getItem().getCrystalType();
     if (item != null)
     {
         if (lolz0r == L2Item.CRYSTAL_S || lolz0r == L2Item.CRYSTAL_S80 || lolz0r == L2Item.CRYSTAL_S84)
         {
             noble.sendMessage("You cannot use S grade equipment at the Grand Olympiad games.");
             return false;
         }
     }

this will fix my error?

EDIT

 

     L2ItemInstance item = noble.getInventory().getItemByObjectId(_objectId);
     int lolz0r = item.getItem().getCrystalType();
     if (item != null)
     {
         if (lolz0r == L2Item.CRYSTAL_S || lolz0r == L2Item.CRYSTAL_S80 || lolz0r == L2Item.CRYSTAL_S84)
         {
             noble.sendMessage("You cannot use S grade equipment at the Grand Olympiad games.");
             return false;
         }
     }

when i put in the end the }then in if (item != null) say redudant null check:the variable item cannot be null at this location but if i delete } then everything its ok

  • 0
Posted

i edit my previous reply pls check it... if its something serious

Very well,delete it and have a try.

Guest
This topic is now closed to further replies.



×
×
  • Create New...