Jump to content
  • 0

[HELP] 1 question about Code


Question

Posted

Index: com/l2jfrozen/gameserver/model/L2Character.java
===================================================================
--- com/l2jfrozen/gameserver/model/L2Character.java	(revision 948)
+++ com/l2jfrozen/gameserver/model/L2Character.java	(working copy)
@@ -340,6 +340,9 @@
	/** The Constant ZONE_DANGERAREA. */
	public static final int ZONE_DANGERAREA = 16384;

+	/** The Constant ZONE_NEWBIE. */
+	public static final int ZONE_NEWBIE = 16385;	
+
	/** The _current zones. */
	private int _currentZones = 0;

Index: com/l2jfrozen/gameserver/model/zone/type/L2NewbieZone.java
===================================================================
--- com/l2jfrozen/gameserver/model/zone/type/L2NewbieZone.java	(revision 0)
+++ com/l2jfrozen/gameserver/model/zone/type/L2NewbieZone.java	(revision 0)
@@ -0,0 +1,83 @@
+/* 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.model.zone.type;
+
+import com.l2jfrozen.gameserver.datatables.csv.MapRegionTable;
+import com.l2jfrozen.gameserver.model.L2Character;
+import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
+import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jfrozen.gameserver.model.zone.L2ZoneType;
+
+/**
+ * 
+ * @author Leki
+ */
+public class L2NewbieZone extends L2ZoneType
+{
+	public L2NewbieZone(int id)
+	{
+		super(id);
+	}
+
+	@Override
+	protected void onEnter(L2Character character)
+	{
+		if(character instanceof L2PcInstance)
+		{
+			L2PcInstance player = (L2PcInstance) character;
+			for (L2ItemInstance i : player.getInventory().getItems())
+			{
+				if (!player.isGM())
+				{	
+					if (i.isEquipable())
+					{	
+						if (i.getEnchantLevel() > 3)
+						{  
+							player.sendMessage("You can enter to this zone if your items aren't enchant more than 3");
+							player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
+							return;
+						}
+					}
+				}
+			}	
+			if(!player.isGM() && player.isFlying())
+			{
+				player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
+				return;
+			}
+			character.setInsideZone(L2Character.ZONE_NEWBIE, true);					
+		}
+	}
+
+	@Override
+	protected void onExit(L2Character character)
+	{
+		if(character instanceof L2PcInstance)
+		{
+			character.setInsideZone(L2Character.ZONE_NEWBIE, false);
+		}
+	}
+
+	@Override
+	public void onDieInside(L2Character character)
+	{}
+
+	@Override
+	public void onReviveInside(L2Character character)
+	{}
+}
\ No newline at end of file
Index: com/l2jfrozen/gameserver/network/clientpackets/RequestEnchantItem.java
===================================================================
--- com/l2jfrozen/gameserver/network/clientpackets/RequestEnchantItem.java	(revision 948)
+++ com/l2jfrozen/gameserver/network/clientpackets/RequestEnchantItem.java	(working copy)
@@ -21,6 +21,7 @@

import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.model.Inventory;
+import com.l2jfrozen.gameserver.model.L2Character;
import com.l2jfrozen.gameserver.model.L2World;
import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
@@ -135,7 +136,13 @@
			activeChar.setActiveEnchantItem(null);
			return;
		}
+		if(activeChar.isInsideZone(L2Character.ZONE_NEWBIE))
+		{
+			activeChar.sendMessage("You can't enchant in newbie zone!");
+			return;
+		}	

