05-10-2013, 04:17 PM
Как сделать так: Если один раз нажал получить золото, второй раз уже нельзя было.
Вот мой квест:
То есть если уже один раз нажал на else if (event.equalsIgnoreCase("11111_Gold")), второй раз уже нельзя, думаю понятно объяснил. За основу взял квест на первую профу.
Вот мой квест:
Квест
[SRC="python"]/*
* 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 quests.Q11111_StartedEquip;
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.model.quest.QuestState;
import com.l2jserver.gameserver.model.quest.State;
/**
* Path of the Warrior (401)
* @author jython script by ElgarL, Mr.
* @version 2010-12-29 (Freya)
*/
public class Q11111_StartedEquip extends Quest
{
private static final String qn = "11111_StartedEquip";
// Item
private static final int LightBag = 1138;
private static final int HeavyBag = 1139;
private static final int RobeBag = 1140;
private static final int Gold = 57;
// Npc
private static final int Auron = 30010;
private static final int Simplon = 30253;
private static final int[] Monsters = { 20035, 20038, 20042, 20043 };
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
String htmltext = event;
QuestState st = player.getQuestState(qn);
if (st == null)
{
return htmltext;
}
if (event.equalsIgnoreCase("11111_1"))
{
if (player.getLevel() <= 20)
{
{
htmltext = "30010-04.htm";
}
}
}
else if (event.equalsIgnoreCase("11111_Gold"))
{
st.setState(State.STARTED);
st.set("cond", "1");
st.giveItems(Gold, 100);
st.addExpAndSp(90, 50);
st.playSound("ItemSound.quest_accept");
st.exitQuest(true);
st.saveGlobalQuestVar("1ClassQuestFinished", "1");
htmltext = "30010-13.html";
}
else if (event.equalsIgnoreCase("11111_Golden"))
{
st.setState(State.STARTED);
st.set("cond", "1");
st.giveItems(Gold, 100);
st.playSound("ItemSound.quest_accept");
st.exitQuest(false);
st.saveGlobalQuestVar("1ClassQuestFinished", "1");
htmltext = "30010-13.html";
}
return htmltext;
}
@Override
public String onTalk(L2Npc npc, L2PcInstance player)
{
String htmltext = getNoQuestMsg(player);
QuestState st = player.getQuestState(qn);
if (st == null)
{
return htmltext;
}
if (npc.getNpcId() == Auron)
{
if (st.getInt("cond") == 0)
{
htmltext = "30010-01.htm";
}
else if (st.getInt("cond") == 1)
{
htmltext = "30010-07.html";
}
else if ((st.getInt("cond") == 2) || (st.getInt("cond") == 3))
{
htmltext = "30010-08.html";
}
else if (st.getInt("cond") == 4)
{
htmltext = "30010-09.html";
}
else if (st.getInt("cond") == 5)
{
htmltext = "30010-12.html";
}
}
else if (npc.getNpcId() == Simplon)
{
if (st.getInt("cond") == 1)
{
htmltext = "30253-01.html";
}
else if (st.getInt("cond") == 2)
{
htmltext = "30253-03.html";
}
else if (st.getInt("cond") == 4)
{
htmltext = "30253-05.html";
}
}
return htmltext;
}
public Q11111_StartedEquip(int questId, String name, String descr)
{
super(questId, name, descr);
addStartNpc(Auron);
addTalkId(Auron);
addTalkId(Simplon);
}
public static void main(String[] args)
{
new Q11111_StartedEquip(11111, qn, "Started Equip");
}
}
[/SRC]
* 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 quests.Q11111_StartedEquip;
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.model.quest.QuestState;
import com.l2jserver.gameserver.model.quest.State;
/**
* Path of the Warrior (401)
* @author jython script by ElgarL, Mr.
* @version 2010-12-29 (Freya)
*/
public class Q11111_StartedEquip extends Quest
{
private static final String qn = "11111_StartedEquip";
// Item
private static final int LightBag = 1138;
private static final int HeavyBag = 1139;
private static final int RobeBag = 1140;
private static final int Gold = 57;
// Npc
private static final int Auron = 30010;
private static final int Simplon = 30253;
private static final int[] Monsters = { 20035, 20038, 20042, 20043 };
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
String htmltext = event;
QuestState st = player.getQuestState(qn);
if (st == null)
{
return htmltext;
}
if (event.equalsIgnoreCase("11111_1"))
{
if (player.getLevel() <= 20)
{
{
htmltext = "30010-04.htm";
}
}
}
else if (event.equalsIgnoreCase("11111_Gold"))
{
st.setState(State.STARTED);
st.set("cond", "1");
st.giveItems(Gold, 100);
st.addExpAndSp(90, 50);
st.playSound("ItemSound.quest_accept");
st.exitQuest(true);
st.saveGlobalQuestVar("1ClassQuestFinished", "1");
htmltext = "30010-13.html";
}
else if (event.equalsIgnoreCase("11111_Golden"))
{
st.setState(State.STARTED);
st.set("cond", "1");
st.giveItems(Gold, 100);
st.playSound("ItemSound.quest_accept");
st.exitQuest(false);
st.saveGlobalQuestVar("1ClassQuestFinished", "1");
htmltext = "30010-13.html";
}
return htmltext;
}
@Override
public String onTalk(L2Npc npc, L2PcInstance player)
{
String htmltext = getNoQuestMsg(player);
QuestState st = player.getQuestState(qn);
if (st == null)
{
return htmltext;
}
if (npc.getNpcId() == Auron)
{
if (st.getInt("cond") == 0)
{
htmltext = "30010-01.htm";
}
else if (st.getInt("cond") == 1)
{
htmltext = "30010-07.html";
}
else if ((st.getInt("cond") == 2) || (st.getInt("cond") == 3))
{
htmltext = "30010-08.html";
}
else if (st.getInt("cond") == 4)
{
htmltext = "30010-09.html";
}
else if (st.getInt("cond") == 5)
{
htmltext = "30010-12.html";
}
}
else if (npc.getNpcId() == Simplon)
{
if (st.getInt("cond") == 1)
{
htmltext = "30253-01.html";
}
else if (st.getInt("cond") == 2)
{
htmltext = "30253-03.html";
}
else if (st.getInt("cond") == 4)
{
htmltext = "30253-05.html";
}
}
return htmltext;
}
public Q11111_StartedEquip(int questId, String name, String descr)
{
super(questId, name, descr);
addStartNpc(Auron);
addTalkId(Auron);
addTalkId(Simplon);
}
public static void main(String[] args)
{
new Q11111_StartedEquip(11111, qn, "Started Equip");
}
}
[/SRC]