Page 1 of 1

[HELP]giftofvitality

Posted: Thu Aug 12, 2010 8:29 pm
by sancak
If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision Number:
L2JDP Revision Number:

i'm tring to adopt gnacik work to gracia final but i got an error at line 54 i also add the sql files for npc but when i spawn npc id 4306 there isn't any npc display.

Type mismatch: cannot convert from Object to String.. what should i do?

Code: Select all

/* * 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */package events.GiftOfVitality; import net.sf.l2j.gameserver.datatables.SkillTable;import net.sf.l2j.gameserver.instancemanager.QuestManager;import net.sf.l2j.gameserver.model.actor.L2Npc;import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;import net.sf.l2j.gameserver.model.quest.Quest;import net.sf.l2j.gameserver.model.quest.QuestState;import net.sf.l2j.gameserver.network.SystemMessageId;import net.sf.l2j.gameserver.network.serverpackets.SystemMessage; /** ** @author Gnacik ** ** Event : 'Gift of Vitality' */public class GiftOfVitality extends Quest{	private static final int _jack = 4306; 	public GiftOfVitality(int questId, String name, String descr)	{		super(questId, name, descr);		addStartNpc(_jack);		addFirstTalkId(_jack);		addTalkId(_jack);	} 	@Override	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)	{		String htmltext = "";		QuestState st = player.getQuestState(getName());		htmltext = event; 		if (event.equalsIgnoreCase("vitality"))		{			long _reuse = 0;			String _streuse = st.get("reuse");			if(_streuse != null)				_reuse = Long.parseLong(_streuse);			if(_reuse > System.currentTimeMillis())			{				long remainingTime = (_reuse - System.currentTimeMillis()) / 1000;				int hours = (int) (remainingTime / 3600);				int minutes = (int) ((remainingTime%3600) / 60);				SystemMessage sm = new SystemMessage(SystemMessageId.AVAILABLE_AFTER_S1_S2_HOURS_S3_MINUTES);				sm.addSkillName(23179);				sm.addNumber(hours);				sm.addNumber(minutes);				player.sendPacket(sm);				htmltext = "4306-notime.htm";			}			else			{				npc.setTarget(player);				npc.doCast(SkillTable.getInstance().getInfo(23179,1));	// Gift of Vitality				st.set("reuse", String.valueOf(System.currentTimeMillis() + 60*60*5*1000));				htmltext = "4306-okvitality.htm";			}		}		else if (event.equalsIgnoreCase("memories_player"))		{			if (player.getLevel() < 76)			{				htmltext = "4306-nolevel.htm";			}			else			{								if (player.isMageClass())				{					npc.setTarget(player);					npc.doCast(SkillTable.getInstance().getInfo(5627,1));	// Wind Walk					npc.doCast(SkillTable.getInstance().getInfo(5628,1));	// Shield					npc.doCast(SkillTable.getInstance().getInfo(5637,1));	// Magic Barrier					npc.doCast(SkillTable.getInstance().getInfo(5633,1));	// Bless the Soul					npc.doCast(SkillTable.getInstance().getInfo(5634,1));	// Acumen					npc.doCast(SkillTable.getInstance().getInfo(5635,1));	// Concentration					npc.doCast(SkillTable.getInstance().getInfo(5636,1));	// Empower				}				else				{					npc.setTarget(player);					npc.doCast(SkillTable.getInstance().getInfo(5627,1));	// Wind Walk					npc.doCast(SkillTable.getInstance().getInfo(5628,1));	// Shield					npc.doCast(SkillTable.getInstance().getInfo(5637,1));	// Magic Barrier					npc.doCast(SkillTable.getInstance().getInfo(5629,1));	// Bless the Body					npc.doCast(SkillTable.getInstance().getInfo(5630,1));	// Vampiric Rage					npc.doCast(SkillTable.getInstance().getInfo(5631,1));	// Regeneration					npc.doCast(SkillTable.getInstance().getInfo(5632,1));	// Haste				}				htmltext = "4306-okbuff.htm";			}		}		else if (event.equalsIgnoreCase("memories_summon"))		{			if (player.getLevel() < 76)			{				htmltext = "4306-nolevel.htm";			}			else if (player.getPet() == null || !(player.getPet() instanceof L2SummonInstance))			{				htmltext = "4306-nosummon.htm";			}			else			{				npc.setTarget(player.getPet());				npc.doCast(SkillTable.getInstance().getInfo(5627,1));	// Wind Walk				npc.doCast(SkillTable.getInstance().getInfo(5628,1));	// Shield				npc.doCast(SkillTable.getInstance().getInfo(5637,1));	// Magic Barrier				npc.doCast(SkillTable.getInstance().getInfo(5629,1));	// Bless the Body				npc.doCast(SkillTable.getInstance().getInfo(5633,1));	// Bless the Soul				npc.doCast(SkillTable.getInstance().getInfo(5630,1));	// Vampiric Rage				npc.doCast(SkillTable.getInstance().getInfo(5634,1));	// Acumen				npc.doCast(SkillTable.getInstance().getInfo(5631,1));	// Regeneration				npc.doCast(SkillTable.getInstance().getInfo(5635,1));	// Concentration				npc.doCast(SkillTable.getInstance().getInfo(5632,1));	// Haste				npc.doCast(SkillTable.getInstance().getInfo(5636,1));	// Empower				htmltext = "4306-okbuff.htm";			}		} 		return htmltext;	} 	@Override	public String onFirstTalk(L2Npc npc, L2PcInstance player)	{		QuestState st = player.getQuestState(getName());		if (st == null)		{			Quest q = QuestManager.getInstance().getQuest(getName());			st = q.newQuestState(player);		}		return "4306.htm";	} 	public static void main(String[] args)	{		new GiftOfVitality(-1, "GiftOfVitality", "events");	}}

Re: [HELP]giftofvitality

Posted: Fri Aug 13, 2010 9:14 am
by jurchiks
afaik the npc doesn't exist in GF client...

Re: [HELP]giftofvitality

Posted: Fri Aug 13, 2010 9:26 am
by sancak
ok npc display not important i can create another npc... what about code?

Re: [HELP]giftofvitality

Posted: Fri Aug 13, 2010 12:07 pm
by jurchiks
check com.l2jserver.model.quest.QuestState
this method
/**
* Return the value of the variable of quest represented by "var"
* @param var : name of the variable of quest
* @return String
*/
public String get(String var)
{
if (_vars == null)
return null;

return _vars.get(var);
}
check if it's exactly the same (search only for "get(" or the comment), if I remember correctly this thing was found and fixed by janiii because of me some time ago (~3 months maybe), but it was in epilogue already.

Re: [HELP]giftofvitality

Posted: Fri Aug 13, 2010 7:38 pm
by sancak
jurchiks wrote:check com.l2jserver.model.quest.QuestState
this method
/**
* Return the value of the variable of quest represented by "var"
* @param var : name of the variable of quest
* @return String
*/
public String get(String var)
{
if (_vars == null)
return null;

return _vars.get(var);
}
check if it's exactly the same (search only for "get(" or the comment), if I remember correctly this thing was found and fixed by janiii because of me some time ago (~3 months maybe), but it was in epilogue already.
hmm mine is

Code: Select all

 	/**	 * Return the value of the variable of quest represented by "var"	 * @param var : name of the variable of quest	 * @return Object	 */	public Object get(String var)	{		if (_vars == null)			return null; 		return _vars.get(var);	} 
is it the same where? i will try it now, if it is the solution i will write here.

Re: [HELP]giftofvitality

Posted: Fri Aug 13, 2010 8:44 pm
by jurchiks
yea, that's what I thought... Change "Object" to "String" and that's it