+		
		/*
		if(!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_ENCHANT))
		{

 

I Wanna change this code from echant check to Grade check  can some1 help me with that?

Recommended Posts

  • 0
Posted

sure, change line: if (i.getEnchantLevel() > 3)

"i" is the L2ItemInstance, so find in L2ItemInstance method(i hope u know what are methods :P) that is returning its grade. it can be named getGrade, getItemGrade or something like that :)

  • 0
Posted

So what i change guys say me exacly reason i ask it like that i m newbie with that F@cking Machine *Eclipse*

 

i change  this if (i.getEnchantLevel() > 3) to this  if (i.getGradeLevel() > 3)  ( 3 = B garde)

 

And after from that where i go??? and wht i replace?

  • 0
Posted

thats all :) players with No, D, C and B grades will be able to enter, rest will be teleported to nearest town.

  • 0
Posted

adding of grade check is not so easy(for me) but ofcourse it is possible, if you know java enough, waste some time and you'll create. Otherwise, no one will write a whole code for you(for free)

  • 0
Posted

thats all :) players with No, D, C and B grades will be able to enter, rest will be teleported to nearest town.

 

doesnt work ..

 

i change that and i go at newbie zone and i get one curse and nothing else :/  i really need that code do something :/

  • 0
Posted

did u make new zone and set it as L2NewbieZone ?

 

yes if i go with +weapon i go with +7 and it teleport me at talking island and i try to change it to garde and i get a curse something like that* and nothing else*

 

If you are sure 100% for that i will try again .

  • 0
Posted

if it still teleport u with just enchanted items, that mean u didnt compile the source or not replaced your server files with compiled source :)

  • 0
Posted

if it still teleport u with just enchanted items, that mean u didnt compile the source or not replaced your server files with compiled source :)

 

i m not so newbie i go with +7 and and teleport me back but i ask u are u sure wht if i change (i.getEnchantLevel() > 3) to this  if (i.getGradeLevel() > 3)  and after i build and i get JAR and replace with new right??

  • 0
Posted

yeah i am quite sure but check it on test server first, check if everything is ok and give us feedback :)

  • 0
Posted

Thats it! I wrote the grade checker. test and feedback please

/* 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.model.zone.type;

import com.l2jfrozen.gameserver.datatables.csv.MapRegionTable;
import com.l2jfrozen.gameserver.model.L2Character;
import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.model.zone.L2ZoneType;
import com.l2jfrozen.gameserver.templates.L2Item;

/**
* 
* @author Leki
*/
public class L2NewbieZone extends L2ZoneType
{
public L2NewbieZone(int id)
{
	super(id);
}

@Override
protected void onEnter(L2Character character)
{
	if(character instanceof L2PcInstance)
	{
		L2PcInstance player = (L2PcInstance) character;
		for (L2ItemInstance i : player.getInventory().getItems())
		{
			if (!player.isGM())
			{	
				if (i.isEquipable())
				{
					int crystaltype = i.getItem().getCrystalType();
					if (crystaltype != L2Item.CRYSTAL_D)
					{  
						player.sendMessage("You can enter to this zone only with d grade armor");
						player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
						return;
					}
				}
			}
		}	
		if(!player.isGM() && player.isFlying())
		{
			player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
			return;
		}
		character.setInsideZone(L2Character.ZONE_NEWBIE, true);					
	}
}

@Override
protected void onExit(L2Character character)
{
	if(character instanceof L2PcInstance)
	{
		character.setInsideZone(L2Character.ZONE_NEWBIE, false);
	}
}

@Override
public void onDieInside(L2Character character)
{}

@Override
public void onReviveInside(L2Character character)
{}
}

  • 0
Posted

Guys really thanks for your time i will try it now

 

 

Wht modify we can do to join UP to B Grade??

 

i join with D grade armor and kick me also with full set armor/jewels/weapon

  • 0
Posted
i join with D grade armor and kick me also with full set armor/jewels/weapon

Thats mean it works? :) to restriect UP to B Grade You should put this

if ((crystaltype == L2Item.CRYSTAL_A) || (crystaltype == L2Item.CRYSTAL_S))

  • 0
Posted

Thats mean it works? :) to restriect UP to B Grade You should put this

 

 

lisen with that code where u give me i join without items and kick me also kick me with ALL grades no grade /D/C/B/A/S i will try to test this one  lets see 

 

with My Friends we try something different but nothing :/ i really need that code is basic for my server features

 

 

I try and this one and kick me with all  grades and without items kick me again so something isnt right.. or something miss  something other opinion guys??

Guest
This topic is now closed to further replies.


×
×
  • Create New...