Jump to content

Question

Posted (edited)

/*

 * Copyright © 2004-2016 L2J Server

 * 

 * This file is part of L2J Server.

 * 

 * L2J Server 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.

 * 

 * L2J Server 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 custom.level;

 

import com.l2jserver.gameserver.instancemanager.GlobalVariablesManager;

import com.l2jserver.gameserver.model.actor.L2Npc;

import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;

import com.l2jserver.gameserver.model.quest.Quest;

import com.l2jserver.gameserver.util.Broadcast;

 

public class LevelNpc extends Quest

{

 

@Override

public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)

{

int count = Integer.parseInt(GlobalVariablesManager.getInstance().getStoredVariable("level"));

if (event.equals("83"))

{

if ((player.getLevel() >= 83) && (count > 0) && (player.getInventory().getItemByItemId(23050) == null))

{

count--;

if (count > 1)

{

Broadcast.toAllOnlinePlayers("Congratulation " + player.getName() + " Reach 83, to receive a prize, reward leveling places left" + count + "One, please continue to work hard!");

}

else

{

Broadcast.toAllOnlinePlayers("Congratulation " + player.getName() + " Reach 83, to receive a prize, award leveling activities has ended! I wish you all a happy game");

}

 

GlobalVariablesManager.getInstance().storeVariable("level", String.valueOf(count));

player.addItem("", 23050, 1, null, false);

player.addItem("", 24012, 3, null, true);

}

else

{

player.sendMessage("You do not meet the conditions, can not receive the award");

}

}

return super.onAdvEvent(event, npc, player);

}

 

@Override

public String onFirstTalk(L2Npc npc, L2PcInstance player)

{

if (Integer.parseInt(GlobalVariablesManager.getInstance().getStoredVariable("level")) > 0)

{

return "1.htm";

}

return "2.htm";

}

 

public LevelNpc(int questId, String name, String descr)

{

super(questId, name, descr);

addTalkId(152);

addStartNpc(152);

addFirstTalkId(152);

addSpawn(152, 83440, 148580, -3405, 3600, false, 0);

}

 

public static void main(String[] args)

{

new LevelNpc(-1, LevelNpc.class.getSimpleName(), "custom");

}

}

 

Edited by curtain

1 answer to this question

Recommended Posts

Guest
This topic is now closed to further replies.


×
×
  • Create New...