Page 1 of 1

NPCBuffer Bug?

Posted: Sat Sep 12, 2009 6:55 pm
by Ninja
If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision Number:
L2JDP Revision Number:

Code: Select all

else if (command.startsWith("Buff"))		{			String[] buffGroupArray = command.substring(5).split(" "); 			for (String buffGroupList : buffGroupArray)			{				if (buffGroupList == null)				{					_log.warning("NPC Buffer Warning: npcId = " + npcId + " has no buffGroup set in the bypass for the buff selected.");					return;				} 				int buffGroup = Integer.parseInt(buffGroupList); 				int[] npcBuffGroupInfo = NpcBufferTable.getInstance().getSkillInfo(npcId, buffGroup); 				if (npcBuffGroupInfo == null) [color=#FF0000][b]<------ I THINK RETURNS 0 NOT NULL[/b][/color]				{					_log.warning("NPC Buffer Warning: npcId = " + npcId + " Location: " + getX() + ", " + getY() + ", " + getZ() + " Player: " + player.getName() + " has tried to use skill group (" + buffGroup + ") not assigned to the NPC Buffer!");					return;				} 				int skillId = npcBuffGroupInfo[0];				int skillLevel = npcBuffGroupInfo[1];				int skillFeeId = npcBuffGroupInfo[2];				int skillFeeAmount = npcBuffGroupInfo[3]; 				if (skillFeeId != 0)				{					L2ItemInstance itemInstance = player.getInventory().getItemByItemId(skillFeeId); 					if (itemInstance == null || (!itemInstance.isStackable() && player.getInventory().getInventoryItemCount(skillFeeId, -1) < skillFeeAmount))					{						SystemMessage sm = new SystemMessage(SystemMessageId.THERE_ARE_NOT_ENOUGH_NECESSARY_ITEMS_TO_USE_THE_SKILL);						player.sendPacket(sm);						continue;					} 					if (itemInstance.isStackable())					{						if (!player.destroyItemByItemId("Npc Buffer", skillFeeId, skillFeeAmount, player.getTarget(), true))						{							SystemMessage sm = new SystemMessage(SystemMessageId.THERE_ARE_NOT_ENOUGH_NECESSARY_ITEMS_TO_USE_THE_SKILL);							player.sendPacket(sm);							continue;						}					}					else					{						for (int i = 0; i < skillFeeAmount; ++i)						{							player.destroyItemByItemId("Npc Buffer", skillFeeId, 1, player.getTarget(), true);						}					}				} 				L2Skill skill;				skill = SkillTable.getInstance().getInfo(skillId, skillLevel); 				if (skill != null)					skill.getEffects(player, player);			} 			showChatWindow(player, pageVal);		}
I think "npcBuffGroupInfo" returns 0. For example if you insert into your buffer HTM a buff that does not exist in the database the npcBuffGroupInfo returns 0. I am not a programmer but I think null and 0 are completely 2 different values.

Re: NPCBuffer Bug?

Posted: Sun Sep 13, 2009 7:25 am
by _DS_
npcBuffGroupInfo is an array and array itself cant be 0, only null.

Re: NPCBuffer Bug?

Posted: Sun Sep 13, 2009 9:20 am
by Ninja
_DS_ wrote:npcBuffGroupInfo is an array and array itself cant be 0, only null.
True but my explanation was wrong. Let me rephrase it again. The problem is that when I write a skill in the NPCBuffer.htm file (for example bypass -h npc_%objectId%_Buff 1323 <- nobles skill) and the skill is not in the npc_buffer database table it should return the following error _log.warning("NPC Buffer Warning: npcId = " + npcId + " Location: " + getX() + ", " + getY() + ", " + getZ() + " Player: " + player.getName() + " has tried to use skill group (" + buffGroup + ") not assigned to the NPC Buffer!");

But I think npcBuffGroupInfo returns the following values npcBuffGroupInfo[0] = 0, npcBuffGroupInfo[1] = 0, npcBuffGroupInfo[2] = 0, npcBuffGroupInfo[3] = 0 and because the array contains the values 0 npcBuffGroupInfo == null will never be true. The code continues to give you the skill but it is not happening because there is no skill with id=0.

Re: NPCBuffer Bug?

Posted: Sun Sep 13, 2009 9:38 am
by _DS_
Replace it with
if (npcBuffGroupInfo == null || npcBuffGroupInfo[0] == 0)