Jump to content
  • 0

Mana Potion problem


Question

Posted

i want to make mana potion to give less mana if player is flaged ..

i don't know what i do wrong... so please help me:

 

i use the latest l2j revision..

 

package handlers.itemhandlers;

import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;

public class ManaPotion extends ItemSkills
{
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
	if (!Config.L2JMOD_ENABLE_MANA_POTIONS_SUPPORT)
	{
		playable.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_HAPPENED));
		return;
	}

               L2PcInstance player = getClient().getActiveChar();

		if (player.getPvpFlag() > 0)
	{
	L2Skill skill = SkillTable.getInstance().getInfo(10001, 1);	
	player.useMagic(skill, true, false);
       }
	else
	{L2Skill skill = SkillTable.getInstance().getInfo(10003, 1);	
	player.useMagic(skill, true, false);
		playable.sendMessage("unflaged");
	}
}
}

 

i've try this as well:

playable.broadcastPacket(new MagicSkillUse(player, 10001, 1, 0, 0));

 

THX:)

 

edited:"playable.sendMessage("unflaged");" i see this message but no mana...

 

 

 

3 answers to this question

Recommended Posts

  • 0
Posted

It's not precised in your post, but I suppose both possibilities are broken.

 

You use "L2PcInstance player = getClient().getActiveChar();" when it's not even related to playable.

 

public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)

That means the item "item" used by the playable "playable"...

 

Use playable instead of your player stuff. And indent your code properly...

 

package handlers.itemhandlers;

import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;

public class ManaPotion extends ItemSkills
{
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
	if (!Config.L2JMOD_ENABLE_MANA_POTIONS_SUPPORT)
	{
		playable.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_HAPPENED));
		return;
	}

	if (playable.getPvpFlag() > 0)
	{
		L2Skill skill = SkillTable.getInstance().getInfo(10001, 1);	
		playable.useMagic(skill, true, false);
       }
	else
	{
		L2Skill skill = SkillTable.getInstance().getInfo(10003, 1);	
		playable.useMagic(skill, true, false);
	}
}
}

 

I just pointed the fact to use playable, to use a skill, just check how others items are handled... I only used your code, not verifying if it was good to cast something.

Guest
This topic is now closed to further replies.


×
×
  • Create New...