Рейтинг темы:
  • 2 Голос(ов) - 3 в среднем
  • 1
  • 2
  • 3
  • 4
  • 5
setClassId
#1
Сделал "квест" который выдает профу, все работает как надо, но при релоге профа возвращается на старую, как решить эту проблему?
[SRC="java"]/*
* 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 village_master.getProf;

import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2Pc Instance;
import com.l2jserver.gameserver.model.base.ClassId;
import com.l2jserver.gameserver.model.itemcontainer.Inven tory;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.quest.State;
import com.l2jserver.gameserver.network.serverpackets.Soc ialAction;

/**
* Path of the Warrior (401)
* @author jython script by ElgarL, Mr.
* @version 2010-12-29 (Freya)
*/
public class getProf extends Quest
{

private static final String qn = "getProf";
// Npc
private static final int Auron = 30010;

@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("1"))
{
if (player.getClassId().getId() == 0x00)
{
if (player.getLevel() >= 20)
{
htmltext = "30010-01.htm";
st.set("cond", "1");
}
else
{
htmltext = "30010_level.htm";
}
}
else
{
htmltext = "30010_sbros.htm";
}
}
else if ((event.equalsIgnoreCase("2") && st.getInt("cond") == 1))
{
st.addExpAndSp(0, 1000000000);
st.giveItems(57, 15000000);
player.setClassId(1);
st.playSound("ItemSound.quest_finish");
player.sendPacket(new SocialAction(player.getObjectId(), 3));
htmltext = "30010.htm";
}
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.htm";
st.set("cond", "1");
}
else if (st.getInt("cond") == 1)
{
htmltext = "30010-01.html";
st.set("cond", "2");
}
else if (st.getInt("cond") == 2)
{
st.giveItems(57, 15000000);
st.addExpAndSp(0, 1000000000);
player.setClassId(1);
st.playSound("ItemSound.quest_finish");
player.sendPacket(new SocialAction(player.getObjectId(), 3));
st.exitQuest(false);
htmltext = "30010.html";
}
}
return htmltext;
}

public getProf(int questId, String name, String descr)
{
super(questId, name, descr);
addStartNpc(Auron);
addTalkId(Auron);
}

public static void main(String[] args)
{
new getProf(30010, qn, "getProf");
}
}
[/SRC]
[SRC="html"]<td background="L2UI_CT1.Windows_DF_Drawer_Bg"><button value="Профа 1" action="bypass -h Quest getProf 2" width=202 height=34 back="L2UI_CT1.OlympiadWnd_DF_Fight1None_Down" fore="L2UI_CT1.OlympiadWnd_DF_Fight1None"/></td>
[/SRC]
Ответ
#2
Запись в БД делайте (если в функцие setClassId этого нету)
Ответ
#3
В классе Player смотрим методы
Код:
public static Player restore(final int objectId)
//Восстановление персонажа входе

Сохранять в базу должно по идее сразу при смене профы.
Смотрим метод
Код:
public synchronized void setClassId(final int id, boolean noban, boolean fromQuest)
Там ищем переход на метод
Код:
public void storeCharSubClasses()
В нем переход на
Код:
CharacterSubclassDAO.getInstance().store(this);

Вот в общем все места перечислил где искать надо.
Ответ
#4
WoWan-SM Написал:В классе Player смотрим методы
Вот в общем все места перечислил где искать надо.
У него исходник l2j,а не l2p :hummer:
добавь строку setBaseClass
Ответ
#5
с setBaseClass работает, но не совсем так как мне надо, возможно ли сделать без смены модельки чара? у меня чар был маг, стал воин.
Я про это:

Добавлено через 1 час 0 минут
Как сделать запись в бд?
Ответ
#6
Советую тебе сделать
Код:
            player.addSubClass(ид класса, 1);
            player.setActiveClass(activeChar.getTotalSubClasses());
Ответ
#7
L2J Написал:Сделал "квест" который выдает профу, все работает как надо, но при релоге профа возвращается на старую, как решить эту проблему?
[SRC="java"]/*
* 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 village_master.getProf;

import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2Pc Instance;
import com.l2jserver.gameserver.model.base.ClassId;
import com.l2jserver.gameserver.model.itemcontainer.Inven tory;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.quest.State;
import com.l2jserver.gameserver.network.serverpackets.Soc ialAction;

/**
* Path of the Warrior (401)
* @author jython script by ElgarL, Mr.
* @version 2010-12-29 (Freya)
*/
public class getProf extends Quest
{

private static final String qn = "getProf";
// Npc
private static final int Auron = 30010;

@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("1"))
{
if (player.getClassId().getId() == 0x00)
{
if (player.getLevel() >= 20)
{
htmltext = "30010-01.htm";
st.set("cond", "1");
}
else
{
htmltext = "30010_level.htm";
}
}
else
{
htmltext = "30010_sbros.htm";
}
}
else if ((event.equalsIgnoreCase("2") && st.getInt("cond") == 1))
{
st.addExpAndSp(0, 1000000000);
st.giveItems(57, 15000000);
player.setClassId(1);
st.playSound("ItemSound.quest_finish");
player.sendPacket(new SocialAction(player.getObjectId(), 3));
htmltext = "30010.htm";
}
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.htm";
st.set("cond", "1");
}
else if (st.getInt("cond") == 1)
{
htmltext = "30010-01.html";
st.set("cond", "2");
}
else if (st.getInt("cond") == 2)
{
st.giveItems(57, 15000000);
st.addExpAndSp(0, 1000000000);
player.setClassId(1);
st.playSound("ItemSound.quest_finish");
player.sendPacket(new SocialAction(player.getObjectId(), 3));
st.exitQuest(false);
htmltext = "30010.html";
}
}
return htmltext;
}

public getProf(int questId, String name, String descr)
{
super(questId, name, descr);
addStartNpc(Auron);
addTalkId(Auron);
}

public static void main(String[] args)
{
new getProf(30010, qn, "getProf");
}
}
[/SRC]
[SRC="html"]<td background="L2UI_CT1.Windows_DF_Drawer_Bg"><button value="Профа 1" action="bypass -h Quest getProf 2" width=202 height=34 back="L2UI_CT1.OlympiadWnd_DF_Fight1None_Down" fore="L2UI_CT1.OlympiadWnd_DF_Fight1None"/></td>
[/SRC]


"else if ((event.equalsIgnoreCase("2") && st.getInt("cond") == 1))"

возможен дюп.
без форматирования код ад =(
Человек просто обязан ошибаться, раз другие учатся на его ошибках .......
Ответ


Перейти к форуму:


Пользователи, просматривающие эту тему: 1 Гость(ей)