Jump to content
  • 0

CTF Event


l2redkiller
 Share

Question

i got some errors in ctf event engine :

 

error1a.jpg

 

errordv.jpg

 

thannkss for help

 

if need the code :

public static void addFlagToPlayer(L2PcInstance _player)
{
	//remove items from the player hands (right, left, both)
	// This is NOT a BUG, I don't want them to see the icon they have 8D
	L2ItemInstance wpn = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
	if (wpn == null)
	{
		wpn = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
		if (wpn != null)
			_player.getInventory().unEquipItemInBodySlotAndRecord(Inventory.PAPERDOLL_RHAND);
	}
	else
	{
		_player.getInventory().unEquipItemInBodySlotAndRecord(Inventory.PAPERDOLL_RHAND);
		wpn = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
		if (wpn != null)
			_player.getInventory().unEquipItemInBodySlotAndRecord(Inventory.PAPERDOLL_LHAND);
	}
	//add the flag in his hands
	_player.getInventory().equipItem(ItemTable.getInstance().createItem("", CTF._FLAG_IN_HAND_ITEM_ID, 1, _player, null));
	_player.broadcastPacket(new SocialAction(_player.getObjectId(), 16)); //amazing glow
	_player._haveFlagCTF = true;
	_player.broadcastUserInfo();
	_player.sendPacket(new CreatureSay(_player.getObjectId(), 15, ":", "You got it! Run back! ::")); // 8D
}

public static void removeFlagFromPlayer(L2PcInstance player)
{
	final L2ItemInstance wpn = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
	player._haveFlagCTF = false;
	if (wpn != null)
	{
		final L2ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
		player.getInventory().destroyItemByItemId("", CTF._FLAG_IN_HAND_ITEM_ID, 1, player, null);
		InventoryUpdate iu = new InventoryUpdate();
		for (L2ItemInstance element : unequiped)
			iu.addModifiedItem(element);
		player.sendPacket(iu);
		player.sendPacket(new ItemList(player, true)); // get your weapon back now ...
		player.abortAttack();
		player.broadcastUserInfo();
	}
	else
	{
		player.getInventory().destroyItemByItemId("", CTF._FLAG_IN_HAND_ITEM_ID, 1, player, null);
		player.sendPacket(new ItemList(player, true)); // get your weapon back now ...
		player.abortAttack();
		player.broadcastUserInfo();
	}
}

Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0

what i have to do with that in freya server ?

 

player.isOnline() == 0

 

and

 

player.isOnline() != 0

 

isOnline is boolean postIL.

 

So it becomes !player.isOnline() for 0, and player.isOnline() for 1.

 

Your first problem is due to the fact you try to unequip in a slot which is out of current possibilities. Aka you try to use an non-registered slot.

 

I invite you to check how unEquipItemInBodySlotAndRecord() method is used in your current pack.

Link to comment
Share on other sites

  • 0

unEquipItemInBodySlotAndRecord

 

 

                     

 case PAPERDOLL_HAIR:		slot = L2Item.SLOT_HAIR;
		break;
		case PAPERDOLL_HAIR2:		slot = L2Item.SLOT_HAIR2;
		break;
		case PAPERDOLL_HEAD:		slot = L2Item.SLOT_HEAD;
		break;
		case PAPERDOLL_RHAND:		slot = L2Item.SLOT_R_HAND;
		break;
		case PAPERDOLL_LHAND:		slot = L2Item.SLOT_L_HAND;
		break;
		case PAPERDOLL_GLOVES:		slot = L2Item.SLOT_GLOVES;
		break;

 

ctf code :

public static void addFlagToPlayer(L2PcInstance _player)
{
	//remove items from the player hands (right, left, both)
	// This is NOT a BUG, I don't want them to see the icon they have 8D
	L2ItemInstance wpn = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
	if (wpn == null)
	{
		wpn = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
		if (wpn != null)
			_player.getInventory().unEquipItemInBodySlotAndRecord(Inventory.PAPERDOLL_RHAND);
	}
	else
	{
		_player.getInventory().unEquipItemInBodySlotAndRecord(Inventory.PAPERDOLL_RHAND);
		wpn = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
		if (wpn != null)
			_player.getInventory().unEquipItemInBodySlotAndRecord(Inventory.PAPERDOLL_LHAND);
	}

 

or its anything of this :

 

_player.getInventory().equipItem(ItemTable.getInstance().createItem("", [color=orange]CTF._FLAG_IN_HAND_ITEM_ID, 1,[/color] _player, null));

Link to comment
Share on other sites

  • 0

I invite you to check how unEquipItemInBodySlotAndRecord() method is used in your current pack.

 

TIP : The important word is "used". I didn't say to analyze this part of code, but to analyze how it is used on different parts of your pack.

 

Another thing, when happens your error ? When you try to pickup the flag ?

Link to comment
Share on other sites

  • 0

i donno maybe you can help me with that ?

 

 

 

You "dunno" or you are simply to lazy to do it by your self and expect ready solution?

 

He gave you hint, now use it by yourself, its request dev help, not request ready code section.

Link to comment
Share on other sites

  • 0

ye but i am just learn java so i dont know that much i had todo with oly / and some scripts for pvp pk announce and color not more

 

sorry

 

Without own effort you won't achieve anything, trust me.

 

Just read, use brain, analyze, TEST your own codes, fix your mistakes by trying.

 

And you will learn something for sure.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock